0

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.

Lexi
  • 1,670
  • 1
  • 19
  • 35
  • 1
    Typescript can do nothing with runtime stuff, types even do not exist there. So you can define separate namespaces for server and client types like `@types/hypernova-react/server` and `@types/hypernova-react/client` for example. – Shlang Apr 06 '20 at 23:08
  • How would I then make that apply to `import { renderReact } from "hypernova-react"`? – Lexi Apr 07 '20 at 09:33

0 Answers0