@@ -1,4 +1,5 @@
|
|||||||
import type * as Godot from "godot"
|
import type * as Godot from "godot"
|
||||||
|
import type { CamelCase } from "type-fest"
|
||||||
|
|
||||||
|
|
||||||
type NodeClass = {
|
type NodeClass = {
|
||||||
@@ -7,25 +8,23 @@ type NodeClass = {
|
|||||||
: never
|
: never
|
||||||
}[keyof typeof Godot]
|
}[keyof typeof Godot]
|
||||||
|
|
||||||
type DecapitalizeString<S extends string> = S extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : S
|
|
||||||
|
|
||||||
type PropsFromInstance<T> = {
|
type PropsFromInstance<T> = {
|
||||||
// biome-ignore lint/complexity/noBannedTypes: it's completely fine
|
// biome-ignore lint/complexity/noBannedTypes: it's completely fine
|
||||||
[K in keyof T as T[K] extends Function ? never : K]?: T[K]
|
[K in keyof T as T[K] extends Function ? never : K]?: T[K]
|
||||||
}
|
}
|
||||||
|
|
||||||
type GodotIntrinsicElements = {
|
type GodotIntrinsicElements = {
|
||||||
[K in NodeClass as DecapitalizeString<K>]: PropsFromInstance<InstanceType<(typeof Godot)[K]>>
|
[K in NodeClass as CamelCase<K>]: PropsFromInstance<InstanceType<(typeof Godot)[K]>>
|
||||||
} & {
|
} & {
|
||||||
custom: {
|
custom: {
|
||||||
class: new (...args: any[]) => Godot.Node
|
class: new (...args: any[]) => Godot.Node
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// declare global {
|
declare global {
|
||||||
declare namespace React {
|
namespace React {
|
||||||
namespace JSX {
|
namespace JSX {
|
||||||
interface IntrinsicElements extends GodotIntrinsicElements {}
|
interface IntrinsicElements extends GodotIntrinsicElements {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user