gpt4 book ai didi

typescript - Webpack 无法编译 ts 3.7(可选链接,空合并)

转载 作者:行者123 更新时间:2023-12-04 06:01:47 25 4
gpt4 key购买 nike

我尝试使用 typescript 3.7 Optional Chaining、Nullish Coalescing 等功能。但是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);
``

最佳答案

我改变了目标:esnextes2018tsconfig.json文件。现在它起作用了。
供引用的 Webpack 问题:https://github.com/webpack/webpack/issues/10227

关于typescript - Webpack 无法编译 ts 3.7(可选链接,空合并),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58813176/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com