-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16178 from Microsoft/master-fix13306
- Loading branch information
Showing
9 changed files
with
387 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//// [0.js] | ||
// @ts-check | ||
var lol = "hello Lol" | ||
const obj = { | ||
/** @type {string|undefined} */ | ||
foo: undefined, | ||
/** @type {string|undefined} */ | ||
bar: "42", | ||
/** @type {function(number): number} */ | ||
method1(n1) { | ||
return n1 + 42; | ||
}, | ||
/** @type {string} */ | ||
lol, | ||
/** @type {number} */ | ||
['b' + 'ar1']: 42, | ||
/** @type {function(number): number} */ | ||
arrowFunc: (num) => num + 42 | ||
} | ||
obj.foo = 'string' | ||
obj.lol | ||
obj.bar = undefined; | ||
var k = obj.method1(0); | ||
obj.bar1 = "42"; | ||
obj.arrowFunc(0); | ||
|
||
//// [0.js] | ||
// @ts-check | ||
var lol = "hello Lol"; | ||
var obj = (_a = { | ||
/** @type {string|undefined} */ | ||
foo: undefined, | ||
/** @type {string|undefined} */ | ||
bar: "42", | ||
/** @type {function(number): number} */ | ||
method1: function (n1) { | ||
return n1 + 42; | ||
}, | ||
/** @type {string} */ | ||
lol: lol | ||
}, | ||
/** @type {number} */ | ||
_a['b' + 'ar1'] = 42, | ||
/** @type {function(number): number} */ | ||
_a.arrowFunc = function (num) { return num + 42; }, | ||
_a); | ||
obj.foo = 'string'; | ||
obj.lol; | ||
obj.bar = undefined; | ||
var k = obj.method1(0); | ||
obj.bar1 = "42"; | ||
obj.arrowFunc(0); | ||
var _a; |
68 changes: 68 additions & 0 deletions
68
tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
=== tests/cases/conformance/jsdoc/0.js === | ||
// @ts-check | ||
var lol = "hello Lol" | ||
>lol : Symbol(lol, Decl(0.js, 1, 3)) | ||
|
||
const obj = { | ||
>obj : Symbol(obj, Decl(0.js, 2, 5)) | ||
|
||
/** @type {string|undefined} */ | ||
foo: undefined, | ||
>foo : Symbol(foo, Decl(0.js, 2, 13)) | ||
>undefined : Symbol(undefined) | ||
|
||
/** @type {string|undefined} */ | ||
bar: "42", | ||
>bar : Symbol(bar, Decl(0.js, 4, 17)) | ||
|
||
/** @type {function(number): number} */ | ||
method1(n1) { | ||
>method1 : Symbol(method1, Decl(0.js, 6, 12)) | ||
>n1 : Symbol(n1, Decl(0.js, 8, 10)) | ||
|
||
return n1 + 42; | ||
>n1 : Symbol(n1, Decl(0.js, 8, 10)) | ||
|
||
}, | ||
/** @type {string} */ | ||
lol, | ||
>lol : Symbol(lol, Decl(0.js, 10, 4)) | ||
|
||
/** @type {number} */ | ||
['b' + 'ar1']: 42, | ||
/** @type {function(number): number} */ | ||
arrowFunc: (num) => num + 42 | ||
>arrowFunc : Symbol(arrowFunc, Decl(0.js, 14, 20)) | ||
>num : Symbol(num, Decl(0.js, 16, 14)) | ||
>num : Symbol(num, Decl(0.js, 16, 14)) | ||
} | ||
obj.foo = 'string' | ||
>obj.foo : Symbol(foo, Decl(0.js, 2, 13)) | ||
>obj : Symbol(obj, Decl(0.js, 2, 5)) | ||
>foo : Symbol(foo, Decl(0.js, 2, 13)) | ||
|
||
obj.lol | ||
>obj.lol : Symbol(lol, Decl(0.js, 10, 4)) | ||
>obj : Symbol(obj, Decl(0.js, 2, 5)) | ||
>lol : Symbol(lol, Decl(0.js, 10, 4)) | ||
|
||
obj.bar = undefined; | ||
>obj.bar : Symbol(bar, Decl(0.js, 4, 17)) | ||
>obj : Symbol(obj, Decl(0.js, 2, 5)) | ||
>bar : Symbol(bar, Decl(0.js, 4, 17)) | ||
>undefined : Symbol(undefined) | ||
|
||
var k = obj.method1(0); | ||
>k : Symbol(k, Decl(0.js, 21, 3)) | ||
>obj.method1 : Symbol(method1, Decl(0.js, 6, 12)) | ||
>obj : Symbol(obj, Decl(0.js, 2, 5)) | ||
>method1 : Symbol(method1, Decl(0.js, 6, 12)) | ||
|
||
obj.bar1 = "42"; | ||
>obj : Symbol(obj, Decl(0.js, 2, 5)) | ||
|
||
obj.arrowFunc(0); | ||
>obj.arrowFunc : Symbol(arrowFunc, Decl(0.js, 14, 20)) | ||
>obj : Symbol(obj, Decl(0.js, 2, 5)) | ||
>arrowFunc : Symbol(arrowFunc, Decl(0.js, 14, 20)) | ||
|
92 changes: 92 additions & 0 deletions
92
tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
=== tests/cases/conformance/jsdoc/0.js === | ||
// @ts-check | ||
var lol = "hello Lol" | ||
>lol : string | ||
>"hello Lol" : "hello Lol" | ||
|
||
const obj = { | ||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } | ||
>{ /** @type {string|undefined} */ foo: undefined, /** @type {string|undefined} */ bar: "42", /** @type {function(number): number} */ method1(n1) { return n1 + 42; }, /** @type {string} */ lol, /** @type {number} */ ['b' + 'ar1']: 42, /** @type {function(number): number} */ arrowFunc: (num) => num + 42} : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } | ||
|
||
/** @type {string|undefined} */ | ||
foo: undefined, | ||
>foo : string | undefined | ||
>undefined : undefined | ||
|
||
/** @type {string|undefined} */ | ||
bar: "42", | ||
>bar : string | undefined | ||
>"42" : "42" | ||
|
||
/** @type {function(number): number} */ | ||
method1(n1) { | ||
>method1 : (n1: any) => any | ||
>n1 : any | ||
|
||
return n1 + 42; | ||
>n1 + 42 : any | ||
>n1 : any | ||
>42 : 42 | ||
|
||
}, | ||
/** @type {string} */ | ||
lol, | ||
>lol : string | ||
|
||
/** @type {number} */ | ||
['b' + 'ar1']: 42, | ||
>'b' + 'ar1' : string | ||
>'b' : "b" | ||
>'ar1' : "ar1" | ||
>42 : 42 | ||
|
||
/** @type {function(number): number} */ | ||
arrowFunc: (num) => num + 42 | ||
>arrowFunc : (arg0: number) => number | ||
>(num) => num + 42 : (num: any) => any | ||
>num : any | ||
>num + 42 : any | ||
>num : any | ||
>42 : 42 | ||
} | ||
obj.foo = 'string' | ||
>obj.foo = 'string' : "string" | ||
>obj.foo : string | undefined | ||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } | ||
>foo : string | undefined | ||
>'string' : "string" | ||
|
||
obj.lol | ||
>obj.lol : string | ||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } | ||
>lol : string | ||
|
||
obj.bar = undefined; | ||
>obj.bar = undefined : undefined | ||
>obj.bar : string | undefined | ||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } | ||
>bar : string | undefined | ||
>undefined : undefined | ||
|
||
var k = obj.method1(0); | ||
>k : number | ||
>obj.method1(0) : number | ||
>obj.method1 : (arg0: number) => number | ||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } | ||
>method1 : (arg0: number) => number | ||
>0 : 0 | ||
|
||
obj.bar1 = "42"; | ||
>obj.bar1 = "42" : "42" | ||
>obj.bar1 : any | ||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } | ||
>bar1 : any | ||
>"42" : "42" | ||
|
||
obj.arrowFunc(0); | ||
>obj.arrowFunc(0) : number | ||
>obj.arrowFunc : (arg0: number) => number | ||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } | ||
>arrowFunc : (arg0: number) => number | ||
>0 : 0 | ||
|
54 changes: 54 additions & 0 deletions
54
tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
tests/cases/conformance/jsdoc/0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string | undefined'. | ||
tests/cases/conformance/jsdoc/0.js(7,3): error TS2322: Type '(n1: any) => string' is not assignable to type '(arg0: number) => number'. | ||
Type 'string' is not assignable to type 'number'. | ||
tests/cases/conformance/jsdoc/0.js(11,3): error TS2322: Type '(n1: any) => string' is not assignable to type '(arg0: number) => number'. | ||
Type 'string' is not assignable to type 'number'. | ||
tests/cases/conformance/jsdoc/0.js(13,3): error TS2322: Type '(num?: string) => string' is not assignable to type '(arg0: number) => number'. | ||
Types of parameters 'num' and 'arg0' are incompatible. | ||
Type 'number' is not assignable to type 'string | undefined'. | ||
tests/cases/conformance/jsdoc/0.js(15,3): error TS2322: Type 'undefined' is not assignable to type 'string'. | ||
tests/cases/conformance/jsdoc/0.js(19,5): error TS2322: Type 'number' is not assignable to type 'string'. | ||
tests/cases/conformance/jsdoc/0.js(22,22): error TS2345: Argument of type '"0"' is not assignable to parameter of type 'number'. | ||
|
||
|
||
==== tests/cases/conformance/jsdoc/0.js (7 errors) ==== | ||
// @ts-check | ||
var lol; | ||
const obj = { | ||
/** @type {string|undefined} */ | ||
bar: 42, | ||
~~~~~~~ | ||
!!! error TS2322: Type 'number' is not assignable to type 'string | undefined'. | ||
/** @type {function(number): number} */ | ||
method1(n1) { | ||
~~~~~~~ | ||
!!! error TS2322: Type '(n1: any) => string' is not assignable to type '(arg0: number) => number'. | ||
!!! error TS2322: Type 'string' is not assignable to type 'number'. | ||
return "42"; | ||
}, | ||
/** @type {function(number): number} */ | ||
method2: (n1) => "lol", | ||
~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2322: Type '(n1: any) => string' is not assignable to type '(arg0: number) => number'. | ||
!!! error TS2322: Type 'string' is not assignable to type 'number'. | ||
/** @type {function(number): number} */ | ||
arrowFunc: (num="0") => num + 42, | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2322: Type '(num?: string) => string' is not assignable to type '(arg0: number) => number'. | ||
!!! error TS2322: Types of parameters 'num' and 'arg0' are incompatible. | ||
!!! error TS2322: Type 'number' is not assignable to type 'string | undefined'. | ||
/** @type {string} */ | ||
lol | ||
~~~ | ||
!!! error TS2322: Type 'undefined' is not assignable to type 'string'. | ||
} | ||
lol = "string" | ||
/** @type {string} */ | ||
var s = obj.method1(0); | ||
~ | ||
!!! error TS2322: Type 'number' is not assignable to type 'string'. | ||
|
||
/** @type {string} */ | ||
var s1 = obj.method2("0"); | ||
~~~ | ||
!!! error TS2345: Argument of type '"0"' is not assignable to parameter of type 'number'. |
49 changes: 49 additions & 0 deletions
49
tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//// [0.js] | ||
// @ts-check | ||
var lol; | ||
const obj = { | ||
/** @type {string|undefined} */ | ||
bar: 42, | ||
/** @type {function(number): number} */ | ||
method1(n1) { | ||
return "42"; | ||
}, | ||
/** @type {function(number): number} */ | ||
method2: (n1) => "lol", | ||
/** @type {function(number): number} */ | ||
arrowFunc: (num="0") => num + 42, | ||
/** @type {string} */ | ||
lol | ||
} | ||
lol = "string" | ||
/** @type {string} */ | ||
var s = obj.method1(0); | ||
|
||
/** @type {string} */ | ||
var s1 = obj.method2("0"); | ||
|
||
//// [0.js] | ||
// @ts-check | ||
var lol; | ||
var obj = { | ||
/** @type {string|undefined} */ | ||
bar: 42, | ||
/** @type {function(number): number} */ | ||
method1: function (n1) { | ||
return "42"; | ||
}, | ||
/** @type {function(number): number} */ | ||
method2: function (n1) { return "lol"; }, | ||
/** @type {function(number): number} */ | ||
arrowFunc: function (num) { | ||
if (num === void 0) { num = "0"; } | ||
return num + 42; | ||
}, | ||
/** @type {string} */ | ||
lol: lol | ||
}; | ||
lol = "string"; | ||
/** @type {string} */ | ||
var s = obj.method1(0); | ||
/** @type {string} */ | ||
var s1 = obj.method2("0"); |
Oops, something went wrong.