Writing types for a function with a different signature in NodeJS

129 views Asked by At

I would like to write some types for hypernova-react but unfortunately it has a different type signature on the client and the server. For the client, the types are:

export function renderReact<C extends React.ComponentType>(name: string, component: C): C;

export function renderReactStatic(name: string, component: React.ComponentType): void;

while on the server they are

export function renderReact<C extends React.ComponentType>(
    name: string,
    component: C
): (props: React.ComponentProps<C>) => string;

export function renderReactStatic<C extends React.ComponentType>(
    name: string,
    component: C
): (props: React.ComponentProps<C>) => string;

How do I handle this? I can't see anything in the typescript docs for checking if window is defined in a type guard.

0

There are 0 answers