fix(es/codegen): Ensure decorators are emitted first in TS paramters (#9545)

**Related issue:**

- Closes https://github.com/swc-project/swc/issues/9543
This commit is contained in:
magic-akari 2024-09-11 10:47:37 +08:00 committed by GitHub
parent 6137b897aa
commit 47ef38dc1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 6 deletions

View File

@ -688,11 +688,9 @@ where
fn emit_ts_param_prop(&mut self, n: &TsParamProp) -> Result {
self.emit_leading_comments_of_span(n.span(), false)?;
self.emit_accessibility(n.accessibility)?;
self.emit_list(n.span, Some(&n.decorators), ListFormat::Decorators)?;
for dec in &n.decorators {
emit!(dec);
}
self.emit_accessibility(n.accessibility)?;
if n.is_override {
keyword!("override");

View File

@ -0,0 +1,7 @@
export class A {
constructor(
@IInstantiationService protected readonly _instantiationService: IInstantiationService,
@IContainerService private readonly _containerService: IContainerService,
) {
}
}

View File

@ -0,0 +1,7 @@
export class A {
constructor(
@IInstantiationService
protected readonly _instantiationService: IInstantiationService,
@IContainerService
private readonly _containerService: IContainerService){}
}

View File

@ -1,6 +1,8 @@
import { field__2 } from "../validation/decorators";
class C__2 {
constructor(@field__2("a")
readonly field__3: string, @field__2("b")
constructor(
@field__2("a")
readonly field__3: string,
@field__2("b")
readonly b__3: string){}
}