<@U01JRLZH77T> <@U33H6SB2B> Can you help with type...
# javascript
s
@hfhbd @turansky Can you help with types-kotlin generator? I have a problem that nodejs wrappers generated with incorrect interfaces. For example
Copy code
suspend fun readdir(
    path: PathLike,
    options: ObjectEncodingOptions,
    /* {
            withFileTypes: true;
        } */
): ReadonlyArray<Dirent> =
    readdirAsync(
        path = path,
        options = options,
    ).await()
https://github.com/JetBrains/kotlin-wrappers/blob/master/kotlin-node/src/jsMain/generated/node/fs/readdir.kt has arg "options" with interface "ObjectEncodingOptions" uses
Copy code
@JsName("readdir")
external fun readdirAsync(
    path: PathLike,
    options: ObjectEncodingOptions,
    /* {
            withFileTypes: true;
        } */
): Promise<ReadonlyArray<Dirent>>
that also has arg "options" with interface and commented field withFileTypes
Copy code
sealed external interface ObjectEncodingOptions {
    var encoding: node.buffer.BufferEncoding?
}
https://github.com/JetBrains/kotlin-wrappers/blob/master/kotlin-node/src/jsMain/generated/node/fs/readdirAsync.kt and nodejs types has more complete interface with option withFileTypes and recursive
Copy code
function readdir(
        path: PathLike,
        options?:
            | (ObjectEncodingOptions & {
                  withFileTypes?: false | undefined;
                  recursive?: boolean | undefined;
              })
            | BufferEncoding
            | null
    ): Promise<string[]>;
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/fs/promises.d.ts#L258 I need option.withFileTypes to receive Dirent instead Strings and looks like it should be default for this function implementation, because in another case it returns string and throw error when I'm trying to call "isFIle" function By the way, it works nice when I'm using it like this:
Copy code
val files: ReadonlyArray<Dirent> = readdir("...", object {
            @JsName("withFileTypes")
            val withFileTypes = true
        } as ObjectEncodingOptions)
t
Custom local extended copy expected in this case (for start)
s
That's exactly what I did But how can I help generator project fix this?
t
We want to avoid duplication in such cases Best help - analytics, where: 1. “options” classes will be described and grouped 2. Duplicates will be highlighted 3. Names or name calculation logic will be suggested