Skip to content

Commit f938caf

Browse files
authored
Merge pull request #16134 from Microsoft/master-fix15250
[Master] Fix 15250 - treat "object" and "Object" the same in JSDoc type def
2 parents bebe2de + 1e8edcb commit f938caf

File tree

7 files changed

+387
-14
lines changed

7 files changed

+387
-14
lines changed

src/compiler/parser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6094,7 +6094,6 @@ namespace ts {
60946094
case SyntaxKind.NullKeyword:
60956095
case SyntaxKind.UndefinedKeyword:
60966096
case SyntaxKind.NeverKeyword:
6097-
case SyntaxKind.ObjectKeyword:
60986097
return parseTokenNode<JSDocType>();
60996098
case SyntaxKind.StringLiteral:
61006099
case SyntaxKind.NumericLiteral:
@@ -6772,7 +6771,7 @@ namespace ts {
67726771
const jsDocTypeReference = <JSDocTypeReference>typeExpression.type;
67736772
if (jsDocTypeReference.name.kind === SyntaxKind.Identifier) {
67746773
const name = <Identifier>jsDocTypeReference.name;
6775-
if (name.text === "Object") {
6774+
if (name.text === "Object" || name.text === "object") {
67766775
typedefTag.jsDocTypeLiteral = scanChildTags();
67776776
}
67786777
}

tests/baselines/reference/checkJsdocTypedefInParamTag1.js

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,29 @@
66
* @property {string=} y
77
* @property {string} [z]
88
* @property {string} [w="hi"]
9-
*
9+
*
1010
* @param {Opts} opts
1111
*/
12-
function foo(opts) {}
12+
function foo(opts) {
13+
opts.x;
14+
}
1315

14-
foo({x: 'abc'});
16+
foo({x: 'abc'});
17+
18+
/**
19+
* @typedef {object} Opts1
20+
* @property {string} x
21+
* @property {string=} y
22+
* @property {string} [z]
23+
* @property {string} [w="hi"]
24+
*
25+
* @param {Opts1} opts
26+
*/
27+
function foo1(opts) {
28+
opts.x;
29+
}
30+
foo1({x: 'abc'});
31+
1532

1633
//// [0.js]
1734
// @ts-check
@@ -24,5 +41,20 @@ foo({x: 'abc'});
2441
*
2542
* @param {Opts} opts
2643
*/
27-
function foo(opts) { }
44+
function foo(opts) {
45+
opts.x;
46+
}
2847
foo({ x: 'abc' });
48+
/**
49+
* @typedef {object} Opts1
50+
* @property {string} x
51+
* @property {string=} y
52+
* @property {string} [z]
53+
* @property {string} [w="hi"]
54+
*
55+
* @param {Opts1} opts
56+
*/
57+
function foo1(opts) {
58+
opts.x;
59+
}
60+
foo1({ x: 'abc' });

tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,42 @@
66
* @property {string=} y
77
* @property {string} [z]
88
* @property {string} [w="hi"]
9-
*
9+
*
1010
* @param {Opts} opts
1111
*/
12-
function foo(opts) {}
12+
function foo(opts) {
1313
>foo : Symbol(foo, Decl(0.js, 0, 0))
1414
>opts : Symbol(opts, Decl(0.js, 10, 13))
1515

16+
opts.x;
17+
>opts.x : Symbol(x, Decl(0.js, 3, 3))
18+
>opts : Symbol(opts, Decl(0.js, 10, 13))
19+
>x : Symbol(x, Decl(0.js, 3, 3))
20+
}
21+
1622
foo({x: 'abc'});
1723
>foo : Symbol(foo, Decl(0.js, 0, 0))
18-
>x : Symbol(x, Decl(0.js, 12, 5))
24+
>x : Symbol(x, Decl(0.js, 14, 5))
25+
26+
/**
27+
* @typedef {object} Opts1
28+
* @property {string} x
29+
* @property {string=} y
30+
* @property {string} [z]
31+
* @property {string} [w="hi"]
32+
*
33+
* @param {Opts1} opts
34+
*/
35+
function foo1(opts) {
36+
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
37+
>opts : Symbol(opts, Decl(0.js, 25, 14))
38+
39+
opts.x;
40+
>opts.x : Symbol(x, Decl(0.js, 18, 3))
41+
>opts : Symbol(opts, Decl(0.js, 25, 14))
42+
>x : Symbol(x, Decl(0.js, 18, 3))
43+
}
44+
foo1({x: 'abc'});
45+
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
46+
>x : Symbol(x, Decl(0.js, 28, 6))
1947

tests/baselines/reference/checkJsdocTypedefInParamTag1.types

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,48 @@
66
* @property {string=} y
77
* @property {string} [z]
88
* @property {string} [w="hi"]
9-
*
9+
*
1010
* @param {Opts} opts
1111
*/
12-
function foo(opts) {}
12+
function foo(opts) {
1313
>foo : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
1414
>opts : { x: string; y?: string; z?: string; w?: string; }
1515

16+
opts.x;
17+
>opts.x : string
18+
>opts : { x: string; y?: string; z?: string; w?: string; }
19+
>x : string
20+
}
21+
1622
foo({x: 'abc'});
1723
>foo({x: 'abc'}) : void
1824
>foo : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
1925
>{x: 'abc'} : { x: string; }
2026
>x : string
2127
>'abc' : "abc"
2228

29+
/**
30+
* @typedef {object} Opts1
31+
* @property {string} x
32+
* @property {string=} y
33+
* @property {string} [z]
34+
* @property {string} [w="hi"]
35+
*
36+
* @param {Opts1} opts
37+
*/
38+
function foo1(opts) {
39+
>foo1 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
40+
>opts : { x: string; y?: string; z?: string; w?: string; }
41+
42+
opts.x;
43+
>opts.x : string
44+
>opts : { x: string; y?: string; z?: string; w?: string; }
45+
>x : string
46+
}
47+
foo1({x: 'abc'});
48+
>foo1({x: 'abc'}) : void
49+
>foo1 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
50+
>{x: 'abc'} : { x: string; }
51+
>x : string
52+
>'abc' : "abc"
53+

0 commit comments

Comments
 (0)