Closed wangito33 closed 3 months ago
Difficult to say without the code
swig -c++ -javascript -napi -typescript -module enumclass seniority.h
produces the typescript file below:
declare const _SWIG_enum_tag: unique symbol;
export const Seniority_Senior: Seniority;
export const Seniority_Subordinated: Seniority;
export const Seniority_SeniorSubordinated: Seniority;
export const Seniority_Max: Seniority;
export type Seniority = number & { readonly [_SWIG_enum_tag]: 'Seniority'; };
I don't see the problem with this output?
This is not that readable. Didn't try with vs code to see if it integrates well. I currently use the -node -tstypes option which wraps the enum to typescript enum. It has its own problem, but is easy to read and use.
Oh, you prefer TypeScript enums. It is not possible - TypeScript enums exist only in TypeScript - they disappear once the code is transpiled to JavaScript. If SWIG was producing TypeScript enums, those wouldn't have been usable from JavaScript.
OK. Thank you for having looked at it. It is indeed better to use union type with typescript.
The improvement on js support is great. I'm just wondering why C++ enum is not wrapped in enum typescript.