请问老师,interface 是关键字,如何解决
来源:3-4 由浅入深 webpack - 编译 typescript
Benjamin_Smith
2018-03-13
ERROR in ./src/app.ts
Module parse failed: The keyword 'interface' is reserved (3:0)
You may need an appropriate loader to handle this file type.
| const NUM = 45
|
| interface Cat {
| name: String,
| gender: Stringnpm install webpack@3.10.0 typescript ts-loader awesome-typescript-loader --save-dev
const NUM = 45
interface Cat {
name: String,
gender: String
}
function touchCat(cat: Cat) {
console.log('miao~', cat.name);
}
touchCat({
name: 'tom',
gender: 'male'
})webpack.config.js 和 tsconfig.js 配置跟你视频里的一样
写回答
4回答
-
tulies
2018-03-28
你贴的代码 test: /\.tex?$/。。 这也不对啊 tsx
00 -
tulies
2018-03-28
如果你webpack用的是3.x的版本,把你的ts-loader也降级到3.x的版本就可以了。 不要用最新的。
00 -
Benjamin_Smith
提问者
2018-03-15
module.exports = { entry: { 'app': './src/app.ts' }, output: { filename: '[name].bundle.js' }, module: { rules: [{ test: /\.tex?$/, use: { loader: 'ts-loader' } }] } }我仔细看了好多遍,跟视频里的是一样的啊
00 -
qbaty
2018-03-14
loader 好像没有配置对,tsx?
012018-03-15
相似问题