typescript - Webpack 无法编译 ts 3.7 (Optional Chaining, Nullish Coalescing)
问题描述
我尝试使用typescript 3.7
可选链接、空值合并等功能。但是webpack
在转换时给了我一个错误。
app: Module parse failed: Unexpected token (50:40)
app: File was processed with these loaders:
app: * ../../../node_modules/ts-loader/index.js
app: You may need an additional loader to handle the result of these loaders.
app: | export const Layout = (props) => {
app: | const regionsResults = useQuery(regionsQuery, { fetchPolicy: 'cache-first' });
app: > const regions = regionsResults.data?.regions ?? [];
app: | const userItem = useQuery(usersProfileQuery, { fetchPolicy: 'cache-first' });
app: | const handleOnClick = (selected) => props.history.push(selected.key);
``
解决方案
我将目标:更改esnext
为es2018
文件中tsconfig.json
。现在它起作用了。
Webpack 问题供参考:https ://github.com/webpack/webpack/issues/10227
推荐阅读
- flutter - Visibility vs Offstage vs Opacity,哪个最适合从小部件树中隐藏孩子?
- javascript - 使用 axios 的 laravel 和 vue js 在 console.log() 或查看时返回 undefined
- c++ - ld:警告:找不到入口符号_start;未设置起始地址
- optimization - 如何在 CP-SAT 中建模条件求和(如 Excel 中的 sumif)?
- python - 日期时间拆分
- dataframe - Pyspark 中的任何函数是否生成相同的连续唯一值集?
- python - Scrapy 结果重复,for 循环有问题
- hybris - FlexibleSearch 查询以获取一天前的记录
- android - Android Studio 数据库检查器不显示任何数据库
- python - 如何编写命令以生成特定格式的 canbus 数据?