yysun/apprun

JSX.IntrinsicElements is missing.

MicahZoltu opened this issue · 2 comments

Trying to return TSX (<div></div>) from a View<State> function results in an error:

JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.ts(7026)

tsconfig.json is setup to compile JSX to react (which matches what I have seen in other projects) but it appears the type definitions are missing. I also setup the "reactNamespace": "app" to match the sample project(s).

Installing @types/react-dom changed the error to

Type 'Element' is not assignable to type 'string | void | VNode | VNode[]'.

because the <div></div> returns a JSX.Element, while View<State> is expected to return a string|void|VNode|VNode[].

yysun commented

I am waiting for a solution from TypeScript.
microsoft/TypeScript#14729

Adding JSX.Element to the acceptable return types of View<T> has made the compiler error go away:

export type View<T> = (state: T, props?: any[]) => string | VNode | VNode[] | JSX.Element | void;