-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
CC @donataswix
It appears that using a React component written as a class in a .js
file causes some issues.
Start a project with the following files:
tsconfig.json
{
"compilerOptions": {
"module": "es2015",
"target": "esnext",
"jsx": "react-native",
"strictNullChecks": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"lib": [
"es5",
"es6",
"es7",
"es2017",
"dom"
],
"outDir": "dist"
},
"include": [
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
}
index.tsx
import React from 'react';
import Hello from './hello';
class A extends React.Component<void,void> {
render() {
return (
<div>
<Hello/>
</div>
);
}
}
hello.js
import React from 'react';
export default class Hello extends React.Component {
render() {
return <div>Hello</div>;
}
}
Expected: No problems
Actual: Error on <Hello />
: JSX element type 'Hello' does not have any construct or call signatures.
Note that if you add type arguments to Component
in hello.js
, this will actually fix the problem (while creating new ones).
Potentially related is #13609.
aristotll
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue