使用React和TypeScript,我试图键入一个将参数传递给Date.toLocaleString的函数,但是当我尝试使用Intl.LocalesArgument时,会出现一个错误,即Namespace 'Intl' has no exported member 'LocalesArgument'。我的tsconfig.json在下面,我尝试将target更改为es2020并重新启动dev服务器,但没有结果。
{
"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"
]
}发布于 2022-09-07 19:02:59
我在TypeScript 4.6.3上,升级到最新版本(撰写本文时的4.8.2)修复了这个问题。
https://stackoverflow.com/questions/73637484
复制相似问题