andylamax
09/11/2021, 11:08 AM@file:JsExports
external interface ServiceConfiguration {
var appId: String
var debug: Boolean?
}
fun service(config: ServiceConfiguration)
Yields the following typescript declaration (code out of this context is redacted): [Snippet 2]
type Nullable<T> = T | undefined | null
export interface ServiceConfiguration {
appId: string;
debug: Nullable<boolean> // want this to be optionally provided
}
export function service(config: ServiceConfiguration);
After importing this bundled library in typescript, calling [Snippet 3]
const service = service({ appId: "<app-id>" }) // troubles the ts compiler
The compiler expects both arguments like so [Snippet 4]
const service1 = service({ appId: "<app-id>", debug: undefined }) // ts compiler is happy
const service2 = service({ appId: "<app-id>", debug: true }) // ts compiler still happy
Question is, how do I make the kotlin compiler to generate [Snippet 5]
export interface ServiceConfiguration {
appId: string;
debug?: boolean // want this to be optionally provided
}
instead of the one being generated on [Snippet 2].
So that I may use it as written in [Snippet 3]?andylamax
09/19/2021, 12:08 AM