Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript v5.1.6 compatibility #1797

Closed
janmooij opened this issue Jul 3, 2023 · 2 comments
Closed

Typescript v5.1.6 compatibility #1797

janmooij opened this issue Jul 3, 2023 · 2 comments

Comments

@janmooij
Copy link

janmooij commented Jul 3, 2023

What is the current behaviour?

$ tsc
../../node_modules/preact/src/jsx.d.ts(1078,3): error TS2304: Cannot find name 'PictureInPictureEvent'.
../../node_modules/preact/src/jsx.d.ts(1124,3): error TS2344: Type 'TargetedPictureInPictureEvent<Target>' does not satisfy the constraint 'TargetedEvent<EventTarget, Event>'.
  Type 'TargetedPictureInPictureEvent<Target>' is missing the following properties from type 'Omit<Event, "currentTarget">': type, target, timeStamp, bubbles, and 17 more.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Create a preact project with typescript@v5.1.6
  2. Try to build the project
  3. See error

What is the expected behaviour?
A succeeding build

Please mention any other relevant information
This started after upgrading typescript from 5.1.3 to 5.1.6.

Please paste the results of npx preact-cli info here.

Environment Info:
  System:
    OS: macOS 13.4.1
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.3 - ~/.nvm/versions/node/v16.19.0/bin/npm
  Browsers:
    Chrome: 114.0.5735.198
    Safari: 16.5.1
@rschristian
Copy link
Member

I cannot reproduce, can you walk me through the exact steps / commands used please?

The reason for this is that preact itself now uses type definitions that are only bundled in newer releases of TypeScript. You're not seeing this error because of using a newer version of TypeScript, but quite the opposite in fact; it seems that you're running an older version without those newer type defs (likely caused by your package manager, not you, to be clear).

What you can try to do is use "overrides"/"resolutions" in your package.json to specify the version of TypeScript that preact-cli should install (to 5.1.6, or whatever you want). Something like this:

"resolutions": {
    "preact-cli/typescript": "5.1.6"
}

This would force preact-cli to install a newer version of TypeScript to use, as (at the moment) it brings its own version along that it prioritizes.

We might be able to make TypeScript an optional peer dep, allowing users to bring in their own versions to avoid this completely, but I'll need a bit of time to test that out.

@rschristian
Copy link
Member

#1798 should've made this easier, so I'll close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants