mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(codegen): add new lines to TSTypeParameterDeclaration (#5853)
This commit is contained in:
parent
b9c45646d1
commit
9f6696a6aa
3 changed files with 67 additions and 3 deletions
|
|
@ -2790,9 +2790,29 @@ impl<'a> Gen for TSClassImplements<'a> {
|
||||||
|
|
||||||
impl<'a> Gen for TSTypeParameterDeclaration<'a> {
|
impl<'a> Gen for TSTypeParameterDeclaration<'a> {
|
||||||
fn gen(&self, p: &mut Codegen, ctx: Context) {
|
fn gen(&self, p: &mut Codegen, ctx: Context) {
|
||||||
p.print_str("<");
|
let is_multi_line = self.params.len() >= 2;
|
||||||
p.print_list(&self.params, ctx);
|
p.print_char(b'<');
|
||||||
p.print_str(">");
|
if is_multi_line {
|
||||||
|
p.indent();
|
||||||
|
}
|
||||||
|
for (index, item) in self.params.iter().enumerate() {
|
||||||
|
if index != 0 {
|
||||||
|
p.print_comma();
|
||||||
|
}
|
||||||
|
if is_multi_line {
|
||||||
|
p.print_soft_newline();
|
||||||
|
p.print_indent();
|
||||||
|
} else if index != 0 {
|
||||||
|
p.print_soft_space();
|
||||||
|
}
|
||||||
|
item.print(p, ctx);
|
||||||
|
}
|
||||||
|
if is_multi_line {
|
||||||
|
p.print_soft_newline();
|
||||||
|
p.dedent();
|
||||||
|
p.print_indent();
|
||||||
|
}
|
||||||
|
p.print_char(b'>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -180,3 +180,33 @@ export @x declare abstract class C {}
|
||||||
div<T>``
|
div<T>``
|
||||||
----------
|
----------
|
||||||
div<T>``;
|
div<T>``;
|
||||||
|
|
||||||
|
########## 30
|
||||||
|
export type Component<Props = any> = Foo;
|
||||||
|
----------
|
||||||
|
export type Component<Props = any> = Foo;
|
||||||
|
|
||||||
|
########## 31
|
||||||
|
|
||||||
|
export type Component<
|
||||||
|
Props = any,
|
||||||
|
RawBindings = any,
|
||||||
|
D = any,
|
||||||
|
C extends ComputedOptions = ComputedOptions,
|
||||||
|
M extends MethodOptions = MethodOptions,
|
||||||
|
E extends EmitsOptions | Record<string, any[]> = {},
|
||||||
|
S extends Record<string, any> = any,
|
||||||
|
> =
|
||||||
|
| ConcreteComponent<Props, RawBindings, D, C, M, E, S>
|
||||||
|
| ComponentPublicInstanceConstructor<Props>
|
||||||
|
|
||||||
|
----------
|
||||||
|
export type Component<
|
||||||
|
Props = any,
|
||||||
|
RawBindings = any,
|
||||||
|
D = any,
|
||||||
|
C extends ComputedOptions = ComputedOptions,
|
||||||
|
M extends MethodOptions = MethodOptions,
|
||||||
|
E extends EmitsOptions | Record<string, any[]> = {},
|
||||||
|
S extends Record<string, any> = any
|
||||||
|
> = ConcreteComponent<Props, RawBindings, D, C, M, E, S> | ComponentPublicInstanceConstructor<Props>;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,20 @@ fn ts() {
|
||||||
"d = x satisfies y;",
|
"d = x satisfies y;",
|
||||||
"export @x declare abstract class C {}",
|
"export @x declare abstract class C {}",
|
||||||
"div<T>``",
|
"div<T>``",
|
||||||
|
"export type Component<Props = any> = Foo;",
|
||||||
|
"
|
||||||
|
export type Component<
|
||||||
|
Props = any,
|
||||||
|
RawBindings = any,
|
||||||
|
D = any,
|
||||||
|
C extends ComputedOptions = ComputedOptions,
|
||||||
|
M extends MethodOptions = MethodOptions,
|
||||||
|
E extends EmitsOptions | Record<string, any[]> = {},
|
||||||
|
S extends Record<string, any> = any,
|
||||||
|
> =
|
||||||
|
| ConcreteComponent<Props, RawBindings, D, C, M, E, S>
|
||||||
|
| ComponentPublicInstanceConstructor<Props>
|
||||||
|
"
|
||||||
];
|
];
|
||||||
|
|
||||||
snapshot("ts", &cases);
|
snapshot("ts", &cases);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue