-
Notifications
You must be signed in to change notification settings - Fork 657
feat(rome_js_parser): instantiation expressions #3147 #4035
feat(rome_js_parser): instantiation expressions #3147 #4035
Conversation
✅ Deploy Preview for docs-rometools canceled.Built without sensitive environment variables
|
92efc3c
to
c88a068
Compare
crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions.ts
Outdated
Show resolved
Hide resolved
Let's rebase this PR to get the latest parser conformance tests. This PR should fix some of them. |
c88a068
to
b8e3bf2
Compare
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 ran the typescript instantiation expression tests and there's one test that is passing when it should not:
[FAIL] type-arguments\instantiation-expression-property-access: Incorrectly passed
The test should fail because it's invalid to access a property after an instantiation expression.
// invalid
a<b>.c;
a<b>?.c;
a<b>?.[c];
I assume that TypeScript implements this as part of the type checker and not as part of the parser itself (but it would be worth double-checking).
We have two options if that's the case:
- Try to implement it as part of the parser
- Implement a syntax rule that reports property accessors after instantiation expressions
And we can implement this either as part of this or a separate PR. Let me know what you prefer.
Babel ts parser and typescript parser have a different implementation about access a property after an instantiation expression.
We want to have the same behaviour as typescript parser. Typescript playground Added new test cases and an error. |
Thank you so much for working on this. Well done! 🥳 |
Summary
This PR fixes:
#3793
#3147
When a potential type argument list is followed by
Typescript reference:
Typescript design notes:
Relative issues:
Open questions:
isBinaryOperator
function: https://github.com/microsoft/TypeScript/blob/main/src/compiler/parser.ts#L5528-L5534Disallow expression with type parameters as left side of property access microsoft/TypeScript#49464
[ts] Disallow property access after instantiation expression babel/babel#14650
f<T> << f<T>;
is valid code. But this PR doesn't support it. May be we can do it in another PR. Prettier playgroundTest Plan
cargo test -p rome_js_parser
test cases from babel:
test cases from esbuild: