TS2552: 无法找到名称 ‘PictureInPictureEvent’。您是指 ‘PictureInPictureEventHandler’ 吗?

huangapple go评论77阅读模式
英文:

TS2552: Cannot find name 'PictureInPictureEvent'. Did you mean 'PictureInPictureEventHandler'?

问题

我已将我的Angular应用程序从版本14升级到版本15。
升级后,我遇到以下错误:

Error: node_modules/preact/src/jsx.d.ts:1078:3 - error TS2552: 找不到名称 'PictureInPictureEvent'。您是否想要 'PictureInPictureEventHandler'?

以及

node_modules/preact/src/jsx.d.ts:1124:3 - error TS2344: 类型 'TargetedPictureInPictureEvent<Target>' 不满足约束 'TargetedEvent<EventTarget, Event>'。

以下是配置详细信息:

{
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "target": "ES2022",
    "downlevelIteration": true,
    "declaration": false,
    "importHelpers": true,
    "lib": [
      "ES2022",
      "dom"
    ],
    "module": "esnext",
    "moduleResolution": "node",
    "sourceMap": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "suppressImplicitAnyIndexErrors": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "watch": false
  },
  "exclude": [
    "node_modules"
  ],
  "angularCompilerOptions": {
    "strictInjectionParameters": true
  }
}

我在这里做错了什么?

英文:

I have upgraded my Angular app to version 15 from 14.
After upgrade I am getting following errors
Error: node_modules/preact/src/jsx.d.ts:1078:3 - error TS2552: Cannot find name 'PictureInPictureEvent'. Did you mean 'PictureInPictureEventHandler'?

And

node_modules/preact/src/jsx.d.ts:1124:3 - error TS2344: Type 'TargetedPictureInPictureEvent<Target>' does not satisfy the constraint 'TargetedEvent<EventTarget, Event>'.

Following are the config details

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

{
  &quot;compilerOptions&quot;: {
    &quot;baseUrl&quot;: &quot;./&quot;,
    &quot;outDir&quot;: &quot;./dist/out-tsc&quot;,
    &quot;target&quot;: &quot;ES2022&quot;,
    &quot;downlevelIteration&quot;: true,
    &quot;declaration&quot;: false,
    &quot;importHelpers&quot;: true,
    &quot;lib&quot;: [
      &quot;ES2022&quot;,
      &quot;dom&quot;
    ],
    &quot;module&quot;: &quot;esnext&quot;,
    &quot;moduleResolution&quot;: &quot;node&quot;,
    &quot;sourceMap&quot;: true,
    &quot;experimentalDecorators&quot;: true,
    &quot;removeComments&quot;: false,
    &quot;suppressImplicitAnyIndexErrors&quot;: true,
    &quot;typeRoots&quot;: [
      &quot;node_modules/@types&quot;
    ],
    &quot;watch&quot;: false
  },
  &quot;exclude&quot;: [
    &quot;node_modules&quot;
  ],
  &quot;angularCompilerOptions&quot;: {
    &quot;strictInjectionParameters&quot;: true
  }
}

<!-- end snippet -->

What am I doing wrong here?

答案1

得分: 3

你需要使用 TS 4.9+ 与 Preact v10.15.0。你可以升级你的 TS 版本或降级 Preact。

你可以参考这个链接,link

英文:

You need to use TS 4.9+ w/ Preact v10.15.0. You can upgrade your TS version or downgrade Preact.

You can follow this link, for reference link

答案2

得分: 2

这个问题是由于TS和Preact版本不匹配引起的。

在尝试更新TS以匹配不同版本的Preact以检查兼容性后,我仍然无法解决这个问题。

对我来说解决这个问题的方法是在tsconfig.json文件的"compilerOptions"中添加以下语句:

"skipLibCheck": true

英文:

This issue is due to a version mismatch of TS and Preact.

After trying to update TS for different versions to check compatibility with Preact I was still not able to solve this.

What solved this issue for me was adding the following statement within "compilerOptions" in tsconfig.json file.

&quot;skipLibCheck&quot;: true

huangapple
  • 本文由 发表于 2023年6月16日 14:07:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76487347.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定