Fix
Some checks failed
Lint / lint (push) Failing after 10s

This commit is contained in:
Julien Valverdé
2026-01-01 20:18:09 +01:00
parent 45f84810b5
commit 84c83c1bef
3 changed files with 64 additions and 13 deletions

View File

@@ -2,21 +2,37 @@ import type * as Godot from "godot"
import * as React from "react"
export type Component<T extends Godot.Node<Godot.NodePathMap>> = React.FunctionComponent<Props<T>>
export interface Component<T extends Godot.Node<Godot.NodePathMap>>
extends React.FunctionComponent<Props<T>>, Prototype<T> {}
export type Props<T extends Godot.Node<Godot.NodePathMap>> = {
readonly ref?: React.RefObject<T | null>
} & {
// biome-ignore lint/complexity/noBannedTypes: using Function here is completely fine
[K in keyof T as T[K] extends Function ? never : K]?: T[K]
}
export interface InstrinsicAttributes {
export interface Prototype<T extends Godot.Node<Godot.NodePathMap>> {
useRef(): React.RefObject<T | null>
useUnsafeRef(): React.RefObject<T>
}
export interface InstrinsicAttributes extends React.Attributes {
readonly children?: React.ReactNode
readonly name?: string
}
export const Prototype: Prototype<any> = {
useRef() { return React.useRef(null) },
useUnsafeRef() { return React.useRef(null) },
}
export const make = <T extends Godot.Node<Godot.NodePathMap>>(
class_: new (...args: any[]) => T
): Component<T> => {
const f = (props: Props<T>) => React.createElement("element", { ...props, class: class_ })
f.displayName = class_.name
return f
}
): Component<T> => Object.setPrototypeOf(
Object.assign(
(props: Props<T>) => React.createElement("element", { ...props, class: class_ }),
{ displayName: class_.name },
),
Prototype,
)

View File

@@ -19,7 +19,7 @@ export const renderComponent: {
} = (
container: Node<NodePathMap>,
component: React.FC<{}>,
props?: React.Attributes,
props?: Record<string, unknown>,
): void => {
const reconciler = Reconciler.make()