I just found out that there is a wrapper for TypeS...
# javascript
a
I just found out that there is a wrapper for TypeScript that is out on kotlin-wrapperes, if anyone needs it ! https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-typescript
😉 2
K 8
a
I am not sure how I would use this wrapper, can someone give me a use case please?
b
To get "global"
Record<T>
type for example. This then can be used in your public API that you plan to export to your TS consumers.
g
So I could basically write a facade to transform a Kotlin Map to a Typescript Record ? ... that looks awesome 🤩
b
You could do all that without it by just declaring Record external yourself. This is just a convenience and standartization library (for other libs to potential link their public API against)
👍 1
g
Thank you, at least I don't have to redefine them in all projects.
t
My use cases: 1. Splitter/SPA - unlock webpack optimization and generate many ES6 modules from single JS file, generated by Kotlin/JS
1 kt -> n js
1. Converter - from TS to Kotlin cc @Sergei Grishchenko
b
I suspect this might be a stepping stone to finally stabilising dukat, as currently it's generating all the DOM and TS declarations for each dependency instead of linking them to some central library (DOM is already in js stdlib, TS is now under a single umbrella as well)
t
Common
Record
located in
kotlin-extensions
s
To get "global" 
Record<T>
 type for example. T
Please, don't use such generic types from
kotlin-typescript
, it is internal declarations for typescript compiler, these types are needed for infrastructure tasks (static code analysis, code transformations, etc.) For kotlin js stdlib polifiling
kotlin-extensions
module should be used.
🙏 1
b
Why not? Since those externals are in global scope, produced .d.ts files from kotlin lib using them will not contain any imports and will assume global Record existence which ts compiler expects. Am I missing something obvious?
Remember that TS doesn't really have a stdlib, just standard global types. So I'd be surprised if this new kotlin wrappers lib has any js module imports or business logic.
t
kotlin-typescript
- TypeScript compiler declarations (for Node.js only)
Record
from
kotlin-extensions
will be used in future
b
Anyone got a link to those magical kotlin-extensions? Googling just surfaces extension function docs...
Otherwise I see where I was wrong. Typescript
compiler
is the key word here. i.e. it has nothing to do with ts utility types like Record. I'm not at a loss trying to come up with a use case for having such kotlin wrappers.
t
a
But the type of
Record
in
kotlin-extensions
isn't right, as an object in JS can have nullable keys & values
t
Key in nonnulable
b
Also Record there is not even external. WTF?
t
Like
Array
? 🙂
a
Ah okay, I just tested into a JS console , sorry ^^'
s
Am I missing something obvious?
@Big Chungus it seems you mix up internal ts declarations https://github.com/microsoft/TypeScript/blob/main/lib/typescript.d.ts and external (there is external declaration for each release of ECMAScript e. g. https://github.com/microsoft/TypeScript/blob/main/lib/lib.es2015.d.ts) Yea, you are right, there is no stdlib in typescript but typescript has declaration for all browser environment that specified in ECMAScript and you can cofigure what environment your code is executed in, see lib tsconfig option https://www.typescriptlang.org/tsconfig#lib Kotlin has similar staff but unfortunately Kotlin definitions are outdated often, and you cannot configure your environment, that is why we have kotlin-extentions in wrappers