Allow keywords in TS qualified types#14362
Merged
nicolo-ribaudo merged 3 commits intobabel:mainfrom Mar 16, 2022
Merged
Conversation
nicolo-ribaudo
commented
Mar 15, 2022
| allowReservedEntityName: false, | ||
| allowReservedQualifiers: false, | ||
| }); | ||
| : this.tsParseEntityName(/* allowReservedWords */ false); |
Member
Author
There was a problem hiding this comment.
I think this is a TS bug (microsoft/TypeScript#48274), but I decided to match the TS behavior and throw.
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51493/ |
It's just moving test names in order, and `defaultIsNotVisibleInLocalScope.ts` is deleted
|
existentialism
approved these changes
Mar 16, 2022
JLHwung
reviewed
Mar 16, 2022
| classExtendsMultipleBaseClasses.ts | ||
| classOverloadForFunction.ts | ||
| classWithEmptyTypeParameter.ts | ||
| # TypeScript doesn't allow a parameter to be named arguments even in non-strict mode, which we don't catch. |
Contributor
There was a problem hiding this comment.
Can we modify the generator to preserve such comments?
Member
Author
There was a problem hiding this comment.
They were already supported but they must be inline. I now moved them.
JLHwung
approved these changes
Mar 16, 2022
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
TypeScript is way more liberal than the restrictions we introduced in #14320: it allows keywords in qualified types almost everywhere, and it handles keywords as normal identifiers.
I believe that some valid syntax will always result in a type checking error, for example
type A = if. However, the TypeScript parser happily accepts it and only reportsifas not being defined (I don't know if it's possible to use something like jsdoc or external declaration files to declare anifglobal type).