Fix
Lint / lint (push) Successful in 53s

This commit is contained in:
Julien Valverdé
2026-05-12 02:00:55 +02:00
parent 56ff7ae3a4
commit 71d1442926
+25 -17
View File
@@ -11,7 +11,7 @@ export type ComponentTypeId = typeof ComponentTypeId
* Represents an Effect-based React Component that integrates the Effect system with React. * Represents an Effect-based React Component that integrates the Effect system with React.
*/ */
export interface Component<P extends {}, A extends React.ReactNode, E, R, F extends Component.Signature> export interface Component<P extends {}, A extends React.ReactNode, E, R, F extends Component.Signature>
extends ComponentPrototype<P, R, F>, ComponentOptions { extends ComponentPrototype<R, F>, ComponentOptions {
new(_: never): Record<string, never> new(_: never): Record<string, never>
readonly [ComponentTypeId]: ComponentTypeId readonly [ComponentTypeId]: ComponentTypeId
readonly "~Props": P readonly "~Props": P
@@ -40,27 +40,22 @@ export declare namespace Component {
} }
export interface ComponentPrototype<P extends {}, R, F extends Component.Signature> export interface ComponentImpl<P extends {}, A extends React.ReactNode, E, R, F extends Component.Signature>
extends Pipeable.Pipeable { extends Component<P, A, E, R, F>, ComponentImplPrototype<R, F> {}
readonly [ComponentTypeId]: ComponentTypeId
export interface ComponentImplPrototype<R, F extends Component.Signature> {
readonly use: Effect.Effect<F, never, Exclude<R, Scope.Scope>> readonly use: Effect.Effect<F, never, Exclude<R, Scope.Scope>>
asFunctionComponent( asFunctionComponent(runtimeRef: React.Ref<Runtime.Runtime<Exclude<R, Scope.Scope>>>): F
runtimeRef: React.Ref<Runtime.Runtime<Exclude<R, Scope.Scope>>> setFunctionComponentName(f: F): void
): F transformFunctionComponent(f: F): F
setFunctionComponentName(f: React.FC<P>): void
transformFunctionComponent(f: React.FC<P>): React.FC<P>
} }
export const ComponentPrototype: ComponentPrototype<any, any, any> = Object.freeze({ export const ComponentImplPrototype: ComponentImplPrototype<any, any> = Object.freeze({
[ComponentTypeId]: ComponentTypeId,
...Pipeable.Prototype,
get use() { return use(this) }, get use() { return use(this) },
asFunctionComponent<P extends {}, A extends React.ReactNode, E, R, F extends Component.Signature>( asFunctionComponent<P extends {}, A extends React.ReactNode, E, R, F extends Component.Signature>(
this: Component<P, A, E, R, F>, this: ComponentImpl<P, A, E, R, F>,
runtimeRef: React.RefObject<Runtime.Runtime<Exclude<R, Scope.Scope>>>, runtimeRef: React.RefObject<Runtime.Runtime<Exclude<R, Scope.Scope>>>,
) { ) {
return (props: P) => Runtime.runSync(runtimeRef.current)( return (props: P) => Runtime.runSync(runtimeRef.current)(
@@ -72,7 +67,7 @@ export const ComponentPrototype: ComponentPrototype<any, any, any> = Object.free
}, },
setFunctionComponentName<P extends {}, A extends React.ReactNode, E, R, F extends Component.Signature>( setFunctionComponentName<P extends {}, A extends React.ReactNode, E, R, F extends Component.Signature>(
this: Component<P, A, E, R, F>, this: ComponentImpl<P, A, E, R, F>,
f: React.FC<P>, f: React.FC<P>,
) { ) {
f.displayName = this.displayName ?? "Anonymous" f.displayName = this.displayName ?? "Anonymous"
@@ -82,7 +77,7 @@ export const ComponentPrototype: ComponentPrototype<any, any, any> = Object.free
} as const) } as const)
const use = Effect.fnUntraced(function* <P extends {}, A extends React.ReactNode, E, R, F extends Component.Signature>( const use = Effect.fnUntraced(function* <P extends {}, A extends React.ReactNode, E, R, F extends Component.Signature>(
self: Component<P, A, E, R, F> self: ComponentImpl<P, A, E, R, F>
) { ) {
// biome-ignore lint/style/noNonNullAssertion: React ref initialization // biome-ignore lint/style/noNonNullAssertion: React ref initialization
const runtimeRef = React.useRef<Runtime.Runtime<Exclude<R, Scope.Scope>>>(null!) const runtimeRef = React.useRef<Runtime.Runtime<Exclude<R, Scope.Scope>>>(null!)
@@ -101,6 +96,19 @@ const use = Effect.fnUntraced(function* <P extends {}, A extends React.ReactNode
}) })
export interface ComponentPrototype<R, F extends Component.Signature>
extends Pipeable.Pipeable {
readonly [ComponentTypeId]: ComponentTypeId
readonly use: Effect.Effect<F, never, Exclude<R, Scope.Scope>>
}
export const ComponentPrototype: ComponentPrototype<any, any> = Object.freeze({
[ComponentTypeId]: ComponentTypeId,
...Pipeable.Prototype,
...ComponentImplPrototype,
} as const)
export interface ComponentOptions { export interface ComponentOptions {
/** /**
* Custom display name for the component in React DevTools and debugging utilities. * Custom display name for the component in React DevTools and debugging utilities.