I'm currently facing an issue with exporting Kotlin Enum classes to JS.
@OptIn(ExperimentalJsExport::class)
@JsExport
enum class interEnum {
SAMPLE
}
When I import the enum into an Angular Project as an NPM module, the corresponding TS block in module_name.d.ts
throws errors during compilation.
abstract class interEnum { // exported from Kotlin/JS
private constructor();
static get SAMPLE(): com.example.demoapp.interEnum & {
get name(): "SAMPLE";
get ordinal(): 0;
};
static values(): Array<com.example.demoapp.interEnum>;
static valueOf(value: string): com.example.demoapp.interEnum;
get name(): "SAMPLE";
get ordinal(): 0;
}
tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir"": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
}
}
Error from ng serve:
ERROR in demo_app/demo_app.d.ts:286:13 - error TS1131: Property or signature expected.
...
Can someone help me understand these errors? I'm new to JS and TS, and I'm having trouble identifying the issue. The editor isn't showing any errors.
If I remove the get
keywords, the compilation is successful. But I'm unsure why they're causing errors. Any assistance would be greatly appreciated.