-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix non-toplevel prototype assignment #27096
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
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
47 changes: 47 additions & 0 deletions
47
tests/baselines/reference/typeFromPrototypeAssignment2.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,47 @@ | ||
tests/cases/conformance/salsa/a.js(28,24): error TS2339: Property 'addon' does not exist on type '{ set: () => void; get(): void; }'. | ||
|
||
|
||
==== tests/cases/conformance/salsa/a.js (1 errors) ==== | ||
// non top-level: | ||
// all references to _map, set, get, addon should be ok | ||
(function container() { | ||
/** @constructor */ | ||
var Multimap = function() { | ||
this._map = {}; | ||
this._map | ||
this.set | ||
this.get | ||
this.addon | ||
}; | ||
|
||
Multimap.prototype = { | ||
set: function() { | ||
this._map | ||
this.set | ||
this.get | ||
this.addon | ||
}, | ||
get() { | ||
this._map | ||
this.set | ||
this.get | ||
this.addon | ||
} | ||
} | ||
|
||
Multimap.prototype.addon = function () { | ||
~~~~~ | ||
!!! error TS2339: Property 'addon' does not exist on type '{ set: () => void; get(): void; }'. | ||
this._map | ||
this.set | ||
this.get | ||
this.addon | ||
} | ||
|
||
var mm = new Multimap(); | ||
mm._map | ||
mm.set | ||
mm.get | ||
mm.addon | ||
}); | ||
|
127 changes: 127 additions & 0 deletions
127
tests/baselines/reference/typeFromPrototypeAssignment2.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,127 @@ | ||
=== tests/cases/conformance/salsa/a.js === | ||
// non top-level: | ||
// all references to _map, set, get, addon should be ok | ||
(function container() { | ||
>container : Symbol(container, Decl(a.js, 2, 1)) | ||
|
||
/** @constructor */ | ||
var Multimap = function() { | ||
>Multimap : Symbol(Multimap, Decl(a.js, 4, 7)) | ||
|
||
this._map = {}; | ||
>this._map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
>_map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
|
||
this._map | ||
>this._map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
>_map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
|
||
this.set | ||
>this.set : Symbol(set, Decl(a.js, 12, 26)) | ||
>set : Symbol(set, Decl(a.js, 12, 26)) | ||
|
||
this.get | ||
>this.get : Symbol(get, Decl(a.js, 18, 10)) | ||
>get : Symbol(get, Decl(a.js, 18, 10)) | ||
|
||
this.addon | ||
>this.addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
>addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
|
||
}; | ||
|
||
Multimap.prototype = { | ||
>Multimap.prototype : Symbol(Multimap.prototype, Decl(a.js, 10, 6)) | ||
>Multimap : Symbol(Multimap, Decl(a.js, 4, 7)) | ||
>prototype : Symbol(Multimap.prototype, Decl(a.js, 10, 6)) | ||
|
||
set: function() { | ||
>set : Symbol(set, Decl(a.js, 12, 26)) | ||
|
||
this._map | ||
>this._map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
>_map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
|
||
this.set | ||
>this.set : Symbol(set, Decl(a.js, 12, 26)) | ||
>set : Symbol(set, Decl(a.js, 12, 26)) | ||
|
||
this.get | ||
>this.get : Symbol(get, Decl(a.js, 18, 10)) | ||
>get : Symbol(get, Decl(a.js, 18, 10)) | ||
|
||
this.addon | ||
>this.addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
>addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
|
||
}, | ||
get() { | ||
>get : Symbol(get, Decl(a.js, 18, 10)) | ||
|
||
this._map | ||
>this._map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
>_map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
|
||
this.set | ||
>this.set : Symbol(set, Decl(a.js, 12, 26)) | ||
>set : Symbol(set, Decl(a.js, 12, 26)) | ||
|
||
this.get | ||
>this.get : Symbol(get, Decl(a.js, 18, 10)) | ||
>get : Symbol(get, Decl(a.js, 18, 10)) | ||
|
||
this.addon | ||
>this.addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
>addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
} | ||
} | ||
|
||
Multimap.prototype.addon = function () { | ||
>Multimap.prototype : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
>Multimap : Symbol(Multimap, Decl(a.js, 4, 7)) | ||
>prototype : Symbol(Multimap.prototype, Decl(a.js, 10, 6)) | ||
>addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
|
||
this._map | ||
>this._map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
>_map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
|
||
this.set | ||
>this.set : Symbol(set, Decl(a.js, 12, 26)) | ||
>set : Symbol(set, Decl(a.js, 12, 26)) | ||
|
||
this.get | ||
>this.get : Symbol(get, Decl(a.js, 18, 10)) | ||
>get : Symbol(get, Decl(a.js, 18, 10)) | ||
|
||
this.addon | ||
>this.addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
>addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
} | ||
|
||
var mm = new Multimap(); | ||
>mm : Symbol(mm, Decl(a.js, 34, 7)) | ||
>Multimap : Symbol(Multimap, Decl(a.js, 4, 7)) | ||
|
||
mm._map | ||
>mm._map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
>mm : Symbol(mm, Decl(a.js, 34, 7)) | ||
>_map : Symbol(Multimap._map, Decl(a.js, 4, 31)) | ||
|
||
mm.set | ||
>mm.set : Symbol(set, Decl(a.js, 12, 26)) | ||
>mm : Symbol(mm, Decl(a.js, 34, 7)) | ||
>set : Symbol(set, Decl(a.js, 12, 26)) | ||
|
||
mm.get | ||
>mm.get : Symbol(get, Decl(a.js, 18, 10)) | ||
>mm : Symbol(mm, Decl(a.js, 34, 7)) | ||
>get : Symbol(get, Decl(a.js, 18, 10)) | ||
|
||
mm.addon | ||
>mm.addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
>mm : Symbol(mm, Decl(a.js, 34, 7)) | ||
>addon : Symbol(Multimap.addon, Decl(a.js, 25, 5)) | ||
|
||
}); | ||
|
156 changes: 156 additions & 0 deletions
156
tests/baselines/reference/typeFromPrototypeAssignment2.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,156 @@ | ||
=== tests/cases/conformance/salsa/a.js === | ||
// non top-level: | ||
// all references to _map, set, get, addon should be ok | ||
(function container() { | ||
>(function container() { /** @constructor */ var Multimap = function() { this._map = {}; this._map this.set this.get this.addon }; Multimap.prototype = { set: function() { this._map this.set this.get this.addon }, get() { this._map this.set this.get this.addon } } Multimap.prototype.addon = function () { this._map this.set this.get this.addon } var mm = new Multimap(); mm._map mm.set mm.get mm.addon}) : () => void | ||
>function container() { /** @constructor */ var Multimap = function() { this._map = {}; this._map this.set this.get this.addon }; Multimap.prototype = { set: function() { this._map this.set this.get this.addon }, get() { this._map this.set this.get this.addon } } Multimap.prototype.addon = function () { this._map this.set this.get this.addon } var mm = new Multimap(); mm._map mm.set mm.get mm.addon} : () => void | ||
>container : () => void | ||
|
||
/** @constructor */ | ||
var Multimap = function() { | ||
>Multimap : typeof Multimap | ||
>function() { this._map = {}; this._map this.set this.get this.addon } : typeof Multimap | ||
|
||
this._map = {}; | ||
>this._map = {} : {} | ||
>this._map : {} | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>_map : {} | ||
>{} : {} | ||
|
||
this._map | ||
>this._map : {} | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>_map : {} | ||
|
||
this.set | ||
>this.set : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>set : () => void | ||
|
||
this.get | ||
>this.get : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>get : () => void | ||
|
||
this.addon | ||
>this.addon : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>addon : () => void | ||
|
||
}; | ||
|
||
Multimap.prototype = { | ||
>Multimap.prototype = { set: function() { this._map this.set this.get this.addon }, get() { this._map this.set this.get this.addon } } : { set: () => void; get(): void; } | ||
>Multimap.prototype : { set: () => void; get(): void; } | ||
>Multimap : typeof Multimap | ||
>prototype : { set: () => void; get(): void; } | ||
>{ set: function() { this._map this.set this.get this.addon }, get() { this._map this.set this.get this.addon } } : { set: () => void; get(): void; } | ||
|
||
set: function() { | ||
>set : () => void | ||
>function() { this._map this.set this.get this.addon } : () => void | ||
|
||
this._map | ||
>this._map : {} | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>_map : {} | ||
|
||
this.set | ||
>this.set : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>set : () => void | ||
|
||
this.get | ||
>this.get : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>get : () => void | ||
|
||
this.addon | ||
>this.addon : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>addon : () => void | ||
|
||
}, | ||
get() { | ||
>get : () => void | ||
|
||
this._map | ||
>this._map : {} | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>_map : {} | ||
|
||
this.set | ||
>this.set : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>set : () => void | ||
|
||
this.get | ||
>this.get : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>get : () => void | ||
|
||
this.addon | ||
>this.addon : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>addon : () => void | ||
} | ||
} | ||
|
||
Multimap.prototype.addon = function () { | ||
>Multimap.prototype.addon = function () { this._map this.set this.get this.addon } : () => void | ||
>Multimap.prototype.addon : any | ||
>Multimap.prototype : { set: () => void; get(): void; } | ||
>Multimap : typeof Multimap | ||
>prototype : { set: () => void; get(): void; } | ||
>addon : any | ||
>function () { this._map this.set this.get this.addon } : () => void | ||
|
||
this._map | ||
>this._map : {} | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>_map : {} | ||
|
||
this.set | ||
>this.set : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>set : () => void | ||
|
||
this.get | ||
>this.get : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>get : () => void | ||
|
||
this.addon | ||
>this.addon : () => void | ||
>this : Multimap & { set: () => void; get(): void; } | ||
>addon : () => void | ||
} | ||
|
||
var mm = new Multimap(); | ||
>mm : Multimap & { set: () => void; get(): void; } | ||
>new Multimap() : Multimap & { set: () => void; get(): void; } | ||
>Multimap : typeof Multimap | ||
|
||
mm._map | ||
>mm._map : {} | ||
>mm : Multimap & { set: () => void; get(): void; } | ||
>_map : {} | ||
|
||
mm.set | ||
>mm.set : () => void | ||
>mm : Multimap & { set: () => void; get(): void; } | ||
>set : () => void | ||
|
||
mm.get | ||
>mm.get : () => void | ||
>mm : Multimap & { set: () => void; get(): void; } | ||
>get : () => void | ||
|
||
mm.addon | ||
>mm.addon : () => void | ||
>mm : Multimap & { set: () => void; get(): void; } | ||
>addon : () => void | ||
|
||
}); | ||
|
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.
This is an unrelated change. I moved this condition to the front because it's the most important check, and it was buried behind the complex predicate at the end.