Skip to content

Error Importing ES6 Class Extending React.Component into TSX #614

Closed
@alecmerdler

Description

@alecmerdler

Moved from: microsoft/TypeScript#18134

Encountering errors using webpack when importing ES6 classes that extend React.Component into TSX. Entry file is app.jsx.

Compiler outputs working code, and current solution is adding ignoreDiagnostics: [2605, 2607] to ts-loader options in Webpack config.

TypeScript Version: 2.4.2
ts-loader Version: 2.3.4

Code
https://github.com/alecmerdler/tsx-jsx

Expected behavior:

  • tsc with no errors
  • webpack with no errors

Actual behavior:

  • tsc: no errors
  • webpack: error TS2605: JSX element type 'Hello' is not a constructor function for JSX elements. Property 'setState' is missing in type 'Hello'.
    and
    error TS2607: JSX element class does not support attributes because it does not have a 'props' property.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions