-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Skip excess property elaborations #29760
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
85cbc66
Don't chain diagnostics after excess property messages have been issued.
DanielRosenwasser a03f5fb
Accepted baselines.
DanielRosenwasser 3d56468
Updated annoying inline unittests.
DanielRosenwasser 471eb5b
Wording and grammar.
DanielRosenwasser 657b3e0
Move assignment to error span reset, and give some explanation.
DanielRosenwasser 9746252
Move the line back to the bottom.
DanielRosenwasser 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
tests/cases/compiler/arrayCast.ts(3,23): error TS2352: Conversion of type '{ foo: string; }[]' to type '{ id: number; }[]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. | ||
Type '{ foo: string; }' is not comparable to type '{ id: number; }'. | ||
Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. | ||
tests/cases/compiler/arrayCast.ts(3,23): error TS2353: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. | ||
|
||
|
||
==== tests/cases/compiler/arrayCast.ts (1 errors) ==== | ||
// Should fail. Even though the array is contextually typed with { id: number }[], it still | ||
// has type { foo: string }[], which is not assignable to { id: number }[]. | ||
<{ id: number; }[]>[{ foo: "s" }]; | ||
~~~~~~~~ | ||
!!! error TS2352: Conversion of type '{ foo: string; }[]' to type '{ id: number; }[]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. | ||
!!! error TS2352: Type '{ foo: string; }' is not comparable to type '{ id: number; }'. | ||
!!! error TS2352: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. | ||
!!! error TS2353: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'. | ||
|
||
// Should succeed, as the {} element causes the type of the array to be {}[] | ||
<{ id: number; }[]>[{ foo: "s" }, {}]; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
tests/cases/compiler/contextualTyping12.ts(1,57): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. | ||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. | ||
tests/cases/compiler/contextualTyping12.ts(1,57): error TS2353: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. | ||
|
||
|
||
==== tests/cases/compiler/contextualTyping12.ts (1 errors) ==== | ||
class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; } | ||
~~~~~~~~~~ | ||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. | ||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. | ||
!!! error TS2353: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. |
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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
tests/cases/compiler/contextualTyping17.ts(1,47): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. | ||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. | ||
tests/cases/compiler/contextualTyping17.ts(1,47): error TS2353: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. | ||
|
||
|
||
==== tests/cases/compiler/contextualTyping17.ts (1 errors) ==== | ||
var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"}; | ||
~~~~~~~~~~ | ||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'. | ||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. | ||
!!! error TS2353: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'. |
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.