-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Error Importing ES6 Class Extending React.Component into TSX #18134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
React declaration file changed to give props and state a default of |
I figured the problem was with What solutions do you suggest other than modifying the typings? Adding |
as a workaround, you can add /** @augments {React.Component<object, object>} */
export class Hello extends React.Component {
...
} |
I've updated the repo with |
c:\test\18134\tsx-jsx>type app.jsx
import * as React from 'react';
import { FooBar } from './index';
const App = (props) => {
return <FooBar />
};
c:\test\18134\tsx-jsx>type hello.jsx
import * as React from 'react';
/** @augments {React.Component<object, object>} */
export class Hello extends React.Component {
render() {
return <div>{this.props.baz}</div>;
}
}
c:\test\18134\tsx-jsx>type index.tsx
import * as React from 'react';
import { Hello } from './hello';
export const FooBar = (props) => {
return <Hello baz={null}>
<div />
</Hello>;
};
c:\test\18134\tsx-jsx>type tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"jsx": "react",
"allowJs": true,
"lib": ["dom", "es2015"],
"pretty": true,
"outDir": "dist",
"sourceMap": true
},
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.jsx"
],
"exclude": [
"node_modules"
]
}
c:\test\18134\tsx-jsx>tsc --v
Version 2.5.1
c:\test\18134\tsx-jsx>tsc --noEmit
c:\test\18134\tsx-jsx>echo %ERRORLEVEL%
0
|
The issue seems to be with |
Encountering errors using both
tsc
andwebpack
when importing ES6 classes that extendReact.Component
into TSX. Entry file isapp.jsx
.Compiler outputs working code, and current solution is adding
ignoreDiagnostics: [2605, 2607]
tots-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 errorswebpack
with no errorsActual behavior:
error TS2339: Property 'className' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Hello> & Readonly<{ children?: ReactNode; }> & Rea...'.
error TS2607: JSX element class does not support attributes because it does not have a 'props' property.
The text was updated successfully, but these errors were encountered: