Skip to content Skip to sidebar Skip to footer

React: Using Es6 Component In Ts Component: Ts2605: Jsx Element Type 'xxx' Is Not A Constructor Function For Jsx Elements

I want to use an ES6 React component in another Typescript component. The ES6 component: class ModelViewer extends Component { constructor(props, context) { super(props, con

Solution 1:

As a kind of brute force method I satisfied the Typescript compiler using a custom typings file.

// typings/custom.d.tsdeclaremodule"*";

And tell the compiler in my tsconfig.json to read my custom typings:

// tsconfig.json{"compilerOptions":{"module":"commonjs","target":"es5","noImplicitAny":false,"removeComments":true,"sourceMap":true,"allowJs":true,"watch":true,"outDir":"./dist/","jsx":"react","experimentalDecorators":true,"allowSyntheticDefaultImports":true,"typeRoots":["./typings","node_modules/@types"]}}

Post a Comment for "React: Using Es6 Component In Ts Component: Ts2605: Jsx Element Type 'xxx' Is Not A Constructor Function For Jsx Elements"