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

This commit is contained in:
Julien Valverdé
2025-12-29 23:52:39 +01:00
parent bd31fd5ea4
commit 5dd051ce71
5 changed files with 39 additions and 26 deletions

View File

@@ -1,17 +1,25 @@
import { Control } from "godot" import { Control, Label } from "godot"
import { Node } from "react-godot-renderer" import { Component } from "react-godot-renderer"
const ControlFC = Component.make(Control)
const LabelFC = Component.make(Label)
export function TestUi1Component() { export function TestUi1Component() {
return ( return (
<Node <ControlFC
class={Control} name="Root"
anchor_left={0} anchor_left={0}
/> anchor_top={0}
anchor_right={0}
anchor_bottom={0}
>
<LabelFC
name="Label"
text="This is a label"
/>
<node2D name="Issou" />
</ControlFC>
) )
} }
Node({
class: Control,
})

View File

@@ -0,0 +1,15 @@
import type * as Godot from "godot"
import * as React from "react"
import type * as JSX from "./JSX.js"
export type Props<T extends Godot.Node> = JSX.PropsFromInstance<T>
export type Component<T extends Godot.Node> = React.FunctionComponent<Props<T>>
export const make = <T extends Godot.Node>(
class_: new (...args: any[]) => T
): Component<T> => {
const f = (props: Props<T>) => React.createElement("element", { ...props, class: class_ })
f.displayName = class_.name
return f
}

View File

@@ -17,7 +17,7 @@ export type GodotIntrinsicElements = {
} }
export type PropsFromInstance<T> = { export type PropsFromInstance<T> = {
// biome-ignore lint/complexity/noBannedTypes: it's completely fine // biome-ignore lint/complexity/noBannedTypes: using Function here is 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]
} }
@@ -25,6 +25,10 @@ declare global {
namespace React { namespace React {
namespace JSX { namespace JSX {
interface IntrinsicElements extends GodotIntrinsicElements {} interface IntrinsicElements extends GodotIntrinsicElements {}
interface IntrinsicAttributes {
children?: React.ReactNode
name?: string
}
} }
} }
} }

View File

@@ -1,14 +0,0 @@
import type * as Godot from "godot"
import * as React from "react"
import type * as JSX from "./JSX.js"
export type NodeProps<T extends Godot.Node> = {
readonly class: new (...args: any[]) => T
} & JSX.PropsFromInstance<NoInfer<T>>
export function Node<T extends Godot.Node>(
props: NodeProps<T>
): React.JSX.Element {
return React.createElement("element", props)
}

View File

@@ -1,4 +1,4 @@
export * as Component from "./Component.js"
export * as JSX from "./JSX.js" export * as JSX from "./JSX.js"
export * from "./Node.js"
export * as Reconciler from "./Reconciler.js" export * as Reconciler from "./Reconciler.js"
export * as Renderer from "./Renderer.js" export * as Renderer from "./Renderer.js"