Я получаю следующую ошибку:
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"
]
}
Какие еще плагины мне нужны?
@FelixKling, извините, я имел в виду destructuring. Я отправил сообщение об ошибке с терминала. Я хочу использовать первый пример, а не второй.



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Я не могу воспроизвести ошибку на детской площадке (но я думаю, что он не использует Babel). Однако из Машинописные документы:
Property renaming
You can also give different names to properties:
let { a: newName1, b: newName2 } = o;Here the syntax starts to get confusing. You can read
a: newName1as “a as newName1”. The direction is left-to-right, as if you had written:let newName1 = o.a; let newName2 = o.b;Confusingly, the colon here does not indicate the type. The type, if you specify it, still needs to be written after the entire destructuring:
let { a, b }: { a: string, b: number } = o;
Итак, вы должны определить метод как
interface Foo {
bar: ({name, age}: {name: string, age: number}) => void;
}
Не вижу распространения. Вы имеете в виду деструктуризацию? Где именно ошибка? Как связаны два фрагмента кода?