fix(rome_js_parser): allow readonly property with initializer in ambient context #3000
Conversation
I am not familiar with this codebase. Is there a step I'm missing? |
You should run |
No. It does not work. No rast files generated. failures:
---- tests::parser::ok::ts_property_readonly_initializer_ambient_context stdout ----
thread 'tests::parser::ok::ts_property_readonly_initializer_ambient_context' panicked at 'There should be no errors in the file "/Users/akari/Github/tools/crates/rome_js_parser/test_data/inline/ok/ts_property_readonly_initializer_ambient_context.ts" but the following errors where present:
Parsed tree:
0: JS_MODULE@0..86
0: (empty)
1: JS_DIRECTIVE_LIST@0..0
2: JS_MODULE_ITEM_LIST@0..85
0: TS_DECLARE_STATEMENT@0..42
0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")]
1: JS_CLASS_DECLARATION@8..42
0: (empty)
1: CLASS_KW@8..14 "class" [] [Whitespace(" ")]
2: JS_IDENTIFIER_BINDING@14..16
0: IDENT@14..16 "A" [] [Whitespace(" ")]
3: (empty)
4: (empty)
5: (empty)
6: L_CURLY@16..18 "{" [] [Whitespace(" ")]
7: JS_CLASS_MEMBER_LIST@18..41
0: JS_UNKNOWN_MEMBER@18..41
0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@18..27
0: TS_READONLY_MODIFIER@18..27
0: READONLY_KW@18..27 "readonly" [] [Whitespace(" ")]
1: JS_LITERAL_MEMBER_NAME@27..32
0: IDENT@27..32 "prop" [] [Whitespace(" ")]
2: JS_INITIALIZER_CLAUSE@32..41
0: EQ@32..34 "=" [] [Whitespace(" ")]
1: JS_STRING_LITERAL_EXPRESSION@34..41
0: JS_STRING_LITERAL@34..41 "\"test\"" [] [Whitespace(" ")]
8: R_CURLY@41..42 "}" [] []
1: JS_CLASS_DECLARATION@42..85
0: (empty)
1: CLASS_KW@42..49 "class" [Newline("\n")] [Whitespace(" ")]
2: JS_IDENTIFIER_BINDING@49..51
0: IDENT@49..51 "B" [] [Whitespace(" ")]
3: (empty)
4: (empty)
5: (empty)
6: L_CURLY@51..53 "{" [] [Whitespace(" ")]
7: JS_CLASS_MEMBER_LIST@53..84
0: JS_UNKNOWN_MEMBER@53..84
0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@53..70
0: TS_DECLARE_MODIFIER@53..61
0: DECLARE_KW@53..61 "declare" [] [Whitespace(" ")]
1: TS_READONLY_MODIFIER@61..70
0: READONLY_KW@61..70 "readonly" [] [Whitespace(" ")]
1: JS_LITERAL_MEMBER_NAME@70..75
0: IDENT@70..75 "prop" [] [Whitespace(" ")]
2: JS_INITIALIZER_CLAUSE@75..84
0: EQ@75..77 "=" [] [Whitespace(" ")]
1: JS_STRING_LITERAL_EXPRESSION@77..84
0: JS_STRING_LITERAL@77..84 "\"test\"" [] [Whitespace(" ")]
8: R_CURLY@84..85 "}" [] []
3: EOF@85..86 "" [Newline("\n")] []
', crates/rome_js_parser/src/test_utils.rs:53:5
failures:
tests::parser::ok::ts_property_readonly_initializer_ambient_context |
Looks like I am wrong |
@MichaReiser @xunilrj any chance you can help here? |
The issue is that the
I'm not entirely sure how we want to represent this in the AST because where the initializer is allowed is more subtle:
I'm not sure if this isn't just a bug in the typescript compiler as the rules seem a bit arbitrary (in general, my experience when working on the TS parser was that typescript isn't consistent with error messages inside of ambient contexts). |
I am going to make a pr to resolve the missing initialization of TsPropertySignatureClassMember |
I'm not sure if just adding It to It may be worth opening a bug report on the typescript repo to check in if this is the expected behaviour or not. |
This PR is stale because it has been open 14 days with no activity. |
This pull request should not be closed, since it has some upstream blocking #3003, I will have a look this week, last week I was tackling the |
@ematipico , maybe we should diss about the workflow for the stale issue and pull request. |
This issue is solved by #4225 |
Summary
readonly
inTsPropertySignatureClassMember
#2958Test Plan