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
Allow keywords in TS qualified types #14362
Allow keywords in TS qualified types #14362
Conversation
allowReservedEntityName: false, | ||
allowReservedQualifiers: false, | ||
}); | ||
: this.tsParseEntityName(/* allowReservedWords */ false); |
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 think this is a TS bug (microsoft/TypeScript#48274), but I decided to match the TS behavior and throw.
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
|
@@ -23,11 +23,8 @@ classExpressionWithDecorator1.ts | |||
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. |
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.
Can we modify the generator to preserve such comments?
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.
They were already supported but they must be inline. I now moved them.
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 reportsif
as not being defined (I don't know if it's possible to use something like jsdoc or external declaration files to declare anif
global type).