Vampire
09/15/2024, 2:25 AMdeclare namespace inc {
type IdentifierBase = "0" | "1";
}
results in
external object inc {
sealed external interface IdentifierBase {
companion object {
@seskar.js.JsValue("0")
val `0`: IdentifierBase
@seskar.js.JsValue("1")
val `1`: IdentifierBase
}
}
}
which does not compile due to "Non-top-level 'external' declaration.".
What is the best way to solve this?Sergei Grishchenko
09/15/2024, 9:53 AMpackage
- sub directory with name inc
will be created and all code inside namespace will be put to separate Kotlin package
2. object
- it is what you see now, unfortunately it is buggy 😞 I need to remove external
modifier for such cases
3. ignore
- namespase wrapper will be removed, and generator will just convert body of namespaceSergei Grishchenko
09/15/2024, 9:57 AMobject
strategy? or you need something else?Vampire
09/15/2024, 10:08 AMsemver
in my project, so tried to add it to kotlin-wrappers
now.
In my project I only defined the externals I used.
Now I of course want to provide everything and currently try to make it compile at first and this is the next-to-last compile error I'm having.
The ignore strategy I know how to use, for that there is a nice example in the readme.
So I'm asking more in the context of kotlin-wrappers which best fits in / what is best-practice. :-)Vampire
09/15/2024, 10:10 AMturansky
09/15/2024, 10:12 AMVampire
09/15/2024, 10:12 AMVampire
09/15/2024, 10:13 AMSergei Grishchenko
09/15/2024, 10:32 AM@seskar.js.JsValue
?Sergei Grishchenko
09/15/2024, 10:33 AMturansky
09/15/2024, 10:33 AMturansky
09/15/2024, 10:34 AMturansky
09/15/2024, 10:35 AMSergei Grishchenko
09/15/2024, 10:38 AMnode:test
package and test.ignore(() => ...)
API, Now is is converted as package, but is is not so useful to be honest 🙂. I guess I need to fix it at some moment.Sergei Grishchenko
09/15/2024, 10:38 AMnamespace with simple function namescould you provide example?
Sergei Grishchenko
09/15/2024, 10:44 AMpackage
strategy is better for now. But I won't so sure, if you need to implement something like this inc(...)
and inc.unsafe(...)
.
I am considering this, because I guess TS declaration for such case also will include namespaces:
function inc(...): string | null
namespace inc {
function unsafe(...): string | null
}
turansky
09/15/2024, 11:02 AMpackage
is your strategy. It's strategy for most wrappersturansky
09/15/2024, 11:02 AMVampire
09/15/2024, 1:23 PMpackage
is the proper choice in most cases, why is it not the default? 😄
Ok, so can you point me at an example - e. g. in kotlin-wrappers - how to follow the package
strategy?
Also, I didn't get what Sergei said about inc.unsafe
turansky
09/15/2024, 1:25 PMjs.intl
js.atomics
In declarations both are namespacesturansky
09/15/2024, 1:29 PMturansky
09/15/2024, 1:30 PMSergei Grishchenko
09/15/2024, 1:37 PMkotlin-node/karakum.config.json
, there is namespaceStrategy
section, I guess in you case it should work:
"namespaceStrategy": {
"inc": "package"
}
Vampire
09/15/2024, 10:54 PMoperator: "" | "=" | "<" | ">" | "<=" | ">=";
leads to
/* export = Comparator; */
sealed external interface ComparatorOperator {
companion object {
@seskar.js.JsValue("")
val `_`: ComparatorOperator
@seskar.js.JsValue("=")
val : ComparatorOperator
/*
Duplicated names were generated:
for "<"
for ">"
for "<="
for ">="
*/
}
Which has two major problems.
5 values result in the same property name which is the empty name, and the empty string leads to an underscore as property name.
Is there some similar case already where I can lend some fixup strategy?Sergei Grishchenko
09/16/2024, 3:55 PMkotlin-node/src/jsMain/kotlin/node/path/PlatformPathSep.kt
and kotlin-node/src/jsMain/kotlin/node/path/PlatformPathDelimiter.kt
2. I exclude this files from output, see kotlin-node/karakum.config.json
"ignoreOutput": [
...
"**/path/PlatformPathDelimiter.kt",
...
]
Sergei Grishchenko
09/16/2024, 3:57 PMgenerated
folder for generation output + kotlin
folder for additional APIs and manual customization.Vampire
09/16/2024, 4:41 PMSergei Grishchenko
09/16/2024, 4:44 PMSergei Grishchenko
09/16/2024, 4:49 PM@JsName
Vampire
09/16/2024, 5:51 PMconfiguration
in a plugin?Vampire
09/16/2024, 5:58 PMStringUnionTypePlugin
which is not really a pluginVampire
09/16/2024, 6:06 PMSergei Grishchenko
09/16/2024, 6:52 PMcontext
+ configuration
serviceVampire
09/16/2024, 8:34 PM