[ts 4.7] Support optional variance annotations#14359
[ts 4.7] Support optional variance annotations#14359nicolo-ribaudo merged 9 commits intobabel:mainfrom magic-akari:feat/ts-VarianceAnnotations
Conversation
JLHwung
left a comment
There was a problem hiding this comment.
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.
Can you add a generator test case to packages/babel-generator/test/fixtures/typescript?
There was a problem hiding this comment.
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.
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