Skip to content

Commit 27078f9

Browse files
author
Kanchalai Tanglertsampan
committed
Merge branch 'master' into master-fix16092
2 parents 227198f + f938caf commit 27078f9

13 files changed

+463
-54
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6855,6 +6855,7 @@ namespace ts {
68556855
case "Object":
68566856
return anyType;
68576857
case "Function":
6858+
case "function":
68586859
return globalFunctionType;
68596860
case "Array":
68606861
case "array":

src/compiler/parser.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6075,7 +6075,10 @@ namespace ts {
60756075
case SyntaxKind.OpenBraceToken:
60766076
return parseJSDocRecordType();
60776077
case SyntaxKind.FunctionKeyword:
6078-
return parseJSDocFunctionType();
6078+
if (lookAhead(nextTokenIsOpenParen)) {
6079+
return parseJSDocFunctionType();
6080+
}
6081+
break;
60796082
case SyntaxKind.DotDotDotToken:
60806083
return parseJSDocVariadicType();
60816084
case SyntaxKind.NewKeyword:
@@ -6091,7 +6094,6 @@ namespace ts {
60916094
case SyntaxKind.NullKeyword:
60926095
case SyntaxKind.UndefinedKeyword:
60936096
case SyntaxKind.NeverKeyword:
6094-
case SyntaxKind.ObjectKeyword:
60956097
return parseTokenNode<JSDocType>();
60966098
case SyntaxKind.StringLiteral:
60976099
case SyntaxKind.NumericLiteral:
@@ -6752,7 +6754,7 @@ namespace ts {
67526754
const jsDocTypeReference = <JSDocTypeReference>typeExpression.type;
67536755
if (jsDocTypeReference.name.kind === SyntaxKind.Identifier) {
67546756
const name = <Identifier>jsDocTypeReference.name;
6755-
if (name.text === "Object") {
6757+
if (name.text === "Object" || name.text === "object") {
67566758
typedefTag.jsDocTypeLiteral = scanChildTags();
67576759
}
67586760
}

tests/baselines/reference/checkJsdocTypedefInParamTag1.js

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
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

1416
foo({x: 'abc'});
1517

@@ -20,9 +22,26 @@ foo({x: 'abc'});
2022
*
2123
* @param {AnotherOpts} opts
2224
*/
23-
function foo1(opts) {}
25+
function foo1(opts) {
26+
opts.anotherX;
27+
}
28+
29+
foo1({anotherX: "world"});
2430

25-
foo1({anotherX: "world"});
31+
/**
32+
* @typedef {object} Opts1
33+
* @property {string} x
34+
* @property {string=} y
35+
* @property {string} [z]
36+
* @property {string} [w="hi"]
37+
*
38+
* @param {Opts1} opts
39+
*/
40+
function foo2(opts) {
41+
opts.x;
42+
}
43+
foo2({x: 'abc'});
44+
2645

2746
//// [0.js]
2847
// @ts-check
@@ -35,7 +54,9 @@ foo1({anotherX: "world"});
3554
*
3655
* @param {Opts} opts
3756
*/
38-
function foo(opts) { }
57+
function foo(opts) {
58+
opts.x;
59+
}
3960
foo({ x: 'abc' });
4061
/**
4162
* @typedef {Object} AnotherOpts
@@ -44,5 +65,20 @@ foo({ x: 'abc' });
4465
*
4566
* @param {AnotherOpts} opts
4667
*/
47-
function foo1(opts) { }
68+
function foo1(opts) {
69+
opts.anotherX;
70+
}
4871
foo1({ anotherX: "world" });
72+
/**
73+
* @typedef {object} Opts1
74+
* @property {string} x
75+
* @property {string=} y
76+
* @property {string} [z]
77+
* @property {string} [w="hi"]
78+
*
79+
* @param {Opts1} opts
80+
*/
81+
function foo2(opts) {
82+
opts.x;
83+
}
84+
foo2({ x: 'abc' });

tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@
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))
1925

2026
/**
2127
* @typedef {Object} AnotherOpts
@@ -24,11 +30,39 @@ foo({x: 'abc'});
2430
*
2531
* @param {AnotherOpts} opts
2632
*/
27-
function foo1(opts) {}
28-
>foo1 : Symbol(foo1, Decl(0.js, 12, 16))
29-
>opts : Symbol(opts, Decl(0.js, 21, 14))
33+
function foo1(opts) {
34+
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
35+
>opts : Symbol(opts, Decl(0.js, 23, 14))
36+
37+
opts.anotherX;
38+
>opts.anotherX : Symbol(anotherX, Decl(0.js, 18, 3))
39+
>opts : Symbol(opts, Decl(0.js, 23, 14))
40+
>anotherX : Symbol(anotherX, Decl(0.js, 18, 3))
41+
}
3042

3143
foo1({anotherX: "world"});
32-
>foo1 : Symbol(foo1, Decl(0.js, 12, 16))
33-
>anotherX : Symbol(anotherX, Decl(0.js, 23, 6))
44+
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
45+
>anotherX : Symbol(anotherX, Decl(0.js, 27, 6))
46+
47+
/**
48+
* @typedef {object} Opts1
49+
* @property {string} x
50+
* @property {string=} y
51+
* @property {string} [z]
52+
* @property {string} [w="hi"]
53+
*
54+
* @param {Opts1} opts
55+
*/
56+
function foo2(opts) {
57+
>foo2 : Symbol(foo2, Decl(0.js, 27, 26))
58+
>opts : Symbol(opts, Decl(0.js, 38, 14))
59+
60+
opts.x;
61+
>opts.x : Symbol(x, Decl(0.js, 31, 3))
62+
>opts : Symbol(opts, Decl(0.js, 38, 14))
63+
>x : Symbol(x, Decl(0.js, 31, 3))
64+
}
65+
foo2({x: 'abc'});
66+
>foo2 : Symbol(foo2, Decl(0.js, 27, 26))
67+
>x : Symbol(x, Decl(0.js, 41, 6))
3468

tests/baselines/reference/checkJsdocTypedefInParamTag1.types

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
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
@@ -27,14 +33,45 @@ foo({x: 'abc'});
2733
*
2834
* @param {AnotherOpts} opts
2935
*/
30-
function foo1(opts) {}
36+
function foo1(opts) {
3137
>foo1 : (opts: { anotherX: string; anotherY?: string; }) => void
3238
>opts : { anotherX: string; anotherY?: string; }
3339

40+
opts.anotherX;
41+
>opts.anotherX : string
42+
>opts : { anotherX: string; anotherY?: string; }
43+
>anotherX : string
44+
}
45+
3446
foo1({anotherX: "world"});
3547
>foo1({anotherX: "world"}) : void
3648
>foo1 : (opts: { anotherX: string; anotherY?: string; }) => void
3749
>{anotherX: "world"} : { anotherX: string; }
3850
>anotherX : string
3951
>"world" : "world"
4052

53+
/**
54+
* @typedef {object} Opts1
55+
* @property {string} x
56+
* @property {string=} y
57+
* @property {string} [z]
58+
* @property {string} [w="hi"]
59+
*
60+
* @param {Opts1} opts
61+
*/
62+
function foo2(opts) {
63+
>foo2 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
64+
>opts : { x: string; y?: string; z?: string; w?: string; }
65+
66+
opts.x;
67+
>opts.x : string
68+
>opts : { x: string; y?: string; z?: string; w?: string; }
69+
>x : string
70+
}
71+
foo2({x: 'abc'});
72+
>foo2({x: 'abc'}) : void
73+
>foo2 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
74+
>{x: 'abc'} : { x: string; }
75+
>x : string
76+
>'abc' : "abc"
77+

tests/baselines/reference/jsDocTypeTag2.js

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -431,28 +431,8 @@
431431
"kind": "space"
432432
},
433433
{
434-
"text": "(",
435-
"kind": "punctuation"
436-
},
437-
{
438-
"text": ")",
439-
"kind": "punctuation"
440-
},
441-
{
442-
"text": " ",
443-
"kind": "space"
444-
},
445-
{
446-
"text": "=>",
447-
"kind": "punctuation"
448-
},
449-
{
450-
"text": " ",
451-
"kind": "space"
452-
},
453-
{
454-
"text": "any",
455-
"kind": "keyword"
434+
"text": "Function",
435+
"kind": "localName"
456436
}
457437
],
458438
"documentation": [],

0 commit comments

Comments
 (0)