Closed
Description
TypeScript Version: 3.1.3
Search Terms: react umd "move to new file" refactor
Code
// ./src/index.tsx
import * as React from 'react';
const MyComponent: React.SFC<{}> = props => <div />;
export default MyComponent;
{
"compilerOptions": {
"jsx": "react"
},
"include": ["./src/**/*"]
}
Expected behavior:
When copying the line const MyComponent
and actioning the "Move to new file" command, the new file contents should be:
import * as React from 'react';
export const MyComponent: React.SFC<{}> = props => <div />;
Actual behavior:
The new file contents are:
export const MyComponent: React.SFC<{}> = props => <div />;
The React
import is missing, which creates errors:
// React import is missing…
export const MyComponent: SFC<{}> = props =>
// … which results in error: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.
<div />;