Skip to content

Commit 6d4ae18

Browse files
authored
Fix bogus "no jsdoc types" error in jsdoc (#1524)
1 parent 16953b7 commit 6d4ae18

19 files changed

+26
-175
lines changed

internal/checker/checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,7 @@ func (c *Checker) checkAccessorDeclaration(node *ast.Node) {
27842784

27852785
func (c *Checker) checkTypeReferenceNode(node *ast.Node) {
27862786
c.checkGrammarTypeArguments(node, node.TypeArgumentList())
2787-
if ast.IsTypeReferenceNode(node) {
2787+
if ast.IsTypeReferenceNode(node) && node.Flags&ast.NodeFlagsJSDoc == 0 {
27882788
data := node.AsTypeReferenceNode()
27892789
if data.TypeArguments != nil && data.TypeName.End() != data.TypeArguments.Pos() {
27902790
// If there was a token between the type name and the type arguments, check if it was a DotToken

testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag12.errors.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/a.js(24,20): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T1'.
22
/a.js(29,14): error TS2741: Property 'a' is missing in type '{}' but required in type 'T1'.
3-
/a.js(32,21): error TS8020: JSDoc types can only be used inside documentation comments.
43
/a.js(44,25): error TS2353: Object literal may only specify known properties, and 'b' does not exist in type 'T2'.
54
/a.js(51,42): error TS1360: Type 'number' does not satisfy the expected type 'string'.
65

76

8-
==== /a.js (5 errors) ====
7+
==== /a.js (4 errors) ====
98
/**
109
* @typedef {Object} T1
1110
* @property {number} a
@@ -43,8 +42,6 @@
4342

4443
/**
4544
* @satisfies {Array.<number, number>}
46-
~
47-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
4845
*/
4946
const t4 = [1, 2];
5047

testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.errors.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
/a.js(1,15): error TS2315: Type 'Object' is not generic.
2-
/a.js(1,21): error TS8020: JSDoc types can only be used inside documentation comments.
32

43

5-
==== /a.js (2 errors) ====
4+
==== /a.js (1 errors) ====
65
/** @typedef {Object.<string, (n: number) => boolean>} Predicates */
76
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87
!!! error TS2315: Type 'Object' is not generic.
9-
~
10-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
118

129
const p = /** @satisfies {Predicates} */ ({
1310
isEven: n => n % 2 === 0,

testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.errors.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
/a.js(1,15): error TS2315: Type 'Object' is not generic.
2-
/a.js(1,21): error TS8020: JSDoc types can only be used inside documentation comments.
32

43

5-
==== /a.js (2 errors) ====
4+
==== /a.js (1 errors) ====
65
/** @typedef {Object.<string, boolean>} Facts */
76
~~~~~~~~~~~~~~~~~~~~~~~~
87
!!! error TS2315: Type 'Object' is not generic.
9-
~
10-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
118

129
// Should be able to detect a failure here
1310
const x = /** @satisfies {Facts} */ ({

testdata/baselines/reference/submodule/conformance/classCanExtendConstructorFunction.errors.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
first.js(21,19): error TS2507: Type '{ (numberOxen: number): void; circle: (wagons: any) => any; }' is not a constructor function type.
2-
first.js(27,21): error TS8020: JSDoc types can only be used inside documentation comments.
32
first.js(44,4): error TS2339: Property 'numberOxen' does not exist on type 'Sql'.
43
first.js(47,24): error TS2507: Type '(numberEaten: number) => void' is not a constructor function type.
54
generic.js(9,23): error TS2507: Type '<T>(flavour: T) => void' is not a constructor function type.
@@ -12,7 +11,7 @@ second.ts(14,25): error TS2507: Type '{ (numberOxen: number): void; circle: (wag
1211
second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Conestoga'.
1312

1413

15-
==== first.js (4 errors) ====
14+
==== first.js (3 errors) ====
1615
/**
1716
* @constructor
1817
* @param {number} numberOxen
@@ -42,8 +41,6 @@ second.ts(26,3): error TS2339: Property 'numberOxen' does not exist on type 'Con
4241
}
4342
/**
4443
* @param {Array.<string>} files
45-
~
46-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
4744
* @param {"csv" | "json" | "xmlolololol"} format
4845
* This is not assignable, so should have a type error
4946
*/

testdata/baselines/reference/submodule/conformance/jsDeclarationsMissingTypeParameters.errors.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
file.js(12,19): error TS8020: JSDoc types can only be used inside documentation comments.
21
file.js(12,20): error TS1099: Type argument list cannot be empty.
32

43

5-
==== file.js (2 errors) ====
4+
==== file.js (1 errors) ====
65
/**
76
* @param {Array=} y desc
87
*/
@@ -15,8 +14,6 @@ file.js(12,20): error TS1099: Type argument list cannot be empty.
1514

1615
/**
1716
* @return {(Array.<> | null)} list of devices
18-
~
19-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
2017
~~
2118
!!! error TS1099: Type argument list cannot be empty.
2219
*/

testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.errors.txt

Lines changed: 0 additions & 33 deletions
This file was deleted.

testdata/baselines/reference/submodule/conformance/jsDeclarationsReusesExistingNodesMappingJSDocTypes.errors.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
index.js(16,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'?
22
index.js(19,12): error TS2552: Cannot find name 'function'. Did you mean 'Function'?
33
index.js(22,12): error TS2315: Type 'Object' is not generic.
4-
index.js(22,18): error TS8020: JSDoc types can only be used inside documentation comments.
54

65

7-
==== index.js (4 errors) ====
6+
==== index.js (3 errors) ====
87
/** @type {?} */
98
export const a = null;
109

@@ -35,7 +34,5 @@ index.js(22,18): error TS8020: JSDoc types can only be used inside documentation
3534
/** @type {Object.<string, number>} */
3635
~~~~~~~~~~~~~~~~~~~~~~~
3736
!!! error TS2315: Type 'Object' is not generic.
38-
~
39-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
4037
export const h = null;
4138

testdata/baselines/reference/submodule/conformance/jsdocIndexSignature.errors.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,25 @@
11
indices.js(1,12): error TS2315: Type 'Object' is not generic.
2-
indices.js(1,18): error TS8020: JSDoc types can only be used inside documentation comments.
32
indices.js(3,12): error TS2315: Type 'Object' is not generic.
4-
indices.js(3,18): error TS8020: JSDoc types can only be used inside documentation comments.
53
indices.js(5,12): error TS2315: Type 'Object' is not generic.
6-
indices.js(5,18): error TS8020: JSDoc types can only be used inside documentation comments.
74
indices.js(7,13): error TS2315: Type 'Object' is not generic.
8-
indices.js(7,19): error TS8020: JSDoc types can only be used inside documentation comments.
95

106

11-
==== indices.js (8 errors) ====
7+
==== indices.js (4 errors) ====
128
/** @type {Object.<string, number>} */
139
~~~~~~~~~~~~~~~~~~~~~~~
1410
!!! error TS2315: Type 'Object' is not generic.
15-
~
16-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
1711
var o1;
1812
/** @type {Object.<number, boolean>} */
1913
~~~~~~~~~~~~~~~~~~~~~~~~
2014
!!! error TS2315: Type 'Object' is not generic.
21-
~
22-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
2315
var o2;
2416
/** @type {Object.<boolean, string>} */
2517
~~~~~~~~~~~~~~~~~~~~~~~~
2618
!!! error TS2315: Type 'Object' is not generic.
27-
~
28-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
2919
var o3;
3020
/** @param {Object.<string, boolean>} o */
3121
~~~~~~~~~~~~~~~~~~~~~~~~
3222
!!! error TS2315: Type 'Object' is not generic.
33-
~
34-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
3523
function f(o) {
3624
o.foo = 1; // error
3725
o.bar = false; // ok

testdata/baselines/reference/submodule/conformance/typedefTagExtraneousProperty.errors.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
typedefTagExtraneousProperty.js(1,15): error TS2315: Type 'Object' is not generic.
2-
typedefTagExtraneousProperty.js(1,21): error TS8020: JSDoc types can only be used inside documentation comments.
32

43

5-
==== typedefTagExtraneousProperty.js (2 errors) ====
4+
==== typedefTagExtraneousProperty.js (1 errors) ====
65
/** @typedef {Object.<string,string>} Mmap
76
~~~~~~~~~~~~~~~~~~~~~~
87
!!! error TS2315: Type 'Object' is not generic.
9-
~
10-
!!! error TS8020: JSDoc types can only be used inside documentation comments.
118
* @property {string} ignoreMe - should be ignored
129
*/
1310

0 commit comments

Comments
 (0)