-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Always export typedefs #23723
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
Always export typedefs #23723
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
43d7b9a
Always export typedefs
sandersn ccc7d6f
Merge branch 'master' into js/always-export-typedefs
sandersn 539afc0
Post-bind typedef instead of pre-checking for commonjs
sandersn 777b5a0
Duplicate identifier errors
sandersn 0f797a1
Fix class type reference resolution+update baselines
sandersn f733b21
Move to a type-based check for duplicate identifiers
sandersn 6e29c5c
Merge branch 'master' into js/always-export-typedefs
sandersn 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
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
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
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
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,70 @@ | ||
=== tests/cases/conformance/jsdoc/commonjs.d.ts === | ||
declare var module: { exports: any}; | ||
>module : Symbol(module, Decl(commonjs.d.ts, 0, 11)) | ||
>exports : Symbol(exports, Decl(commonjs.d.ts, 0, 21)) | ||
|
||
=== tests/cases/conformance/jsdoc/mod1.js === | ||
/// <reference path="./commonjs.d.ts"/> | ||
/** @typedef {{ type: "a", x: 1 }} A */ | ||
/** @typedef {{ type: "b", y: 1 }} B */ | ||
/** @typedef {A | B} Both */ | ||
module.exports = C | ||
>module.exports : Symbol(exports, Decl(commonjs.d.ts, 0, 21)) | ||
>module : Symbol(export=, Decl(mod1.js, 0, 0)) | ||
>exports : Symbol(export=, Decl(mod1.js, 0, 0)) | ||
>C : Symbol(C, Decl(mod1.js, 4, 18)) | ||
|
||
function C() { | ||
>C : Symbol(C, Decl(mod1.js, 4, 18)) | ||
|
||
this.p = 1 | ||
>p : Symbol(C.p, Decl(mod1.js, 5, 14)) | ||
} | ||
|
||
=== tests/cases/conformance/jsdoc/mod2.js === | ||
/// <reference path="./commonjs.d.ts"/> | ||
/** @typedef {{ type: "a", x: 1 }} A */ | ||
/** @typedef {{ type: "b", y: 1 }} B */ | ||
/** @typedef {A | B} Both */ | ||
|
||
export function C() { | ||
>C : Symbol(C, Decl(mod2.js, 0, 0)) | ||
|
||
this.p = 1 | ||
>p : Symbol(C.p, Decl(mod2.js, 5, 21)) | ||
} | ||
|
||
=== tests/cases/conformance/jsdoc/mod3.js === | ||
/// <reference path="./commonjs.d.ts"/> | ||
/** @typedef {{ type: "a", x: 1 }} A */ | ||
/** @typedef {{ type: "b", y: 1 }} B */ | ||
/** @typedef {A | B} Both */ | ||
|
||
exports.C = function() { | ||
>exports.C : Symbol(C, Decl(mod3.js, 0, 0)) | ||
>exports : Symbol(C, Decl(mod3.js, 0, 0)) | ||
>C : Symbol(C, Decl(mod3.js, 0, 0)) | ||
|
||
this.p = 1 | ||
>p : Symbol(C.p, Decl(mod3.js, 5, 24)) | ||
} | ||
|
||
=== tests/cases/conformance/jsdoc/use.js === | ||
/** @type {import('./mod1').Both} */ | ||
var both1 = { type: 'a', x: 1 }; | ||
>both1 : Symbol(both1, Decl(use.js, 1, 3)) | ||
>type : Symbol(type, Decl(use.js, 1, 13)) | ||
>x : Symbol(x, Decl(use.js, 1, 24)) | ||
|
||
/** @type {import('./mod2').Both} */ | ||
var both2 = both1; | ||
>both2 : Symbol(both2, Decl(use.js, 3, 3)) | ||
>both1 : Symbol(both1, Decl(use.js, 1, 3)) | ||
|
||
/** @type {import('./mod3').Both} */ | ||
var both3 = both2; | ||
>both3 : Symbol(both3, Decl(use.js, 5, 3)) | ||
>both2 : Symbol(both2, Decl(use.js, 3, 3)) | ||
|
||
|
||
|
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,88 @@ | ||
=== tests/cases/conformance/jsdoc/commonjs.d.ts === | ||
declare var module: { exports: any}; | ||
>module : { exports: any; } | ||
>exports : any | ||
|
||
=== tests/cases/conformance/jsdoc/mod1.js === | ||
/// <reference path="./commonjs.d.ts"/> | ||
/** @typedef {{ type: "a", x: 1 }} A */ | ||
/** @typedef {{ type: "b", y: 1 }} B */ | ||
/** @typedef {A | B} Both */ | ||
module.exports = C | ||
>module.exports = C : typeof C | ||
>module.exports : any | ||
>module : { exports: any; } | ||
>exports : any | ||
>C : typeof C | ||
|
||
function C() { | ||
>C : typeof C | ||
|
||
this.p = 1 | ||
>this.p = 1 : 1 | ||
>this.p : any | ||
>this : any | ||
>p : any | ||
>1 : 1 | ||
} | ||
|
||
=== tests/cases/conformance/jsdoc/mod2.js === | ||
/// <reference path="./commonjs.d.ts"/> | ||
/** @typedef {{ type: "a", x: 1 }} A */ | ||
/** @typedef {{ type: "b", y: 1 }} B */ | ||
/** @typedef {A | B} Both */ | ||
|
||
export function C() { | ||
>C : typeof C | ||
|
||
this.p = 1 | ||
>this.p = 1 : 1 | ||
>this.p : any | ||
>this : any | ||
>p : any | ||
>1 : 1 | ||
} | ||
|
||
=== tests/cases/conformance/jsdoc/mod3.js === | ||
/// <reference path="./commonjs.d.ts"/> | ||
/** @typedef {{ type: "a", x: 1 }} A */ | ||
/** @typedef {{ type: "b", y: 1 }} B */ | ||
/** @typedef {A | B} Both */ | ||
|
||
exports.C = function() { | ||
>exports.C = function() { this.p = 1} : typeof C | ||
>exports.C : typeof C | ||
>exports : typeof import("tests/cases/conformance/jsdoc/mod3") | ||
>C : typeof C | ||
>function() { this.p = 1} : typeof C | ||
|
||
this.p = 1 | ||
>this.p = 1 : 1 | ||
>this.p : any | ||
>this : any | ||
>p : any | ||
>1 : 1 | ||
} | ||
|
||
=== tests/cases/conformance/jsdoc/use.js === | ||
/** @type {import('./mod1').Both} */ | ||
var both1 = { type: 'a', x: 1 }; | ||
>both1 : { type: "a"; x: 1; } | { type: "b"; y: 1; } | ||
>{ type: 'a', x: 1 } : { type: "a"; x: 1; } | ||
>type : "a" | ||
>'a' : "a" | ||
>x : 1 | ||
>1 : 1 | ||
|
||
/** @type {import('./mod2').Both} */ | ||
var both2 = both1; | ||
>both2 : { type: "a"; x: 1; } | { type: "b"; y: 1; } | ||
>both1 : { type: "a"; x: 1; } | ||
|
||
/** @type {import('./mod3').Both} */ | ||
var both3 = both2; | ||
>both3 : { type: "a"; x: 1; } | { type: "b"; y: 1; } | ||
>both2 : { type: "a"; x: 1; } | ||
|
||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure i understand why this is related ot the original change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that
typedef
s are exported, there's a possibility that their names collide, such that there is a difference betweenIn other words, the type reference
Foo
might refer to the typedef, whereas the value referenced innew Foo
might refer to the class. There should be an error to prevent this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see. thanks.