小编Won*_*rin的帖子

类型“typeof Intl”上不存在属性“RelativeTimeFormat”

编写代码时没有错误,但是在编译时出现了这种情况:

src/index.ts:2:24 - error TS2339: Property 'RelativeTimeFormat' does not exist on type 'typeof Intl'.

2   const rtf = new Intl.RelativeTimeFormat("en", { style: "long" });
                         ~~~~~~~~~~~~~~~~~~


Found 1 error.
Run Code Online (Sandbox Code Playgroud)

虽然这个问题在这个PR之后应该已经解决了。

我的tsconfig

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "CommonJS",
    "moduleResolution": "Node",
    "outDir": "lib",
    "lib": [
      "DOM",
      "ESNext"
    ],
    "strict": true,
    "declaration": true,
    "removeComments": true,
    "sourceMap": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "importHelpers": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "isolatedModules": true
  },
  "include": [
    "src"
  ]
}
Run Code Online (Sandbox Code Playgroud)

打字稿版本:4.0.3

typescript

13
推荐指数
1
解决办法
7263
查看次数

标签 统计

typescript ×1