Problem with generated d.ts. file

Dear all,
I am trying to export kotlin files to using it as ts.

However, after build and generate all files (package.json, d.ts and js), error occurred when I try to use d.ts file

Example interface is:

@JsExport
interface AdditionalDataAPI {
    fun getAdditionalData(dataType: Int): Any?
    fun getAdditionalDataList(dataType: Int): List<*>?
    fun getAdditionalDataAsync(dataType: Int, callback: AsyncDataReceiver<*>?)
    fun getAdditionalDataListAsync(dataType: Int, callback: AsyncDataReceiver<List<*>?>?)
}

after build, these interface became

export namespace api {
    interface AdditionalDataAPI {
        getAdditionalData(dataType: number): Nullable<any>;
        getAdditionalDataList(dataType: number): Nullable<kotlin.collections.List<any /*UnknownType **/>>;
        getAdditionalDataAsync(dataType: number, callback: Nullable<listeners.AsyncDataReceiver<any /*UnknownType **/>>): void;
        getAdditionalDataListAsync(dataType: number, callback: Nullable<listeners.AsyncDataReceiver<Nullable<kotlin.collections.List<any /*UnknownType **/>>>>): void;
    }
}

Why “Unknown type” shows up ? Why kotlin.collections.List is not recognized ?

Setting in gradle.kts is

js(IR) {
        browser {
            commonWebpackConfig {
                cssSupport.enabled = true
            }
        }
        binaries.library()
    }

Thanks for help

Hi there,

The Unknown type is your star generic type, not the kotlin.collections.List.

Yes, maybe you’re right. but the error says

{
“resource”: …filename.d.ts",
“owner”: “typescript”,
“code”: “2503”,
“severity”: 8,
“message”: “Cannot find namespace ‘kotlin’.”,
“source”: “ts”,
“startLineNumber”: 50,
“startColumn”: 59,
“endLineNumber”: 50,
“endColumn”: 65
}

Is there any fix for this ?

It can not find any class or interface inside kotlin

This is because Kotlin types are not @JsExport ed, which means the typescript type generation won’t add them and you get unresolved symbols, there is not really a way around that apart from just ignoring the kotlin namespace by putting declare const kotlin:any; in your typescript project