mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(codegen): print some missing typescript attributes (#3980)
This commit is contained in:
parent
dc6d45e2e6
commit
dac617de29
2 changed files with 23 additions and 0 deletions
|
|
@ -2095,6 +2095,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for Class<'a> {
|
|||
if let Some(id) = &self.id {
|
||||
p.print_hard_space();
|
||||
id.gen(p, ctx);
|
||||
if let Some(type_parameters) = self.type_parameters.as_ref() {
|
||||
type_parameters.gen(p, ctx);
|
||||
}
|
||||
}
|
||||
if let Some(super_class) = self.super_class.as_ref() {
|
||||
p.print_str(b" extends ");
|
||||
|
|
@ -2444,6 +2447,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for PropertyDefinition<'a> {
|
|||
if self.r#static {
|
||||
p.print_str(b"static ");
|
||||
}
|
||||
if self.readonly {
|
||||
p.print_str(b"readonly ");
|
||||
}
|
||||
if self.computed {
|
||||
p.print(b'[');
|
||||
}
|
||||
|
|
@ -2818,6 +2824,10 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for TSMappedType<'a> {
|
|||
p.print_str(b" = ");
|
||||
default.gen(p, ctx);
|
||||
}
|
||||
if let Some(name_type) = &self.name_type {
|
||||
p.print_str(b" as ");
|
||||
name_type.gen(p, ctx);
|
||||
}
|
||||
p.print_str(b"]");
|
||||
match self.optional {
|
||||
TSMappedTypeModifierOperator::True => {
|
||||
|
|
@ -3255,6 +3265,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for TSTupleElement<'a> {
|
|||
impl<'a, const MINIFY: bool> Gen<MINIFY> for TSNamedTupleMember<'a> {
|
||||
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
|
||||
self.label.gen(p, ctx);
|
||||
if self.optional {
|
||||
p.print_str(b"?");
|
||||
}
|
||||
p.print_str(b":");
|
||||
p.print_soft_space();
|
||||
self.element_type.gen(p, ctx);
|
||||
|
|
|
|||
|
|
@ -189,6 +189,16 @@ fn typescript() {
|
|||
"export { Foo, type Bar } from 'foo';\n",
|
||||
false,
|
||||
);
|
||||
test_ts(
|
||||
"type A<T> = { [K in keyof T as K extends string ? B<K> : K ]: T[K] }",
|
||||
"type A<T> = { [K in keyof T as K extends string ? B<K> : K] : T[K]};\n",
|
||||
false,
|
||||
);
|
||||
test_ts(
|
||||
"class A {readonly type = 'frame'}",
|
||||
"class A {\n\treadonly type = 'frame';\n}\n",
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
fn test_comment_helper(source_text: &str, expected: &str) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue