-
Notifications
You must be signed in to change notification settings - Fork 12.9k
fix(45233): export default can not be typed via jsdoc #45342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment1.errors.txt
This file contains hidden or 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/a.js(8,18): error TS2322: Type '{ c: boolean; }' is not assignable to type 'Foo'. | ||
Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. | ||
|
||
|
||
==== tests/cases/compiler/checkJsdocTypeTagOnExportAssignment1.js (0 errors) ==== | ||
|
||
==== tests/cases/compiler/a.js (1 errors) ==== | ||
/** | ||
* @typedef {Object} Foo | ||
* @property {boolean} a | ||
* @property {boolean} b | ||
*/ | ||
|
||
/** @type {Foo} */ | ||
export default { c: false }; | ||
~~~~~~~~ | ||
!!! error TS2322: Type '{ c: boolean; }' is not assignable to type 'Foo'. | ||
!!! error TS2322: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. | ||
|
||
==== tests/cases/compiler/b.js (0 errors) ==== | ||
import a from "./a"; | ||
a; | ||
|
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment1.js
This file contains hidden or 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,35 @@ | ||
//// [tests/cases/compiler/checkJsdocTypeTagOnExportAssignment1.ts] //// | ||
|
||
//// [checkJsdocTypeTagOnExportAssignment1.js] | ||
|
||
//// [a.js] | ||
/** | ||
* @typedef {Object} Foo | ||
* @property {boolean} a | ||
* @property {boolean} b | ||
*/ | ||
|
||
/** @type {Foo} */ | ||
export default { c: false }; | ||
|
||
//// [b.js] | ||
import a from "./a"; | ||
a; | ||
|
||
|
||
//// [checkJsdocTypeTagOnExportAssignment1.js] | ||
//// [a.js] | ||
"use strict"; | ||
/** | ||
* @typedef {Object} Foo | ||
* @property {boolean} a | ||
* @property {boolean} b | ||
*/ | ||
exports.__esModule = true; | ||
/** @type {Foo} */ | ||
exports["default"] = { c: false }; | ||
//// [b.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var a_1 = require("./a"); | ||
a_1["default"]; |
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment1.symbols
This file contains hidden or 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 @@ | ||
=== tests/cases/compiler/checkJsdocTypeTagOnExportAssignment1.js === | ||
|
||
No type information for this code.=== tests/cases/compiler/a.js === | ||
/** | ||
* @typedef {Object} Foo | ||
* @property {boolean} a | ||
* @property {boolean} b | ||
*/ | ||
|
||
/** @type {Foo} */ | ||
export default { c: false }; | ||
>c : Symbol(c, Decl(a.js, 7, 16)) | ||
|
||
=== tests/cases/compiler/b.js === | ||
import a from "./a"; | ||
>a : Symbol(a, Decl(b.js, 0, 6)) | ||
|
||
a; | ||
>a : Symbol(a, Decl(b.js, 0, 6)) | ||
|
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment1.types
This file contains hidden or 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,22 @@ | ||
=== tests/cases/compiler/checkJsdocTypeTagOnExportAssignment1.js === | ||
|
||
No type information for this code.=== tests/cases/compiler/a.js === | ||
/** | ||
* @typedef {Object} Foo | ||
* @property {boolean} a | ||
* @property {boolean} b | ||
*/ | ||
|
||
/** @type {Foo} */ | ||
export default { c: false }; | ||
>{ c: false } : { c: boolean; } | ||
>c : boolean | ||
>false : false | ||
|
||
=== tests/cases/compiler/b.js === | ||
import a from "./a"; | ||
>a : import("tests/cases/compiler/a").Foo | ||
|
||
a; | ||
>a : import("tests/cases/compiler/a").Foo | ||
|
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment2.errors.txt
This file contains hidden or 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/b.js(2,18): error TS2322: Type '{ c: boolean; }' is not assignable to type 'Foo'. | ||
Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. | ||
|
||
|
||
==== tests/cases/compiler/checkJsdocTypeTagOnExportAssignment2.js (0 errors) ==== | ||
|
||
==== tests/cases/compiler/a.ts (0 errors) ==== | ||
export interface Foo { | ||
a: number; | ||
b: number; | ||
} | ||
|
||
==== tests/cases/compiler/b.js (1 errors) ==== | ||
/** @type {import("./a").Foo} */ | ||
export default { c: false }; | ||
~~~~~~~~ | ||
!!! error TS2322: Type '{ c: boolean; }' is not assignable to type 'Foo'. | ||
!!! error TS2322: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'. | ||
|
||
==== tests/cases/compiler/c.js (0 errors) ==== | ||
import b from "./b"; | ||
b; | ||
|
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment2.js
This file contains hidden or 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,33 @@ | ||
//// [tests/cases/compiler/checkJsdocTypeTagOnExportAssignment2.ts] //// | ||
|
||
//// [checkJsdocTypeTagOnExportAssignment2.js] | ||
|
||
//// [a.ts] | ||
export interface Foo { | ||
a: number; | ||
b: number; | ||
} | ||
|
||
//// [b.js] | ||
/** @type {import("./a").Foo} */ | ||
export default { c: false }; | ||
|
||
//// [c.js] | ||
import b from "./b"; | ||
b; | ||
|
||
|
||
//// [checkJsdocTypeTagOnExportAssignment2.js] | ||
//// [a.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
//// [b.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
/** @type {import("./a").Foo} */ | ||
exports["default"] = { c: false }; | ||
//// [c.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var b_1 = require("./b"); | ||
b_1["default"]; |
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment2.symbols
This file contains hidden or 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,25 @@ | ||
=== tests/cases/compiler/checkJsdocTypeTagOnExportAssignment2.js === | ||
|
||
No type information for this code.=== tests/cases/compiler/a.ts === | ||
export interface Foo { | ||
>Foo : Symbol(Foo, Decl(a.ts, 0, 0)) | ||
|
||
a: number; | ||
>a : Symbol(Foo.a, Decl(a.ts, 0, 22)) | ||
|
||
b: number; | ||
>b : Symbol(Foo.b, Decl(a.ts, 1, 14)) | ||
} | ||
|
||
=== tests/cases/compiler/b.js === | ||
/** @type {import("./a").Foo} */ | ||
export default { c: false }; | ||
>c : Symbol(c, Decl(b.js, 1, 16)) | ||
|
||
=== tests/cases/compiler/c.js === | ||
import b from "./b"; | ||
>b : Symbol(b, Decl(c.js, 0, 6)) | ||
|
||
b; | ||
>b : Symbol(b, Decl(c.js, 0, 6)) | ||
|
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment2.types
This file contains hidden or 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,25 @@ | ||
=== tests/cases/compiler/checkJsdocTypeTagOnExportAssignment2.js === | ||
|
||
No type information for this code.=== tests/cases/compiler/a.ts === | ||
export interface Foo { | ||
a: number; | ||
>a : number | ||
|
||
b: number; | ||
>b : number | ||
} | ||
|
||
=== tests/cases/compiler/b.js === | ||
/** @type {import("./a").Foo} */ | ||
export default { c: false }; | ||
>{ c: false } : { c: boolean; } | ||
>c : boolean | ||
>false : false | ||
|
||
=== tests/cases/compiler/c.js === | ||
import b from "./b"; | ||
>b : import("tests/cases/compiler/a").Foo | ||
|
||
b; | ||
>b : import("tests/cases/compiler/a").Foo | ||
|
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment3.errors.txt
This file contains hidden or 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/a.js(10,16): error TS2739: Type '{ c: number; }' is missing the following properties from type 'Foo': a, b | ||
|
||
|
||
==== tests/cases/compiler/checkJsdocTypeTagOnExportAssignment3.js (0 errors) ==== | ||
|
||
==== tests/cases/compiler/a.js (1 errors) ==== | ||
/** | ||
* @typedef {Object} Foo | ||
* @property {boolean} a | ||
* @property {boolean} b | ||
*/ | ||
|
||
const bar = { c: 1 }; | ||
|
||
/** @type {Foo} */ | ||
export default bar; | ||
~~~ | ||
!!! error TS2739: Type '{ c: number; }' is missing the following properties from type 'Foo': a, b | ||
|
||
==== tests/cases/compiler/b.js (0 errors) ==== | ||
import a from "./a"; | ||
a; | ||
|
38 changes: 38 additions & 0 deletions
38
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment3.js
This file contains hidden or 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,38 @@ | ||
//// [tests/cases/compiler/checkJsdocTypeTagOnExportAssignment3.ts] //// | ||
|
||
//// [checkJsdocTypeTagOnExportAssignment3.js] | ||
|
||
//// [a.js] | ||
/** | ||
* @typedef {Object} Foo | ||
* @property {boolean} a | ||
* @property {boolean} b | ||
*/ | ||
|
||
const bar = { c: 1 }; | ||
|
||
/** @type {Foo} */ | ||
export default bar; | ||
|
||
//// [b.js] | ||
import a from "./a"; | ||
a; | ||
|
||
|
||
//// [checkJsdocTypeTagOnExportAssignment3.js] | ||
//// [a.js] | ||
"use strict"; | ||
/** | ||
* @typedef {Object} Foo | ||
* @property {boolean} a | ||
* @property {boolean} b | ||
*/ | ||
exports.__esModule = true; | ||
var bar = { c: 1 }; | ||
/** @type {Foo} */ | ||
exports["default"] = bar; | ||
//// [b.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var a_1 = require("./a"); | ||
a_1["default"]; |
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment3.symbols
This file contains hidden or 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,24 @@ | ||
=== tests/cases/compiler/checkJsdocTypeTagOnExportAssignment3.js === | ||
|
||
No type information for this code.=== tests/cases/compiler/a.js === | ||
/** | ||
* @typedef {Object} Foo | ||
* @property {boolean} a | ||
* @property {boolean} b | ||
*/ | ||
|
||
const bar = { c: 1 }; | ||
>bar : Symbol(bar, Decl(a.js, 6, 5)) | ||
>c : Symbol(c, Decl(a.js, 6, 13)) | ||
|
||
/** @type {Foo} */ | ||
export default bar; | ||
>bar : Symbol(bar, Decl(a.js, 6, 5)) | ||
|
||
=== tests/cases/compiler/b.js === | ||
import a from "./a"; | ||
>a : Symbol(a, Decl(b.js, 0, 6)) | ||
|
||
a; | ||
>a : Symbol(a, Decl(b.js, 0, 6)) | ||
|
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment3.types
This file contains hidden or 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 @@ | ||
=== tests/cases/compiler/checkJsdocTypeTagOnExportAssignment3.js === | ||
|
||
No type information for this code.=== tests/cases/compiler/a.js === | ||
/** | ||
* @typedef {Object} Foo | ||
* @property {boolean} a | ||
* @property {boolean} b | ||
*/ | ||
|
||
const bar = { c: 1 }; | ||
>bar : { c: number; } | ||
>{ c: 1 } : { c: number; } | ||
>c : number | ||
>1 : 1 | ||
|
||
/** @type {Foo} */ | ||
export default bar; | ||
>bar : { c: number; } | ||
|
||
=== tests/cases/compiler/b.js === | ||
import a from "./a"; | ||
>a : import("tests/cases/compiler/a").Foo | ||
|
||
a; | ||
>a : import("tests/cases/compiler/a").Foo | ||
|
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/checkJsdocTypeTagOnExportAssignment4.errors.txt
This file contains hidden or 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,16 @@ | ||
tests/cases/compiler/a.js(6,16): error TS2322: Type 'string' is not assignable to type 'number'. | ||
|
||
|
||
==== tests/cases/compiler/checkJsdocTypeTagOnExportAssignment4.js (0 errors) ==== | ||
|
||
==== tests/cases/compiler/a.js (1 errors) ==== | ||
/** | ||
* @typedef {number} Foo | ||
*/ | ||
|
||
/** @type {Foo} */ | ||
export default ""; | ||
~~ | ||
!!! error TS2322: Type 'string' is not assignable to type 'number'. | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.