-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Put error spans deep on nested object literals #25140
Merged
Merged
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
91d292d
Add ncie deep elaborations
weswigham 4303c00
Merge branch 'master' into nice-elaborations
weswigham c463bd5
Nice stuff
weswigham 5733e3f
Merge branch 'master' into nice-elaborations
weswigham 167ec23
Merge branch 'master' into nice-elaborations
weswigham f832eae
Modify tuple error to use length error mroe often
weswigham 36206c8
Accept good baselines
weswigham c8fc8db
Accept meh baselines
weswigham f52c9b9
Fix literal types
weswigham ea3300a
Calculate elaborations like it was the very first time again~
weswigham 23d1e17
Use tristate for enum relationship to ensure elaborations are printed…
weswigham 4a757fa
Merge branch 'master' into nice-elaborations
weswigham 10b1292
Merge branch 'master' into nice-elaborations
weswigham e663505
Update message text, nits
weswigham 7b83484
Merge branch 'master' into nice-elaborations
weswigham b819165
move some functions back to where they were
weswigham 1bcf91e
Add test of deep JSX elaboration
weswigham 9eb759b
Add elaboration test with parenthesized expressions, comma expression…
weswigham 62ba57c
Move check to allow elaborations on more anonymous types
weswigham 7a344f5
Fix nits
weswigham dcbf33a
Add specialized error to elaborations of nonliteral computed named-me…
weswigham ae46816
Update error message
weswigham 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
|
@@ -6674,6 +6674,25 @@ namespace ts { | |
return node.kind === SyntaxKind.NamedImports || node.kind === SyntaxKind.NamedExports; | ||
} | ||
|
||
/* @internal */ | ||
/** | ||
* Strip off existed single quotes or double quotes from a given string | ||
* | ||
* @return non-quoted string | ||
*/ | ||
export function stripQuotes(name: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like we should just be able to call |
||
const length = name.length; | ||
if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { | ||
return name.substring(1, length - 1); | ||
} | ||
return name; | ||
} | ||
|
||
/* @internal */ | ||
export function startsWithQuote(name: string): boolean { | ||
return isSingleOrDoubleQuote(name.charCodeAt(0)); | ||
} | ||
|
||
export interface ObjectAllocator { | ||
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node; | ||
getTokenConstructor(): new <TKind extends SyntaxKind>(kind: TKind, pos?: number, end?: number) => Token<TKind>; | ||
|
This file contains 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 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,7 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"pretty": true, | ||
"lib": ["es5"], | ||
"lib": ["es2015"], | ||
"target": "es5", | ||
|
||
"declaration": true, | ||
|
This file contains 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 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 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 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 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 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
17 changes: 7 additions & 10 deletions
17
tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt
This file contains 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,21 +1,18 @@ | ||
tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts(6,5): error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. | ||
Index signatures are incompatible. | ||
Type 'string | number' is not assignable to type 'boolean'. | ||
Type 'string' is not assignable to type 'boolean'. | ||
tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts(7,5): error TS2322: Type 'string' is not assignable to type 'boolean'. | ||
tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts(8,5): error TS2322: Type 'number' is not assignable to type 'boolean'. | ||
|
||
|
||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts (1 errors) ==== | ||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts (2 errors) ==== | ||
interface I { | ||
[s: string]: boolean; | ||
[s: number]: boolean; | ||
} | ||
|
||
var o: I = { | ||
~ | ||
!!! error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. | ||
!!! error TS2322: Index signatures are incompatible. | ||
!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. | ||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'. | ||
[""+"foo"]: "", | ||
~~~~~~~~~~ | ||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'. | ||
[""+"bar"]: 0 | ||
~~~~~~~~~~ | ||
!!! error TS2322: Type 'number' is not assignable to type 'boolean'. | ||
} |
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.
I thought it was "category": "Error"
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.
As discussed duing our sync earlier, right now the category is unused for related information - we can put off deciding why they aughta be until we have a story for using them in some principled way (for, eg, elaborations vs explanations)