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.ts
declare module "*";

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"