Hi, what should be the type of an optional propert...
# javascript
a
Hi, what should be the type of an optional property of an external interface ?
a
Give it a default value
Copy code
external fun optionFunction(optionalArg: String = definedExternally)
a
Not an argument, a property,
Copy code
interface CompressedTextureExtensions {
    s3tc: WEBGL_compressed_texture_s3tc?
}
t
Copy code
external interface CompressedTextureExtensions {
    var s3tc: WEBGL_compressed_texture_s3tc?
}
a
Just nullable type ? I've seen in dukat generations that they set
definedExternally
getters/setters for optional properties 🤔
t
You can add it if you need more code with same result 🙂
Single (legal) case for
definedExternally
, where it’s really required - function parameters
a
Ah okay I see, and if a property in TS has the type
String | null
it's also
String?
in Kotlin I guess ?
a
Yes a
String | null
is
String?
in kotlin
b
Nullable types with default getter and setter implementations via definedExternally
Benefit of doing it this way is that you are bot forced to override them when implementing said interface