andylamax
12/01/2023, 7:07 PM@JsExport
rendering the whole stack's types as any when exposed to typescript. I deeply request @turansky if it is not too much effort, can we mark all external kotlin/js declarations with @JsExport
so that us library authors who write kotlin libs to be used in typescript also benefit from the stack??? If there is a downside to this request, can you please enlighten me???ian.shaun.thomas
12/01/2023, 8:25 PMturansky
12/01/2023, 9:03 PM@JsExport
It looks like duplication of existed TS declarationturansky
12/01/2023, 9:09 PMIf there is a downside to this request, can you please enlighten me???There is no direct mapping between TS and Kotlin/JS declarations.
andylamax
12/02/2023, 12:11 AMIt looks like duplication of existed TS declaration
Yes and no, because, if I export a ReadonlyArray<String> they type is defined as any (coz ReadonlyArrray) is not marked with @JsExport. While the types are almost Identical, we miss the definitions in the final .d.ts file. hence this request to you
andylamax
12/02/2023, 12:14 AM@JsExport
) in helping us library devs whom our targeted consumers are TS developersturansky
12/02/2023, 2:52 AMYes and no, because, if I export a ReadonlyArray<String> they type is defined as any (coz ReadonlyArrray) is not marked with @JsExport.Will it work with
@JsExport
? 😉turansky
12/02/2023, 2:56 AMI feel like you logically can't say "it looks like a duplication of existed TS" and then follow up with the statement "There is no direct mapping..."I expect invalid and non-compatible copies of TS types
turansky
12/02/2023, 2:58 AMandylamax
12/02/2023, 7:50 AMWill it work with@JsExport?
Yes, for two reasons. 1. The fact that typescript type system is structural and instance based assures that it will work 2. I have done some attempts and duplicated some of the definitions from kotlin-wrappers with success. Catch is, I didn't duplicate everything just the stuff I needed and it seem to work
andylamax
12/02/2023, 7:52 AMI expect invalid and non-compatible copies of TS and Types
Thats the beauty of typescript interfaces, they merge on collisions and again the types are validated through a structural approach
andylamax
12/02/2023, 7:58 AMAnd what we should do with external interfaces with the same name??
This is an actual roadblock if one is using
useEsModule()
, coz the complier exports things in a flat structure
But using other types, i.e. umd, the typescript definitions are being spitted out in their respective namespace which does match with the package itself
But since this is a already a problem to whoever uses esModules, the impact of exporting external declarations will be non existent.
Also, users who aren't interested in exported declaration have been already opted by default with the kotlin compiler plugin. So, yes to @JsExport
andylamax
12/02/2023, 7:59 AMturansky
12/02/2023, 9:27 AMturansky
12/02/2023, 9:36 AMandylamax
12/02/2023, 11:58 AMturansky
12/02/2023, 12:08 PM