mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
feat(codegen): print readonly keyword for TSIndexSignature (#3791)
This commit is contained in:
parent
7d47fc3fcc
commit
2821e0e307
3 changed files with 16 additions and 2 deletions
|
|
@ -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'[');
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
4
crates/oxc_isolated_declarations/tests/fixtures/readonly.ts
vendored
Normal file
4
crates/oxc_isolated_declarations/tests/fixtures/readonly.ts
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export const EMPTY_OBJ: { readonly [key: string]: any } = __DEV__
|
||||
? Object.freeze({})
|
||||
: {}
|
||||
export const EMPTY_ARR: readonly never[] = __DEV__ ? Object.freeze([]) : []
|
||||
|
|
@ -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)[];
|
||||
Loading…
Reference in a new issue