-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
190 additions
and
8 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
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
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/arrowExpressionBodyJSDoc.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,26 @@ | ||
mytest.js(6,44): error TS2322: Type 'string' is not assignable to type 'T'. | ||
'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. | ||
mytest.js(13,44): error TS2322: Type 'string' is not assignable to type 'T'. | ||
'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. | ||
|
||
|
||
==== mytest.js (2 errors) ==== | ||
/** | ||
* @template T | ||
* @param {T|undefined} value value or not | ||
* @returns {T} result value | ||
*/ | ||
const foo1 = value => /** @type {string} */({ ...value }); | ||
~~~~~~~~~~~~~~ | ||
!!! error TS2322: Type 'string' is not assignable to type 'T'. | ||
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. | ||
|
||
/** | ||
* @template T | ||
* @param {T|undefined} value value or not | ||
* @returns {T} result value | ||
*/ | ||
const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2322: Type 'string' is not assignable to type 'T'. | ||
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'string'. |
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/arrowExpressionBodyJSDoc.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,23 @@ | ||
//// [tests/cases/compiler/arrowExpressionBodyJSDoc.ts] //// | ||
|
||
=== mytest.js === | ||
/** | ||
* @template T | ||
* @param {T|undefined} value value or not | ||
* @returns {T} result value | ||
*/ | ||
const foo1 = value => /** @type {string} */({ ...value }); | ||
>foo1 : Symbol(foo1, Decl(mytest.js, 5, 5)) | ||
>value : Symbol(value, Decl(mytest.js, 5, 12)) | ||
>value : Symbol(value, Decl(mytest.js, 5, 12)) | ||
|
||
/** | ||
* @template T | ||
* @param {T|undefined} value value or not | ||
* @returns {T} result value | ||
*/ | ||
const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); | ||
>foo2 : Symbol(foo2, Decl(mytest.js, 12, 5)) | ||
>value : Symbol(value, Decl(mytest.js, 12, 12)) | ||
>value : Symbol(value, Decl(mytest.js, 12, 12)) | ||
|
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,43 @@ | ||
//// [tests/cases/compiler/arrowExpressionBodyJSDoc.ts] //// | ||
|
||
=== mytest.js === | ||
/** | ||
* @template T | ||
* @param {T|undefined} value value or not | ||
* @returns {T} result value | ||
*/ | ||
const foo1 = value => /** @type {string} */({ ...value }); | ||
>foo1 : <T>(value: T | undefined) => T | ||
> : ^ ^^ ^^ ^^^^^ | ||
>value => /** @type {string} */({ ...value }) : <T>(value: T | undefined) => T | ||
> : ^ ^^ ^^ ^^^^^ | ||
>value : T | undefined | ||
> : ^^^^^^^^^^^^^ | ||
>({ ...value }) : string | ||
> : ^^^^^^ | ||
>{ ...value } : {} | ||
> : ^^ | ||
>value : T | undefined | ||
> : ^^^^^^^^^^^^^ | ||
|
||
/** | ||
* @template T | ||
* @param {T|undefined} value value or not | ||
* @returns {T} result value | ||
*/ | ||
const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); | ||
>foo2 : <T>(value: T | undefined) => T | ||
> : ^ ^^ ^^ ^^^^^ | ||
>value => /** @type {string} */(/** @type {T} */({ ...value })) : <T>(value: T | undefined) => T | ||
> : ^ ^^ ^^ ^^^^^ | ||
>value : T | undefined | ||
> : ^^^^^^^^^^^^^ | ||
>(/** @type {T} */({ ...value })) : string | ||
> : ^^^^^^ | ||
>({ ...value }) : T | ||
> : ^ | ||
>{ ...value } : {} | ||
> : ^^ | ||
>value : T | undefined | ||
> : ^^^^^^^^^^^^^ | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
// @checkJs: true | ||
// @allowJs: true | ||
|
||
// @filename: mytest.js | ||
|
||
/** | ||
* @template T | ||
* @param {T|undefined} value value or not | ||
* @returns {T} result value | ||
*/ | ||
const foo1 = value => /** @type {string} */({ ...value }); | ||
|
||
/** | ||
* @template T | ||
* @param {T|undefined} value value or not | ||
* @returns {T} result value | ||
*/ | ||
const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); |
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