mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
Minifiers join a derived constructor's statements into one comma expression (`super(message, options), this.name = ..., ...;`), which jose 6.2.12 ships in its error classes. The statement lowering already runs each operand of a statement-level comma as its own statement, so super() is accepted when only parentheses and comma operators separate it from its expression statement. Every other expression position keeps the SC1090 refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
589 B
TypeScript
25 lines
589 B
TypeScript
// super(...) as an operand of a statement-level comma expression compiles
|
|
// (super-comma-sequence.ts). Any other expression position still refuses:
|
|
// the field initializers that run at super() would be misordered.
|
|
class Base {
|
|
constructor(readonly origin: string) {}
|
|
}
|
|
|
|
class Selected extends Base {
|
|
constructor(left: boolean) {
|
|
left ? super("left") : super("right");
|
|
}
|
|
}
|
|
|
|
function keep<T>(value: T): T {
|
|
return value;
|
|
}
|
|
|
|
class Argument extends Base {
|
|
constructor() {
|
|
keep((super("argument"), 1));
|
|
}
|
|
}
|
|
|
|
console.log(new Selected(true).origin, new Argument().origin);
|