Hi, how would I type in Kotlin an enum in TS like ...
# javascript
a
Hi, how would I type in Kotlin an enum in TS like this :
Copy code
export enum UPDATE_PRIORITY {
    INTERACTION = 50,
    HIGH = 25,
    NORMAL = 0,
    LOW = -25,
    UTILITY = -50,
}
And a function that have a parameter of this :
Copy code
function test(priority: UPDATE_PRIORITY = UPDATE_PRIORITY.HIGH): void
?
t
You can use Seskar plugin in IR to solve this problem https://github.com/turansky/seskar#int
@Ayfri Works? 🙂
a
No, it says
Infinity
when I use any one 😕
Copy code
@JsUnion
external enum class UPDATE_PRIORITY {
	@JsInt(50)
	INTERACTION,
	
	@JsInt(25)
	HIGH,
	
	@JsInt(0)
	NORMAL,
	
	@JsInt(-25)
	LOW,
	
	@JsInt(-50)
	UTILITY
}
t
Do you have example project or calls?
a
image.png,image.png
t
Do you use Kotlin
1.5.0
?
a
Yes
t
Do you have open project for check?
Do you use IR compiler (required)?
✅ 1
a
The thing if in the
typings/PIXI.kt
file
t
I add some “cleanup” PR-s for start https://github.com/Ayfri/PIXI-Kotlin/pulls
a
Oh thanks, it's my first middle project so I don't know all the conventions on Kotlin/JS ^^
t
It’s not a problem. Don’t stop! 🙂
Do you use IntelliJ IDEA?
a
Yes !
t
a
I installed today Gradle 7.0.2 so I guess that it will be better to modify your PR so it uses Gradle 7 ? ^^
t
As you wish
Wrapper jar/props required for build
gradle
folder ignore - mistake
Untitled.kt
Works fine
Looks like declaration correction required
FYI - Seskar
0.0.10
released
a
Okay thanks, I fixed everything
But when I console.log my ticker, it stills show his
Priority
property as Infinity
image.png
Oh
I'm dumb I guess, when I do it in JS, it always says
Infinity
x)
Sorry to have wasted your time x)
t
I’m dumb I guess, when I do it in JS, it always says 
Infinity
 x)
Possibly it’s property with setter only
1. Pixi typings can be simplified (root object is redundant) 2. Common recomendation - use library specific packages.
pixi
- good package for Pixi declarations 3. You can embed pixi in bundle without (
window
extensions are redundant)
a
1 - In PIXI.js everything is tied to the PIXI namespace (in TypeScript), so how would I do that in Kotlin ? Extensions ? 2 - You're right ! 3 - How ?
t
1 Before
Copy code
package pixi

@JsModule("pixi.js")
external object PIXI {
    class Application
}
After
Copy code
@file:JsModule("pixi.js")

package pixi

external class Application
Separate file will be required for enums 😞
3 • Remove
@JsNonModule
• Use
useCommonJs()
method in JS target for modular build
a
Okay I see, thanks !
Mh when I set
file:JSModule("pixi.js")
it says that I can't use
typealias
and extensions
t
Known redundant limitation Feel free to vote
a
So I guess that I have to move these into another file ?
t
Type aliases works fine with magic annotation
Check required for
1.5.10
a
I'll try
t
Separate file for extensions will be required before fix
a
https://github.com/JetBrains/kotlin/blob/1.5.20-M1/ChangeLog.md If I understand correctly on the JS part, it fixes this no ?
t
Which issue marked as resolved?
t
Looks like other issue
Check required in any case