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

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

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>'。

以下是配置详细信息:

  1. {
  2. "compilerOptions": {
  3. "baseUrl": "./",
  4. "outDir": "./dist/out-tsc",
  5. "target": "ES2022",
  6. "downlevelIteration": true,
  7. "declaration": false,
  8. "importHelpers": true,
  9. "lib": [
  10. "ES2022",
  11. "dom"
  12. ],
  13. "module": "esnext",
  14. "moduleResolution": "node",
  15. "sourceMap": true,
  16. "experimentalDecorators": true,
  17. "removeComments": false,
  18. "suppressImplicitAnyIndexErrors": true,
  19. "typeRoots": [
  20. "node_modules/@types"
  21. ],
  22. "watch": false
  23. },
  24. "exclude": [
  25. "node_modules"
  26. ],
  27. "angularCompilerOptions": {
  28. "strictInjectionParameters": true
  29. }
  30. }

我在这里做错了什么?

英文:

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 -->

  1. {
  2. &quot;compilerOptions&quot;: {
  3. &quot;baseUrl&quot;: &quot;./&quot;,
  4. &quot;outDir&quot;: &quot;./dist/out-tsc&quot;,
  5. &quot;target&quot;: &quot;ES2022&quot;,
  6. &quot;downlevelIteration&quot;: true,
  7. &quot;declaration&quot;: false,
  8. &quot;importHelpers&quot;: true,
  9. &quot;lib&quot;: [
  10. &quot;ES2022&quot;,
  11. &quot;dom&quot;
  12. ],
  13. &quot;module&quot;: &quot;esnext&quot;,
  14. &quot;moduleResolution&quot;: &quot;node&quot;,
  15. &quot;sourceMap&quot;: true,
  16. &quot;experimentalDecorators&quot;: true,
  17. &quot;removeComments&quot;: false,
  18. &quot;suppressImplicitAnyIndexErrors&quot;: true,
  19. &quot;typeRoots&quot;: [
  20. &quot;node_modules/@types&quot;
  21. ],
  22. &quot;watch&quot;: false
  23. },
  24. &quot;exclude&quot;: [
  25. &quot;node_modules&quot;
  26. ],
  27. &quot;angularCompilerOptions&quot;: {
  28. &quot;strictInjectionParameters&quot;: true
  29. }
  30. }

<!-- 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.

  1. &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:

确定