Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3025,8 +3025,7 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for TSSignature<'a> {
Self::TSIndexSignature(signature) => signature.gen(p, ctx),
Self::TSPropertySignature(signature) => {
if signature.readonly {
p.print_str(b"readonly");
p.print_hard_space();
p.print_str(b"readonly ");
}
if signature.computed {
p.print(b'[');
Expand Down Expand Up @@ -3191,6 +3190,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for TSTypeParameterInstantiation<'a> {

impl<'a, const MINIFY: bool> Gen<MINIFY> for TSIndexSignature<'a> {
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
if self.readonly {
p.print_str(b"readonly ");
}
p.print_str(b"[");
for (index, parameter) in self.parameters.iter().enumerate() {
if index != 0 {
Expand Down
4 changes: 4 additions & 0 deletions crates/oxc_isolated_declarations/tests/fixtures/readonly.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const EMPTY_OBJ: { readonly [key: string]: any } = __DEV__
? Object.freeze({})
: {}
export const EMPTY_ARR: readonly never[] = __DEV__ ? Object.freeze([]) : []
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/readonly.ts
---
==================== .D.TS ====================

export declare const EMPTY_OBJ: {readonly [key: string]: any};
export declare const EMPTY_ARR: readonly (never)[];