-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Add getEffectiveConstructSignatures #27561
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
8 commits
Select commit
Hold shift + click to select a range
458d04e
Add helpers that understand constructor functions
sandersn b9a5d8a
Correct correct originalBaseType
sandersn bacb81b
Add error examples to tests
sandersn 967ad2c
Merge branch 'master' into add-getEffectiveConstructSignatures
sandersn 2786f24
Add construct signatures instead of getEffective* functions
sandersn 87ad09e
Fix typo in baseline
sandersn 977d09d
Remove pesky newline
sandersn fe8bd11
Test of constructor tag on object literal method
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
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
15 changes: 15 additions & 0 deletions
15
tests/baselines/reference/constructorTagOnObjectLiteralMethod.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,15 @@ | ||
tests/cases/conformance/jsdoc/example.js(3,16): error TS2339: Property 'bar' does not exist on type '{ Foo(): void; }'. | ||
tests/cases/conformance/jsdoc/example.js(5,2): error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. | ||
|
||
|
||
==== tests/cases/conformance/jsdoc/example.js (2 errors) ==== | ||
const obj = { | ||
/** @constructor */ | ||
Foo() { this.bar = "bar" } | ||
~~~ | ||
!!! error TS2339: Property 'bar' does not exist on type '{ Foo(): void; }'. | ||
}; | ||
(new obj.Foo()).bar | ||
~~~~~~~~~~~~~ | ||
!!! error TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type. | ||
|
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/constructorTagOnObjectLiteralMethod.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,16 @@ | ||
=== tests/cases/conformance/jsdoc/example.js === | ||
const obj = { | ||
>obj : Symbol(obj, Decl(example.js, 0, 5)) | ||
|
||
/** @constructor */ | ||
Foo() { this.bar = "bar" } | ||
>Foo : Symbol(Foo, Decl(example.js, 0, 13)) | ||
>this : Symbol(obj, Decl(example.js, 0, 11)) | ||
>bar : Symbol(bar, Decl(example.js, 2, 9)) | ||
|
||
}; | ||
(new obj.Foo()).bar | ||
>obj.Foo : Symbol(Foo, Decl(example.js, 0, 13)) | ||
>obj : Symbol(obj, Decl(example.js, 0, 5)) | ||
>Foo : Symbol(Foo, Decl(example.js, 0, 13)) | ||
|
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/constructorTagOnObjectLiteralMethod.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,24 @@ | ||
=== tests/cases/conformance/jsdoc/example.js === | ||
const obj = { | ||
>obj : { Foo(): void; } | ||
>{ /** @constructor */ Foo() { this.bar = "bar" }} : { Foo(): void; } | ||
|
||
/** @constructor */ | ||
Foo() { this.bar = "bar" } | ||
>Foo : () => void | ||
>this.bar = "bar" : "bar" | ||
>this.bar : any | ||
>this : { Foo(): void; } | ||
>bar : any | ||
>"bar" : "bar" | ||
|
||
}; | ||
(new obj.Foo()).bar | ||
>(new obj.Foo()).bar : any | ||
>(new obj.Foo()) : any | ||
>new obj.Foo() : any | ||
>obj.Foo : () => void | ||
>obj : { Foo(): void; } | ||
>Foo : () => void | ||
>bar : 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
10 changes: 10 additions & 0 deletions
10
tests/cases/conformance/jsdoc/constructorTagOnObjectLiteralMethod.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,10 @@ | ||
// @noEmit: true | ||
// @Filename: example.js | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @noImplicitAny: true | ||
const obj = { | ||
/** @constructor */ | ||
Foo() { this.bar = "bar" } | ||
}; | ||
(new obj.Foo()).bar |
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
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.
Uh oh!
There was an error while loading. Please reload this page.