-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Avoid circular reference in this-property assignments #37827
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
sandersn
merged 5 commits into
master
from
avoid-circular-reference-in-this-property-assignments
Apr 10, 2020
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b518ea0
Avoid circular reference in this-property assignments
sandersn d80ab88
Add test case + rename function
sandersn 8a6718f
Use isMatchingReference
sandersn e219402
Merge branch 'master' into avoid-circular-reference-in-this-property-…
sandersn ccb9fab
Merge branch 'master' into avoid-circular-reference-in-this-property-…
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
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/thisPropertyAssignmentCircular.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,28 @@ | ||
//// [thisPropertyAssignmentCircular.js] | ||
export class Foo { | ||
constructor() { | ||
this.foo = "Hello"; | ||
} | ||
slicey() { | ||
this.foo = this.foo.slice(); | ||
} | ||
m() { | ||
this.foo | ||
} | ||
} | ||
|
||
/** @class */ | ||
function C() { | ||
this.x = 0; | ||
this.x = function() { this.x.toString(); } | ||
} | ||
|
||
|
||
|
||
|
||
//// [thisPropertyAssignmentCircular.d.ts] | ||
export class Foo { | ||
foo: string; | ||
slicey(): void; | ||
m(): void; | ||
} |
51 changes: 51 additions & 0 deletions
51
tests/baselines/reference/thisPropertyAssignmentCircular.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/thisPropertyAssignmentCircular.js === | ||
export class Foo { | ||
>Foo : Symbol(Foo, Decl(thisPropertyAssignmentCircular.js, 0, 0)) | ||
|
||
constructor() { | ||
this.foo = "Hello"; | ||
>this.foo : Symbol(Foo.foo, Decl(thisPropertyAssignmentCircular.js, 1, 19), Decl(thisPropertyAssignmentCircular.js, 4, 14)) | ||
>this : Symbol(Foo, Decl(thisPropertyAssignmentCircular.js, 0, 0)) | ||
>foo : Symbol(Foo.foo, Decl(thisPropertyAssignmentCircular.js, 1, 19), Decl(thisPropertyAssignmentCircular.js, 4, 14)) | ||
} | ||
slicey() { | ||
>slicey : Symbol(Foo.slicey, Decl(thisPropertyAssignmentCircular.js, 3, 5)) | ||
|
||
this.foo = this.foo.slice(); | ||
>this.foo : Symbol(Foo.foo, Decl(thisPropertyAssignmentCircular.js, 1, 19), Decl(thisPropertyAssignmentCircular.js, 4, 14)) | ||
>this : Symbol(Foo, Decl(thisPropertyAssignmentCircular.js, 0, 0)) | ||
>foo : Symbol(Foo.foo, Decl(thisPropertyAssignmentCircular.js, 1, 19), Decl(thisPropertyAssignmentCircular.js, 4, 14)) | ||
>this.foo.slice : Symbol(String.slice, Decl(lib.es5.d.ts, --, --)) | ||
>this.foo : Symbol(Foo.foo, Decl(thisPropertyAssignmentCircular.js, 1, 19), Decl(thisPropertyAssignmentCircular.js, 4, 14)) | ||
>this : Symbol(Foo, Decl(thisPropertyAssignmentCircular.js, 0, 0)) | ||
>foo : Symbol(Foo.foo, Decl(thisPropertyAssignmentCircular.js, 1, 19), Decl(thisPropertyAssignmentCircular.js, 4, 14)) | ||
>slice : Symbol(String.slice, Decl(lib.es5.d.ts, --, --)) | ||
} | ||
m() { | ||
>m : Symbol(Foo.m, Decl(thisPropertyAssignmentCircular.js, 6, 5)) | ||
|
||
this.foo | ||
>this.foo : Symbol(Foo.foo, Decl(thisPropertyAssignmentCircular.js, 1, 19), Decl(thisPropertyAssignmentCircular.js, 4, 14)) | ||
>this : Symbol(Foo, Decl(thisPropertyAssignmentCircular.js, 0, 0)) | ||
>foo : Symbol(Foo.foo, Decl(thisPropertyAssignmentCircular.js, 1, 19), Decl(thisPropertyAssignmentCircular.js, 4, 14)) | ||
} | ||
} | ||
|
||
/** @class */ | ||
function C() { | ||
>C : Symbol(C, Decl(thisPropertyAssignmentCircular.js, 10, 1)) | ||
|
||
this.x = 0; | ||
>this.x : Symbol(C.x, Decl(thisPropertyAssignmentCircular.js, 13, 14), Decl(thisPropertyAssignmentCircular.js, 14, 15)) | ||
>this : Symbol(C, Decl(thisPropertyAssignmentCircular.js, 10, 1)) | ||
>x : Symbol(C.x, Decl(thisPropertyAssignmentCircular.js, 13, 14), Decl(thisPropertyAssignmentCircular.js, 14, 15)) | ||
|
||
this.x = function() { this.x.toString(); } | ||
>this.x : Symbol(C.x, Decl(thisPropertyAssignmentCircular.js, 13, 14), Decl(thisPropertyAssignmentCircular.js, 14, 15)) | ||
>this : Symbol(C, Decl(thisPropertyAssignmentCircular.js, 10, 1)) | ||
>x : Symbol(C.x, Decl(thisPropertyAssignmentCircular.js, 13, 14), Decl(thisPropertyAssignmentCircular.js, 14, 15)) | ||
>this.x : Symbol(C.x, Decl(thisPropertyAssignmentCircular.js, 13, 14), Decl(thisPropertyAssignmentCircular.js, 14, 15)) | ||
>this : Symbol(C, Decl(thisPropertyAssignmentCircular.js, 10, 1)) | ||
>x : Symbol(C.x, Decl(thisPropertyAssignmentCircular.js, 13, 14), Decl(thisPropertyAssignmentCircular.js, 14, 15)) | ||
} | ||
|
62 changes: 62 additions & 0 deletions
62
tests/baselines/reference/thisPropertyAssignmentCircular.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,62 @@ | ||
=== tests/cases/conformance/salsa/thisPropertyAssignmentCircular.js === | ||
export class Foo { | ||
>Foo : Foo | ||
|
||
constructor() { | ||
this.foo = "Hello"; | ||
>this.foo = "Hello" : "Hello" | ||
>this.foo : string | ||
>this : this | ||
>foo : string | ||
>"Hello" : "Hello" | ||
} | ||
slicey() { | ||
>slicey : () => void | ||
|
||
this.foo = this.foo.slice(); | ||
>this.foo = this.foo.slice() : string | ||
>this.foo : string | ||
>this : this | ||
>foo : string | ||
>this.foo.slice() : string | ||
>this.foo.slice : (start?: number, end?: number) => string | ||
>this.foo : string | ||
>this : this | ||
>foo : string | ||
>slice : (start?: number, end?: number) => string | ||
} | ||
m() { | ||
>m : () => void | ||
|
||
this.foo | ||
>this.foo : string | ||
>this : this | ||
>foo : string | ||
} | ||
} | ||
|
||
/** @class */ | ||
function C() { | ||
>C : typeof C | ||
|
||
this.x = 0; | ||
>this.x = 0 : 0 | ||
>this.x : any | ||
>this : this | ||
>x : any | ||
>0 : 0 | ||
|
||
this.x = function() { this.x.toString(); } | ||
>this.x = function() { this.x.toString(); } : () => void | ||
>this.x : any | ||
>this : this | ||
>x : any | ||
>function() { this.x.toString(); } : () => void | ||
>this.x.toString() : any | ||
>this.x.toString : any | ||
>this.x : any | ||
>this : this | ||
>x : any | ||
>toString : any | ||
} | ||
|
22 changes: 22 additions & 0 deletions
22
tests/cases/conformance/salsa/thisPropertyAssignmentCircular.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 @@ | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @declaration: true | ||
// @emitDeclarationOnly: true | ||
// @filename: thisPropertyAssignmentCircular.js | ||
export class Foo { | ||
constructor() { | ||
this.foo = "Hello"; | ||
} | ||
slicey() { | ||
this.foo = this.foo.slice(); | ||
} | ||
m() { | ||
this.foo | ||
} | ||
} | ||
|
||
/** @class */ | ||
function C() { | ||
this.x = 0; | ||
this.x = function() { this.x.toString(); } | ||
} |
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.