使用react-scripts-ts (2.17.0),我尝试设置一个测试套件。但是我收到了一个"SyntaxError:意外的标识符“。
配置如下:
tsconfig.json (using the standard of JSX handbook)
{
"compilerOptions": {
"jsx": "react"
}
}
这是组件的布局:
./App.tsx
interface IAppProps extends WithStyles<typeof styles> {
// ...
}
export interface IAppState {
// ...
}
class App extends React.Component<IAppProps, IAppState> {
// ...
}
export default withStyles(styles)(App);
这是测试设置:
./app.test.ts
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const app = React.createElement(App);
const div = document.createElement('div');
ReactDOM.render(app, div);
});
我应该以某种方式运行Babel吗?
https://stackoverflow.com/questions/56645129
复制相似问题