mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
a111b5b340
`packages/codegen` emits invalid TypeScript for abstract accessors with an explicit accessibility modifier. The JavaScript printer writes `abstract` before `public` or `protected`, but TypeScript requires accessibility to come first and reports TS1029 for the generated declaration.
For example, this valid input:
```ts
abstract class C {
public abstract accessor x: number;
protected abstract accessor y: string;
}
```
was printed as:
```ts
abstract class C {
abstract public accessor x: number;
abstract protected accessor y: string;
}
```
The printer now preserves the valid modifier order:
```ts
abstract class C {
public abstract accessor x: number;
protected abstract accessor y: string;
}
```
`printAccessorProperty` now emits accessibility before `abstract`, matching the neighboring method and property printers. The same ordering also handles declarations such as `protected abstract override accessor x: number` and applies to both the ordinary and source-map-enabled builds.
This brings the JavaScript printer in line with the Rust codegen correction in #26392. The change is confined to accessor modifier ordering; subsequent `static`, `override`, and `accessor` emission and source-map anchoring retain their existing behavior.
17 lines
437 B
TypeScript
17 lines
437 B
TypeScript
abstract class C extends B {
|
|
public abstract accessor x: number;
|
|
protected abstract accessor y: string;
|
|
public abstract override accessor z: number;
|
|
protected abstract override accessor w: string;
|
|
abstract accessor a: number;
|
|
}
|
|
|
|
class D extends B {
|
|
public static accessor x = 1;
|
|
protected static accessor y = 1;
|
|
private accessor z = 1;
|
|
public override accessor w = 1;
|
|
accessor #a = 1;
|
|
public accessor b!: number;
|
|
}
|