we cannot compile jsx if we provide noImplicitAny option.
https://github.com/Microsoft/TypeScript/commit/fe4612273ccc2017cfec598521eec5ce30bbd4dc
tsc test.tsx --jsx react --noImplicitAny
<div>test</div>
test.tsx(1,1): error TS2602: JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist.
test.tsx(1,1): error TS7026: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists
Success the compilation if we provide noImplicitAny option.
Of course, this will be success if we don't provide noImplicitAny option.
As the errors say:
because the global type 'JSX.Element' does not exist.
and
because no interface 'JSX.IntrinsicElements' exists
If you want to compile JSX files without implicit any errors, you can define those types:
declare namespace JSX {
interface Element { }
interface IntrinsicElements { div: any; }
}
I recommend getting the react-jsx.d.ts file from DefinitelyTyped
aha. Thank you!
Got bitten by this, but now react-jsx.d.ts doesn't exists on DefinitelyTyped. Currently the options seems to be:
typings install react
JSX definition was REMOVEDtypings install dt~react --global
JSX definitionnpm install @types/react
JSX definition@nahuel not REMOVED, just not yet 'ported'. Glad to iterate on it if you wouldn't mind opening an issue for it. Or feel free to make a PR. Won't take much to make it external module friendly.
I'll get right to it when I get back this weekend from traveling.
Most helpful comment
Got bitten by this, but now
react-jsx.d.tsdoesn't exists on DefinitelyTyped. Currently the options seems to be:typings install react
JSXdefinition was REMOVEDtypings install dt~react --global
JSXdefinitionnpm install @types/react
JSXdefinition