-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Instantiation expression can be followed by line break or binary operator #49353
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 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b51d604
Allow instantiation expression to be followed by let or interface on …
ahejlsberg 3ab7927
Add tests
ahejlsberg e8df098
Update src/compiler/parser.ts
DanielRosenwasser 919b36f
Instantiation expressions followed by line breaks or binary operators
ahejlsberg 4c82a58
Add more tests
ahejlsberg 395c036
Merge branch 'main' into fix49348
ahejlsberg fe46a9b
Accept new baselines
ahejlsberg 1699825
Fix lint error
ahejlsberg 816553a
Update fourslash test
ahejlsberg 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5732,6 +5732,12 @@ namespace ts { | |
case SyntaxKind.NoSubstitutionTemplateLiteral: // foo<T> `...` | ||
case SyntaxKind.TemplateHead: // foo<T> `...${100}...` | ||
return true; | ||
// These strict mode reserved words are valid identifiers in non-strict mode, and can thus | ||
// start an expression. However, when they follow a type argument list and are immediately | ||
// preceded by a line break, we don't consider them expression starters. | ||
case SyntaxKind.InterfaceKeyword: | ||
case SyntaxKind.LetKeyword: | ||
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. You need to cover more than just these cases and have tests for them - for example class C {
static specialFoo = f<string>
static bar = 123;
}
class D {
public specialFoo = f<string>
public bar = 123;
}
class E {
private specialFoo = f<string>
private bar = 123;
}
class F {
protected specialFoo = f<string>
protected bar = 123;
} |
||
return scanner.hasPrecedingLineBreak(); | ||
} | ||
// Consider something a type argument list only if the following token can't start an expression. | ||
return !isStartOfExpression(); | ||
|
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
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.