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

fix: typecheck in preact jsx.d.ts due to type change related to signals #955

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robertmaier
Copy link

@robertmaier robertmaier commented Apr 21, 2023

as reported in preactjs/preact#3934 the default property in RoutableProps breaks typechecks in Preact's jsx.d.ts file.
This is caused by the addition of Signals to Preact, after which the property is defined as boolean | undefined | SignalLike<boolean | undefined> instead of a plain optional boolean.

The type ends up in preact's types because of namespace declaration merging.

@marvinhagemeister suggested to remove the default definition in preact-router here. Which is why I would suggest to also do this in preact-iso

An alternative solution would be to remove the type merging overall, but I don't have too much knowledge where the type is used.

@changeset-bot
Copy link

changeset-bot bot commented Apr 21, 2023

🦋 Changeset detected

Latest commit: 6116504

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
preact-iso Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

the delete type defines an optional boolean, which breaks typechecks in preacts jsx.d.ts file after adding Signals.
@robertmaier robertmaier changed the title fix: remove default from RoutableProps type fix: typecheck in preact jsx.d.ts due to type change related to signals Apr 21, 2023
@rschristian
Copy link
Member

Thanks for the PR!

Did you check that the types work correct? I don't think they would, as IntriniscAttributes needs to have RouteableProps else something like this wouldn't work: <Home default />. I think we need to exclude the HTMLAttributes's default from IntrinsicAttributes instead

@robertmaier
Copy link
Author

@rschristian Thanks for haveing a first look. So you'd propose to do something like

type IntrinsicAttributes = Omit<preact.JSX.IntrinsicAttributes, 'default'>

if I understand correctly?
I'll have a look if it solves our typecheck issue and let you know how it went.

@rschristian
Copy link
Member

I think so? I'm admittedly not a huge fan of TS, but I think that's what we'd need to do, or something along those lines anyways.

It's weird (to me, anyways) that this is an issue though, as default shouldn't exist on components to cause conflicts. <Foo default /> shouldn't work (without these routers' types), so I'm not really sure I understand what the conflict is, if that makes sense.

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

Successfully merging this pull request may close these issues.

None yet

2 participants