-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Fix cross-file merge of assignment decl valueDeclaration #26918
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 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e948e6e
Fix cross-file merge of assignment decl valueDeclaration
sandersn a279c61
Merge branch 'master' into fix-assignment-decl-cross-file-merge
sandersn a669d97
Update baselines
sandersn cb9fefe
Add a fix for #27099
sandersn a6d77fa
Add a separate jsGlobalAugmentations table
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
11 changes: 11 additions & 0 deletions
11
tests/baselines/reference/globalMergeWithCommonJSAssignmentDeclaration.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,11 @@ | ||
tests/cases/conformance/salsa/bug27099.js(1,1): error TS2322: Type '1' is not assignable to type 'string'. | ||
|
||
|
||
==== tests/cases/conformance/salsa/bug27099.js (1 errors) ==== | ||
window.name = 1; | ||
~~~~~~~~~~~ | ||
!!! error TS2322: Type '1' is not assignable to type 'string'. | ||
window.console; // should not have error: Property 'console' does not exist on type 'typeof window'. | ||
module.exports = 'anything'; | ||
|
||
|
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/globalMergeWithCommonJSAssignmentDeclaration.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,17 @@ | ||
=== tests/cases/conformance/salsa/bug27099.js === | ||
window.name = 1; | ||
>window.name : Symbol(Window.name, Decl(lib.dom.d.ts, --, --)) | ||
>window : Symbol(window, Decl(bug27099.js, 0, 0)) | ||
>name : Symbol(Window.name, Decl(lib.dom.d.ts, --, --)) | ||
|
||
window.console; // should not have error: Property 'console' does not exist on type 'typeof window'. | ||
>window.console : Symbol(WindowConsole.console, Decl(lib.dom.d.ts, --, --)) | ||
>window : Symbol(window, Decl(bug27099.js, 0, 0)) | ||
>console : Symbol(WindowConsole.console, Decl(lib.dom.d.ts, --, --)) | ||
|
||
module.exports = 'anything'; | ||
>module.exports : Symbol("tests/cases/conformance/salsa/bug27099", Decl(bug27099.js, 0, 0)) | ||
>module : Symbol(export=, Decl(bug27099.js, 1, 15)) | ||
>exports : Symbol(export=, Decl(bug27099.js, 1, 15)) | ||
|
||
|
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/globalMergeWithCommonJSAssignmentDeclaration.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,21 @@ | ||
=== tests/cases/conformance/salsa/bug27099.js === | ||
window.name = 1; | ||
>window.name = 1 : 1 | ||
>window.name : string | ||
>window : Window | ||
>name : string | ||
>1 : 1 | ||
|
||
window.console; // should not have error: Property 'console' does not exist on type 'typeof window'. | ||
>window.console : Console | ||
>window : Window | ||
>console : Console | ||
|
||
module.exports = 'anything'; | ||
>module.exports = 'anything' : string | ||
>module.exports : string | ||
>module : { "tests/cases/conformance/salsa/bug27099": string; } | ||
>exports : string | ||
>'anything' : "anything" | ||
|
||
|
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
51 changes: 51 additions & 0 deletions
51
tests/baselines/reference/typeFromPropertyAssignment35.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,51 @@ | ||
=== tests/cases/conformance/salsa/bug26877.js === | ||
/** @param {Emu.D} x */ | ||
function ollKorrect(x) { | ||
>ollKorrect : Symbol(ollKorrect, Decl(bug26877.js, 0, 0)) | ||
>x : Symbol(x, Decl(bug26877.js, 1, 20)) | ||
|
||
x._model | ||
>x._model : Symbol(D._model, Decl(bug26877.js, 7, 19)) | ||
>x : Symbol(x, Decl(bug26877.js, 1, 20)) | ||
>_model : Symbol(D._model, Decl(bug26877.js, 7, 19)) | ||
|
||
const y = new Emu.D() | ||
>y : Symbol(y, Decl(bug26877.js, 3, 9)) | ||
>Emu.D : Symbol(Emu.D, Decl(bug26877.js, 5, 1), Decl(second.js, 2, 4)) | ||
>Emu : Symbol(Emu, Decl(bug26877.js, 5, 1), Decl(second.js, 0, 3), Decl(second.js, 0, 12)) | ||
>D : Symbol(Emu.D, Decl(bug26877.js, 5, 1), Decl(second.js, 2, 4)) | ||
|
||
const z = Emu.D._wrapperInstance; | ||
>z : Symbol(z, Decl(bug26877.js, 4, 9)) | ||
>Emu.D._wrapperInstance : Symbol(Emu.D._wrapperInstance, Decl(second.js, 0, 12)) | ||
>Emu.D : Symbol(Emu.D, Decl(bug26877.js, 5, 1), Decl(second.js, 2, 4)) | ||
>Emu : Symbol(Emu, Decl(bug26877.js, 5, 1), Decl(second.js, 0, 3), Decl(second.js, 0, 12)) | ||
>D : Symbol(Emu.D, Decl(bug26877.js, 5, 1), Decl(second.js, 2, 4)) | ||
>_wrapperInstance : Symbol(Emu.D._wrapperInstance, Decl(second.js, 0, 12)) | ||
} | ||
Emu.D = class { | ||
>Emu.D : Symbol(Emu.D, Decl(bug26877.js, 5, 1), Decl(second.js, 2, 4)) | ||
>Emu : Symbol(Emu, Decl(bug26877.js, 5, 1), Decl(second.js, 0, 3), Decl(second.js, 0, 12)) | ||
>D : Symbol(Emu.D, Decl(bug26877.js, 5, 1), Decl(second.js, 2, 4)) | ||
|
||
constructor() { | ||
this._model = 1 | ||
>this._model : Symbol(D._model, Decl(bug26877.js, 7, 19)) | ||
>this : Symbol(D, Decl(bug26877.js, 6, 7)) | ||
>_model : Symbol(D._model, Decl(bug26877.js, 7, 19)) | ||
} | ||
} | ||
|
||
=== tests/cases/conformance/salsa/second.js === | ||
var Emu = {} | ||
>Emu : Symbol(Emu, Decl(bug26877.js, 5, 1), Decl(second.js, 0, 3), Decl(second.js, 0, 12)) | ||
|
||
/** @type {string} */ | ||
Emu.D._wrapperInstance; | ||
>Emu.D._wrapperInstance : Symbol(Emu.D._wrapperInstance, Decl(second.js, 0, 12)) | ||
>Emu.D : Symbol(Emu.D, Decl(bug26877.js, 5, 1), Decl(second.js, 2, 4)) | ||
>Emu : Symbol(Emu, Decl(bug26877.js, 5, 1), Decl(second.js, 0, 3), Decl(second.js, 0, 12)) | ||
>D : Symbol(Emu.D, Decl(bug26877.js, 5, 1), Decl(second.js, 2, 4)) | ||
>_wrapperInstance : Symbol(Emu.D._wrapperInstance, Decl(second.js, 0, 12)) | ||
|
||
|
57 changes: 57 additions & 0 deletions
57
tests/baselines/reference/typeFromPropertyAssignment35.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,57 @@ | ||
=== tests/cases/conformance/salsa/bug26877.js === | ||
/** @param {Emu.D} x */ | ||
function ollKorrect(x) { | ||
>ollKorrect : (x: D) => void | ||
>x : D | ||
|
||
x._model | ||
>x._model : number | ||
>x : D | ||
>_model : number | ||
|
||
const y = new Emu.D() | ||
>y : D | ||
>new Emu.D() : D | ||
>Emu.D : typeof D | ||
>Emu : typeof Emu | ||
>D : typeof D | ||
|
||
const z = Emu.D._wrapperInstance; | ||
>z : string | ||
>Emu.D._wrapperInstance : string | ||
>Emu.D : typeof D | ||
>Emu : typeof Emu | ||
>D : typeof D | ||
>_wrapperInstance : string | ||
} | ||
Emu.D = class { | ||
>Emu.D = class { constructor() { this._model = 1 }} : typeof D | ||
>Emu.D : typeof D | ||
>Emu : typeof Emu | ||
>D : typeof D | ||
>class { constructor() { this._model = 1 }} : typeof D | ||
|
||
constructor() { | ||
this._model = 1 | ||
>this._model = 1 : 1 | ||
>this._model : number | ||
>this : this | ||
>_model : number | ||
>1 : 1 | ||
} | ||
} | ||
|
||
=== tests/cases/conformance/salsa/second.js === | ||
var Emu = {} | ||
>Emu : typeof Emu | ||
>{} : {} | ||
|
||
/** @type {string} */ | ||
Emu.D._wrapperInstance; | ||
>Emu.D._wrapperInstance : string | ||
>Emu.D : typeof D | ||
>Emu : typeof Emu | ||
>D : typeof D | ||
>_wrapperInstance : string | ||
|
||
|
8 changes: 8 additions & 0 deletions
8
tests/cases/conformance/salsa/globalMergeWithCommonJSAssignmentDeclaration.ts
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,8 @@ | ||
// @noEmit: true | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @Filename: bug27099.js | ||
window.name = 1; | ||
window.console; // should not have error: Property 'console' does not exist on type 'typeof window'. | ||
module.exports = 'anything'; | ||
|
22 changes: 22 additions & 0 deletions
22
tests/cases/conformance/salsa/typeFromPropertyAssignment35.ts
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 @@ | ||
// @noEmit: true | ||
// @allowJs: true | ||
// @checkJs: true | ||
|
||
// @Filename: bug26877.js | ||
/** @param {Emu.D} x */ | ||
function ollKorrect(x) { | ||
x._model | ||
const y = new Emu.D() | ||
const z = Emu.D._wrapperInstance; | ||
} | ||
Emu.D = class { | ||
constructor() { | ||
this._model = 1 | ||
} | ||
} | ||
|
||
// @Filename: second.js | ||
var Emu = {} | ||
/** @type {string} */ | ||
Emu.D._wrapperInstance; | ||
|
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.
Talking with @weswigham, he pointed out that it would be better to store all the identifier-unbound declarations in a separate per-file commonJSGlobalAugmentations property that gets merged into globals instead of trying to filter here (there are plenty of symbols marked with Assignment that shouldn't necessarily merge with globals).