使用React和TypeScript,我试图输入一个函数,将参数传递给Date.toLocaleString
,但当我尝试使用Intl.LocalesArgument
时,我得到一个错误,说Namespace 'Intl' has no exported member 'LocalesArgument'
。我的tsconfig.json
在下面,我已经尝试将target
更改为es2020
并重新启动开发服务器,但无济于事。
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext",
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"useUnknownInCatchVariables": false
},
"include": [
"src"
]
}
2条答案
按热度按时间azpvetkf1#
我使用的是TypeScript
4.6.3
,升级到最新版本(撰写本文时为4.8.2
)解决了这个问题。fcipmucu2#
如果您无法更新版本,可以通过转到tsconfig并将“ES2020.Intl”添加到“Lib”数组来解决: