-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
add support of TS Optional variance annotations
#2102
Conversation
internal/js_parser/ts_parser_test.go
Outdated
expectPrintedTSX(t, "<in T extends={true}></in>", "/* @__PURE__ */ React.createElement(\"in\", {\n T: true,\n extends: true\n});\n") | ||
expectPrintedTSX(t, "<out T extends={true}></out>", "/* @__PURE__ */ React.createElement(\"out\", {\n T: true,\n extends: true\n});\n") | ||
expectPrintedTSX(t, "<in out T extends={true}></in>", "/* @__PURE__ */ React.createElement(\"in\", {\n out: true,\n T: true,\n extends: true\n});\n") | ||
expectPrintedTSX(t, "<in T,>() => {}", "() => {\n};\n") |
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.
Where did these test cases come from? I can't reproduce this. The latest nightly build of the TypeScript compiler gives this for <in T,>() => {}
instead when JSX is enabled:
React.createElement("in", { T: true }, "() => ");
and this when JSX is disabled:
T, > ();
{ }
Edit: The reason why I'm now moving forward with testing this PR against the nightly TypeScript compiler is that the TypeScript PR for this has landed and support for the in
/out
modifiers now appears to work in nightly builds. For example, this code now works fine in nightly builds:
type Foo<out T> = () => T
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.
Oh, thanks.
I will report this issue to TypeScript repo.
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.
You are right.
It's TypeScript Error TS1273
.
I have modified the code and added some more test cases.
- increase test coverage - fix bug: anonymous classes don't support in/out - better error messages when in/out isn't allowed - more robust parsing of invalid in/out sequences
This PR add support of TS
Optional variance annotations