Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

fix(rome_js_parser): allow readonly property with initializer in ambient context #3000

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions crates/rome_js_parser/src/syntax/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,10 +945,17 @@ fn parse_property_class_member_body(
// test_err ts ts_property_initializer_ambient_context
// declare class A { prop = "test" }
// class B { declare prop = "test" }
p.error(
p.err_builder("Initializers are not allowed in ambient contexts.")
.primary(initializer.range(p), ""),
);
//
// test ts ts_property_readonly_initializer_ambient_context
// declare class A { readonly prop = "test" }
// class B { declare readonly prop = "test" }

if !modifiers.has(ModifierKind::Readonly) {
p.error(
p.err_builder("Initializers are not allowed in ambient contexts.")
.primary(initializer.range(p), ""),
);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare class A { readonly prop = "test" }
class B { declare readonly prop = "test" }