【发布时间】:2018-10-31 12:18:25
【问题描述】:
我收到以下错误:
SyntaxError: /Path/to/File.tsx: Unexpected token, expected ";" (73:76)
为:
interface Foo {
bar: ({name: string, age: number}) => void;
}
这不会:
interface Bar {
name: string;
age: number;
}
interface Foo {
bar: (props: Bar) => void;
}
.babelrc是
{
"presets": [
"@babel/env",
"@babel/typescript",
"@babel/react"
],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread",
"@babel/transform-arrow-functions"
]
}
我还需要什么其他插件?
【问题讨论】:
-
我没有看到任何传播。你的意思是解构吗?错误究竟在哪里?两个代码sn-ps有什么关系?
-
@FelixKling 对,对不起,我的意思是
destructuring。我发布了从终端收到的错误。我想使用第一个示例,而不是第二个示例。
标签: javascript typescript babeljs