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
[ts 4.7] Support optional variance annotations #14359
[ts 4.7] Support optional variance annotations #14359
Conversation
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 you add some test cases?
// with plugins `jsx` and `typescript`
<in T>() => {}
It should throw SingleTypeParameterWithoutTrailingComma error.
And also a type-variance-like JSX element:
<in T>() => {}</in>
It should be parsed successfully.
this.word("out"); | ||
this.space(); | ||
} | ||
|
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 you add a generator test case to packages/babel-generator/test/fixtures/typescript
?
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'm investigating ci failures in main branch, but I don't know much about ts and jsx.
<in T>() => {}</in>
will fail when BABEL_8_BREAKING is enabled.
Can someone tell me if this is a problem with the parser or with the test?
Test Added. please do not merge until microsoft/TypeScript#48240 is merged. |
cc @bradzacher if you have any comment regarding the AST shape |
in?: boolean, | ||
out?: boolean, |
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'm not 100% sold on using boolean flags as it locks us in with naming but I guess that this is the same thing we did with class property modifiers as well so it's not like we're breaking convention in the AST.
Given the precedence - this is probably the best approach, so LGTM
@JLHwung |
@magic-akari I think the AST shape is fine. We can add a |
variance modifier can only appear on a type parameter of a class, interface or type alias
This PR Implement
Optional variance annotations