Skip to content

Commit

Permalink
fix(es/codegen): Ensure decorators are emitted first in TS paramters (#…
Browse files Browse the repository at this point in the history
…9545)

**Related issue:**

- Closes #9543
  • Loading branch information
magic-akari authored Sep 11, 2024
1 parent 6137b89 commit 47ef38d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
6 changes: 2 additions & 4 deletions crates/swc_ecma_codegen/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export class A {
constructor(
@IInstantiationService protected readonly _instantiationService: IInstantiationService,
@IContainerService private readonly _containerService: IContainerService,
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export class A {
constructor(
@IInstantiationService
protected readonly _instantiationService: IInstantiationService,
@IContainerService
private readonly _containerService: IContainerService){}
}
Original file line number Diff line number Diff line change
@@ -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){}
}

0 comments on commit 47ef38d

Please sign in to comment.