Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1bbcb55

Browse filesBrowse files
authored
@typedef's nested Object syntax disallows type arguments (microsoft#36172)
Previously the jsdoc index signature syntax was incorrectly treated the same as Object: ```js /** @typedef {Object} AllowsNesting * @Property ... */ /** @typedef {Object.<string,string>} IncorrectlyAllowsNesting */ ``` Fixes microsoft#34911
1 parent 502e711 commit 1bbcb55
Copy full SHA for 1bbcb55

File tree

Expand file treeCollapse file tree

4 files changed

+64
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+64
-1
lines changed
Open diff view settings
Collapse file

‎src/compiler/parser.ts‎

Copy file name to clipboardExpand all lines: src/compiler/parser.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7145,7 +7145,7 @@ namespace ts {
71457145
case SyntaxKind.ArrayType:
71467146
return isObjectOrObjectArrayTypeReference((node as ArrayTypeNode).elementType);
71477147
default:
7148-
return isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object";
7148+
return isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
71497149
}
71507150
}
71517151

Collapse file
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/conformance/jsdoc/typedefTagExtraneousProperty.js ===
2+
/** @typedef {Object.<string,string>} Mmap
3+
* @property {string} ignoreMe - should be ignored
4+
*/
5+
6+
/** @type {Mmap} */
7+
var y = { bye: "no" };
8+
>y : Symbol(y, Decl(typedefTagExtraneousProperty.js, 5, 3), Decl(typedefTagExtraneousProperty.js, 6, 1), Decl(typedefTagExtraneousProperty.js, 7, 57))
9+
>bye : Symbol(bye, Decl(typedefTagExtraneousProperty.js, 5, 9))
10+
11+
y
12+
>y : Symbol(y, Decl(typedefTagExtraneousProperty.js, 5, 3), Decl(typedefTagExtraneousProperty.js, 6, 1), Decl(typedefTagExtraneousProperty.js, 7, 57))
13+
14+
y.ignoreMe = "ok but just because of the index signature"
15+
>y : Symbol(y, Decl(typedefTagExtraneousProperty.js, 5, 3), Decl(typedefTagExtraneousProperty.js, 6, 1), Decl(typedefTagExtraneousProperty.js, 7, 57))
16+
17+
y['hi'] = "yes"
18+
>y : Symbol(y, Decl(typedefTagExtraneousProperty.js, 5, 3), Decl(typedefTagExtraneousProperty.js, 6, 1), Decl(typedefTagExtraneousProperty.js, 7, 57))
19+
Collapse file
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
=== tests/cases/conformance/jsdoc/typedefTagExtraneousProperty.js ===
2+
/** @typedef {Object.<string,string>} Mmap
3+
* @property {string} ignoreMe - should be ignored
4+
*/
5+
6+
/** @type {Mmap} */
7+
var y = { bye: "no" };
8+
>y : { [x: string]: string; }
9+
>{ bye: "no" } : { bye: string; }
10+
>bye : string
11+
>"no" : "no"
12+
13+
y
14+
>y : { [x: string]: string; }
15+
16+
y.ignoreMe = "ok but just because of the index signature"
17+
>y.ignoreMe = "ok but just because of the index signature" : "ok but just because of the index signature"
18+
>y.ignoreMe : string
19+
>y : { [x: string]: string; }
20+
>ignoreMe : string
21+
>"ok but just because of the index signature" : "ok but just because of the index signature"
22+
23+
y['hi'] = "yes"
24+
>y['hi'] = "yes" : "yes"
25+
>y['hi'] : string
26+
>y : { [x: string]: string; }
27+
>'hi' : "hi"
28+
>"yes" : "yes"
29+
Collapse file
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @lib: es5
2+
// @allowjs: true
3+
// @checkjs: true
4+
// @noemit: true
5+
// @Filename: typedefTagExtraneousProperty.js
6+
7+
/** @typedef {Object.<string,string>} Mmap
8+
* @property {string} ignoreMe - should be ignored
9+
*/
10+
11+
/** @type {Mmap} */
12+
var y = { bye: "no" };
13+
y
14+
y.ignoreMe = "ok but just because of the index signature"
15+
y['hi'] = "yes"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.