Babel 不能转换'?' 在打字稿的声明中。
let t= getObject()?.fieldName;//Module build failed (from ./node_modules/babel-loader/lib/index.js): Unexpected token
let t= getObject() && getObejct().fieldName;
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"]
}