File tree 4 files changed +16
-4
lines changed
tests/fixture/typescript/class_prop
4 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -1566,10 +1566,12 @@ where
1566
1566
}
1567
1567
1568
1568
emit ! ( n. key) ;
1569
+
1570
+ if n. is_optional {
1571
+ punct ! ( "?" ) ;
1572
+ }
1573
+
1569
1574
if let Some ( type_ann) = & n. type_ann {
1570
- if n. is_optional {
1571
- punct ! ( "?" ) ;
1572
- }
1573
1575
if n. definite {
1574
1576
punct ! ( "!" ) ;
1575
1577
}
@@ -1635,6 +1637,12 @@ where
1635
1637
1636
1638
emit ! ( n. key) ;
1637
1639
1640
+ // emit for a computed property, but not an identifier already marked as
1641
+ // optional
1642
+ if n. is_optional && !n. key . as_ident ( ) . map ( |i| i. optional ) . unwrap_or ( false ) {
1643
+ punct ! ( "?" ) ;
1644
+ }
1645
+
1638
1646
if let Some ( ty) = & n. type_ann {
1639
1647
if n. definite {
1640
1648
punct ! ( "!" ) ;
Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ class MyClass extends Base {
3
3
prop2 ! : string ;
4
4
#prop3?: string ;
5
5
#prop4?: string = "test" ;
6
+ #privateOptionalNoType?;
6
7
static readonly prop5 ! : string ;
7
8
readonly #prop6 = "asdf" ;
8
9
public abstract override readonly prop7 = 5 ;
9
10
override readonly #prop8 = 5 ;
10
11
declare public static readonly prop9 : string ;
12
+ [ value ] ?: string [ ] ;
11
13
}
Original file line number Diff line number Diff line change @@ -3,9 +3,11 @@ class MyClass extends Base {
3
3
prop2 ! : string ;
4
4
#prop3?: string ;
5
5
#prop4?: string = "test" ;
6
+ #privateOptionalNoType?;
6
7
static readonly prop5 ! : string ;
7
8
readonly #prop6 = "asdf" ;
8
9
public abstract override readonly prop7 = 5 ;
9
10
override readonly #prop8 = 5 ;
10
11
declare public static readonly prop9 : string ;
12
+ [ value ] ?: string [ ] ;
11
13
}
You can’t perform that action at this time.
0 commit comments