Skip to content

Commit 6c03e20

Browse files
authored
fix(ts/fast-dts): Emit readonly for Object getter prop (#10492)
**Related issue:** - Closes #10491
1 parent d2468f1 commit 6c03e20

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

.changeset/fair-ghosts-glow.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_core: patch
3+
swc_typescript: patch
4+
---
5+
6+
fix(typescript/dts): Emit `readonly` for Object getter prop

crates/swc_typescript/src/fast_dts/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl FastDts {
196196
let (key, computed) = self.transform_property_name_to_expr(&getter.key);
197197
members.push(TsTypeElement::TsPropertySignature(TsPropertySignature {
198198
span: DUMMY_SP,
199-
readonly: is_const,
199+
readonly: true,
200200
key: Box::new(key),
201201
computed,
202202
optional: false,

crates/swc_typescript/tests/fixture/symbol-properties.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export declare const foo: {
55
[Symbol.iterator]: () => void;
66
[Symbol.asyncIterator]: () => Promise<void>;
77
[globalThis.Symbol.iterator]: () => void;
8-
[Symbol.toStringTag]: string;
8+
readonly [Symbol.toStringTag]: string;
99
};
1010
export declare abstract class Foo {
1111
[Symbol.iterator](): void;

0 commit comments

Comments
 (0)