typescript - Argument of type 'App' is not assignable to parameter of type 'ReactElement<any>[]'. Property 'length' is missing in type 'App'
2017-11-08T03:37:17Z||2017-11-08T03:42:01Z
Full error message. 完整的错误提示.
[ts]
Argument of type 'App' is not assignable to parameter of type 'ReactElement<any>[]'.
Property 'length' is missing in type 'App'.
[ts] Type 'RegExp' cannot be converted to type 'App'.
[ts]
Type 'RegExp' cannot be converted to type 'App'.
Property 'render' is missing in type 'RegExp'.
Sample code. 示例代码:
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './lib/app/App';
ReactDOM.render(
<App />,
document.getElementById('root') as HTMLElement
);
That's because you use <App />
in a ts file, rename it to tsx.
因为你在ts文件中用了<App />
,把文件改成tsx*问题就没了。