Fix JSX types
Some checks failed
Lint / lint (push) Failing after 9s

This commit is contained in:
Julien Valverdé
2025-12-28 23:53:22 +01:00
parent 0c642b655e
commit 945ef34829

View File

@@ -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 {}
} }
} }
// } }