dukat icon indicating copy to clipboard operation
dukat copied to clipboard

Extending non-external type and extending final type

Open Schahen opened this issue 5 years ago • 2 comments

this code

export interface ReactNodeArray extends Array<string> {}

is translated

external interface ReactNodeArray : Array<String>

Which is pretty straightforward however non-valid in Koltin/JS since we get

[shabunc@shagen demo (master)]$ kotlinc-js minimal.module_demo.kt  -output out.js
minimal.module_demo.kt:18:20: error: external type extends non-external type
external interface ReactNodeArray : Array<String>
                   ^
minimal.module_demo.kt:18:37: error: this type is final, so it cannot be inherited from
external interface ReactNodeArray : Array<String>

Real-life scenario: prop-types

Schahen avatar Sep 19 '19 18:09 Schahen

Are there any work arounds to this issue?

I am trying to use the shopify api but they are putting the cursors for next and prev as non enumerated props onto the page results, my thoughts were to extend array as in your example.

set321go avatar Jun 01 '20 22:06 set321go

Can repro by using the JS MSAL library, getting

External type extends non-external type

due to

external open class ClientAuthError(errorCode: String, errorMessage: String = definedExternally) : AuthError
// AuthError:
typealias AuthError = Error

The Error there is from the Kotlin stdlib

utybo avatar Jan 20 '21 14:01 utybo