[英]Babel 7 + Typescript Unexpected token when using destructuring in function method
[英]Babel typescript unexpected token '?' in statement
Babel 不能转换 '?' 在打字稿中的语句。
let t= getObject()?.fieldName;//Module build failed (from ./node_modules/babel-loader/lib/index.js): Unexpected token
let t= getObject() && getObejct().fieldName;
也许你可以使用可选链
npm install --save-dev @babel/plugin-proposal-optional-chaining
将此添加到您的 babel 文件中
{
"plugins": ["@babel/plugin-proposal-optional-chaining"]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.