Konyaco
04/26/2022, 10:45 AMimplementation(npm("@types/mojang-gametest", "^0.1.3", generateExternals = true))
implementation(npm("@types/mojang-minecraft", "^0.1.3", generateExternals = true))
implementation(npm("typescript", "^4.4.3"))
implementation(npm("gulp", "^4.0.2"))
implementation(npm("gulp-typescript", "^6.0.0-alpha.1", generateExternals = true))
implementation(npm("del", "^6.0.0"))
Problem 1
Here are excerpts from @types/mojang-minecraft
dependency:
export class MinecraftItemTypes {
static readonly 'air': ItemType;
static readonly 'apple': ItemType;
// ...
static readonly 'item.acaciaDoor': ItemType;
static readonly 'item.bed': ItemType;
}
There are some fields which have a .
in their name. And they are converted to:
external open class MinecraftItemTypes {
companion object {
var item.acaciaDoor: ItemType
var item.bed: ItemType
var item.beetroot: ItemType
}
}
They can not be compiled, should they be converted like this?
var `item.acaciaDoor`: ItemType
Also, the TS uses readonly
keyword, I'm not familiar with TypeScript, may be it should be converted to val
?
Problem 2
There are some fields, store a literal value:
export class BlockProperties {
static readonly 'active' = 'active';
static readonly 'color' = 'color';
static readonly 'direction' = 'direction';
// ...
}
They are converted to:
external open class BlockProperties {
companion object {
var active: Any = "active"
var color: Any = "color"
var direction: Any = "direction"
}
}
They are reported wrong with Wrong initializer of external declaration. Must be ' = definedExternally'
In addition, is it possible to infer the type String
?
val active: String = definedExternally
Are these bugs? How can I deal with them?🤔turansky
04/26/2022, 10:59 AMMinecraftItemTypes
external object MinecraftItemTypes {
val air: ItemType
val apple: ItemType
}
inline val MinecraftItemTypes.itemBed: ItemType
get() = asDynamic()["item.bed"]
2. BlockProperties
In IR you can use Seskar unions or write declarations like generated (works in all platforms)Konyaco
04/26/2022, 2:15 PMturansky
04/26/2022, 6:34 PMIt’s troublesome to manually process them...You can use Seskar 🙂
turansky
04/26/2022, 6:34 PMephemient
04/26/2022, 11:58 PMKonyaco
04/27/2022, 12:08 AM