Skip to content

Commit 6f5a054

Browse files
authored
fix: AutoAccessor was losing non-null assertion (#588)
1 parent 050808c commit 6f5a054

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/generation/generate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ fn gen_auto_accessor<'a>(node: &AutoAccessor<'a>, context: &mut Context<'a>) ->
474474
is_optional: false,
475475
is_override: false,
476476
readonly: false,
477-
definite: false,
477+
// todo: https://github.com/swc-project/swc/issues/8344
478+
definite: node.type_ann.is_some() && node.key.next_token_fast(context.program).is_some_and(|t| t.token == Token::Bang),
478479
},
479480
context,
480481
)

tests/specs/declarations/class/auto_accessor/AutoAccessor_All.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Person {
66
public static accessor test2 : string;
77
private accessor test3 : string;
88
accessor #test = 2;
9+
accessor here!: string;
910

1011
constructor(name: string) {
1112
this.name = name;
@@ -19,6 +20,7 @@ class Person {
1920
public static accessor test2: string;
2021
private accessor test3: string;
2122
accessor #test = 2;
23+
accessor here!: string;
2224

2325
constructor(name: string) {
2426
this.name = name;

0 commit comments

Comments
 (0)