-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Don't treat object properties as potential JS contructors without JSDoc class tag #49735
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
5 commits
Select commit
Hold shift + click to select a range
9357739
Add test case
jakebailey 88b88aa
Don't treat object properties as potential JS contructors without JSD…
jakebailey 4f58a1b
Handle object literal methods
jakebailey 086c8c9
Don't handle methods
jakebailey 532c2bb
Use correct node for property assignment check
jakebailey 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
=== tests/cases/compiler/index.js === | ||
const a1 = { | ||
>a1 : Symbol(a1, Decl(index.js, 0, 5)) | ||
|
||
foo() { | ||
>foo : Symbol(foo, Decl(index.js, 0, 12)) | ||
|
||
this.x = 0; | ||
>this : Symbol(a1, Decl(index.js, 0, 10)) | ||
>x : Symbol(x, Decl(index.js, 1, 11)) | ||
} | ||
} | ||
|
||
const a2 = { | ||
>a2 : Symbol(a2, Decl(index.js, 6, 5)) | ||
|
||
foo: function() { | ||
>foo : Symbol(foo, Decl(index.js, 6, 12)) | ||
|
||
this.x = 0; | ||
>this : Symbol(a2, Decl(index.js, 6, 10)) | ||
>x : Symbol(foo.x, Decl(index.js, 7, 21)) | ||
} | ||
} | ||
|
||
const b1 = { | ||
>b1 : Symbol(b1, Decl(index.js, 12, 5)) | ||
|
||
/** @class */ | ||
foo() { | ||
>foo : Symbol(foo, Decl(index.js, 12, 12)) | ||
|
||
this.x = 0; | ||
>this : Symbol(b1, Decl(index.js, 12, 10)) | ||
>x : Symbol(x, Decl(index.js, 14, 11)) | ||
} | ||
} | ||
|
||
const b2 = { | ||
>b2 : Symbol(b2, Decl(index.js, 19, 5)) | ||
|
||
/** @class */ | ||
foo: function() { | ||
>foo : Symbol(foo, Decl(index.js, 19, 12)) | ||
|
||
this.x = 0; | ||
>this.x : Symbol(foo.x, Decl(index.js, 21, 21)) | ||
>this : Symbol(foo, Decl(index.js, 21, 8)) | ||
>x : Symbol(foo.x, Decl(index.js, 21, 21)) | ||
} | ||
} | ||
|
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,69 @@ | ||
=== tests/cases/compiler/index.js === | ||
const a1 = { | ||
>a1 : { foo(): void; } | ||
>{ foo() { this.x = 0; }} : { foo(): void; } | ||
|
||
foo() { | ||
>foo : () => void | ||
|
||
this.x = 0; | ||
>this.x = 0 : 0 | ||
>this.x : any | ||
>this : { foo(): void; } | ||
>x : any | ||
>0 : 0 | ||
} | ||
} | ||
|
||
const a2 = { | ||
>a2 : { foo: typeof foo; } | ||
>{ foo: function() { this.x = 0; }} : { foo: typeof foo; } | ||
|
||
foo: function() { | ||
>foo : typeof foo | ||
>function() { this.x = 0; } : typeof foo | ||
|
||
this.x = 0; | ||
>this.x = 0 : 0 | ||
>this.x : any | ||
>this : { foo: typeof foo; } | ||
>x : any | ||
>0 : 0 | ||
} | ||
} | ||
|
||
const b1 = { | ||
>b1 : { foo(): void; } | ||
>{ /** @class */ foo() { this.x = 0; }} : { foo(): void; } | ||
|
||
/** @class */ | ||
foo() { | ||
>foo : () => void | ||
|
||
this.x = 0; | ||
>this.x = 0 : 0 | ||
>this.x : any | ||
>this : { foo(): void; } | ||
jakebailey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
>x : any | ||
>0 : 0 | ||
} | ||
} | ||
|
||
const b2 = { | ||
>b2 : { foo: typeof foo; } | ||
>{ /** @class */ foo: function() { this.x = 0; }} : { foo: typeof foo; } | ||
|
||
/** @class */ | ||
foo: function() { | ||
>foo : typeof foo | ||
>function() { this.x = 0; } : typeof foo | ||
|
||
this.x = 0; | ||
>this.x = 0 : 0 | ||
>this.x : any | ||
>this : this | ||
>x : any | ||
>0 : 0 | ||
} | ||
} | ||
|
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,39 @@ | ||
//// [index.js] | ||
export { } | ||
let obj = { | ||
x: 10, | ||
y: [1], | ||
fun: function() { | ||
this.x = 1 | ||
this/*1*/ | ||
}, | ||
f2: function() { | ||
this.x | ||
this/*2*/ | ||
}, | ||
f3: (function() { | ||
this.x = 1 | ||
this/*3*/ | ||
}), | ||
} | ||
|
||
|
||
//// [index.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var obj = { | ||
x: 10, | ||
y: [1], | ||
fun: function () { | ||
this.x = 1; | ||
this; /*1*/ | ||
}, | ||
f2: function () { | ||
this.x; | ||
this; /*2*/ | ||
}, | ||
f3: (function () { | ||
this.x = 1; | ||
this; /*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,45 @@ | ||
=== tests/cases/compiler/index.js === | ||
export { } | ||
let obj = { | ||
>obj : Symbol(obj, Decl(index.js, 1, 3)) | ||
|
||
x: 10, | ||
>x : Symbol(x, Decl(index.js, 1, 11)) | ||
|
||
y: [1], | ||
>y : Symbol(y, Decl(index.js, 2, 8)) | ||
|
||
fun: function() { | ||
>fun : Symbol(fun, Decl(index.js, 3, 9)) | ||
|
||
this.x = 1 | ||
>this.x : Symbol(x, Decl(index.js, 1, 11)) | ||
>this : Symbol(obj, Decl(index.js, 1, 9)) | ||
>x : Symbol(fun.x, Decl(index.js, 4, 19)) | ||
|
||
this/*1*/ | ||
>this : Symbol(obj, Decl(index.js, 1, 9)) | ||
|
||
}, | ||
f2: function() { | ||
>f2 : Symbol(f2, Decl(index.js, 7, 4)) | ||
|
||
this.x | ||
>this.x : Symbol(x, Decl(index.js, 1, 11)) | ||
>this : Symbol(obj, Decl(index.js, 1, 9)) | ||
>x : Symbol(x, Decl(index.js, 1, 11)) | ||
|
||
this/*2*/ | ||
>this : Symbol(obj, Decl(index.js, 1, 9)) | ||
|
||
}, | ||
f3: (function() { | ||
>f3 : Symbol(f3, Decl(index.js, 11, 4)) | ||
|
||
this.x = 1 | ||
>x : Symbol((Anonymous function).x, Decl(index.js, 12, 19)) | ||
|
||
this/*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,61 @@ | ||
=== tests/cases/compiler/index.js === | ||
export { } | ||
let obj = { | ||
>obj : { x: number; y: number[]; fun: typeof fun; f2: () => void; f3: typeof (Anonymous function); } | ||
>{ x: 10, y: [1], fun: function() { this.x = 1 this/*1*/ }, f2: function() { this.x this/*2*/ }, f3: (function() { this.x = 1 this/*3*/ }),} : { x: number; y: number[]; fun: typeof fun; f2: () => void; f3: typeof (Anonymous function); } | ||
|
||
x: 10, | ||
>x : number | ||
>10 : 10 | ||
|
||
y: [1], | ||
>y : number[] | ||
>[1] : number[] | ||
>1 : 1 | ||
|
||
fun: function() { | ||
>fun : typeof fun | ||
>function() { this.x = 1 this/*1*/ } : typeof fun | ||
|
||
this.x = 1 | ||
>this.x = 1 : 1 | ||
>this.x : number | ||
>this : { x: number; y: number[]; fun: typeof fun; f2: () => void; f3: typeof (Anonymous function); } | ||
>x : number | ||
>1 : 1 | ||
|
||
this/*1*/ | ||
>this : { x: number; y: number[]; fun: typeof fun; f2: () => void; f3: typeof (Anonymous function); } | ||
|
||
}, | ||
f2: function() { | ||
>f2 : () => void | ||
>function() { this.x this/*2*/ } : () => void | ||
|
||
this.x | ||
>this.x : number | ||
>this : { x: number; y: number[]; fun: typeof fun; f2: () => void; f3: typeof (Anonymous function); } | ||
>x : number | ||
|
||
this/*2*/ | ||
>this : { x: number; y: number[]; fun: typeof fun; f2: () => void; f3: typeof (Anonymous function); } | ||
|
||
}, | ||
f3: (function() { | ||
>f3 : typeof (Anonymous function) | ||
>(function() { this.x = 1 this/*3*/ }) : typeof (Anonymous function) | ||
>function() { this.x = 1 this/*3*/ } : typeof (Anonymous function) | ||
|
||
this.x = 1 | ||
>this.x = 1 : 1 | ||
>this.x : any | ||
>this : any | ||
>x : any | ||
>1 : 1 | ||
|
||
this/*3*/ | ||
>this : any | ||
|
||
}), | ||
} | ||
|
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,30 @@ | ||
// @allowJs: true | ||
// @noEmit: true | ||
// @checkJs: true | ||
|
||
// @filename: index.js | ||
const a1 = { | ||
foo() { | ||
this.x = 0; | ||
} | ||
} | ||
|
||
const a2 = { | ||
foo: function() { | ||
this.x = 0; | ||
} | ||
} | ||
|
||
const b1 = { | ||
/** @class */ | ||
foo() { | ||
this.x = 0; | ||
} | ||
} | ||
|
||
const b2 = { | ||
/** @class */ | ||
foo: function() { | ||
this.x = 0; | ||
} | ||
} |
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 @@ | ||
// @allowJs: true | ||
// @outDir: out | ||
|
||
// @filename: index.js | ||
export { } | ||
let obj = { | ||
x: 10, | ||
y: [1], | ||
fun: function() { | ||
this.x = 1 | ||
this/*1*/ | ||
}, | ||
f2: function() { | ||
this.x | ||
this/*2*/ | ||
}, | ||
f3: (function() { | ||
this.x = 1 | ||
this/*3*/ | ||
}), | ||
} |
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 test is explicitly the case that is changing:
So, I'm not sure if that's good or bad.