Node.js can now run a subset of TypeScript without any flags. The subset can be enforced using the tsconfig flag erasableSyntaxOnly. https://www.typescriptlang.org/tsconfig/#erasableSyntaxOnly
Context (Input, Language)
Input Format: any (?)
Output Language: Typescript
Description
Current Behaviour / Output
By default the typescript generator generates enums. This can be dealt with using --prefer-unions flag to quicktype.
However, the converter "classes" have this:
/**
* @schema X
*/
export class X {
public static fromNumber(value: number): X {
return new X(value);
}
public static fromString(value: string): X {
return new X(value);
}
private constructor(public readonly value: number | string) {
}
}
Proposed Behaviour / Output
A better output would be:
/**
* @schema X
*/
export class X {
readonly value: number | string;
public static fromNumber(value: number): X {
return new X(value);
}
public static fromString(value: string): X {
return new X(value);
}
private constructor(value: number | string) {
this.value = value;
}
}
Solution
Maybe add an --erasable-syntax-only and generate compatible code?
Alternatives
Only generate the types...
Node.js can now run a subset of TypeScript without any flags. The subset can be enforced using the tsconfig flag
erasableSyntaxOnly. https://www.typescriptlang.org/tsconfig/#erasableSyntaxOnlyContext (Input, Language)
Input Format: any (?)
Output Language: Typescript
Description
Current Behaviour / Output
By default the typescript generator generates
enums. This can be dealt with using--prefer-unionsflag to quicktype.However, the converter "classes" have this:
Proposed Behaviour / Output
A better output would be:
Solution
Maybe add an
--erasable-syntax-onlyand generate compatible code?Alternatives
Only generate the types...