将lib添加到打字稿配置会导致编译中的回归

发布于 2025-01-25 04:07:39 字数 1115 浏览 0 评论 0原文

我添加

"lib": [
      "ES2020.Promise",
    ],

到我的ts配置中,因为我需要使用Promise.allSettled(),但是,这会导致我的编译时间检查回归,因为现在它在内置的JavaScript函数上失败了,例如

Property 'flat' does not exist on type 'ConditionalAttributeEntity[][]'
const conditionalAttributes = conditionalAttributesUnprocessed.flat();

Parameter 'component' implicitly has an 'any' type.
.filter(component => _.has(component, 'componentList'))

这些功能在这些功能上工作正常,

我config看起来像这样,

   "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "incremental": true,
    "module": "commonjs",
    "noErrorTruncation": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "pretty": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "ES2019",
    "lib": [
      "ES2020.Promise",
    ],

我可以做些什么来模块化使用promise.allsettled(),同时保持编译时间相同?

i added

"lib": [
      "ES2020.Promise",
    ],

to my ts config because i needed to use promise.allSettled(), however, this caused a regression to my compile time checks as it's now failing on built in javascript functions like

Property 'flat' does not exist on type 'ConditionalAttributeEntity[][]'
const conditionalAttributes = conditionalAttributesUnprocessed.flat();

Parameter 'component' implicitly has an 'any' type.
.filter(component => _.has(component, 'componentList'))

before these worked fine

my config looks like this

   "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "incremental": true,
    "module": "commonjs",
    "noErrorTruncation": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "pretty": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "ES2019",
    "lib": [
      "ES2020.Promise",
    ],

Is there anything i can do to more modularly use promise.allSettled() while keeping compile time checks the same?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文