-
-
Notifications
You must be signed in to change notification settings - Fork 94
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 external type definitions of renderToString
#326
Conversation
🦋 Changeset detectedLatest commit: 87d8c21 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Sorry about the messy changeset commits. This is only the second time I've used a changeset. |
What exactly is the problem here? Should work as-is, I believe?
All good, no worries! I think the types change can land as a patch? Or is there some usage that might break? |
This code would pass type checking but would lead to a runtime
Yes, this is useless, but it passes type checking and it would be a super weird bug to track down later if there is a use case for this that I am unaware of.
According to https://semver.org,
I figure this applies here. Unless, there is a different definition that I am not aware of.
No, this should just add functionality. |
Looks fine to me? REPL Demo
There's no functionality being added in correcting types. Adding functionality would be adding a new method or something. As types aren't really part of the public API, breaking types changes can land as a minor in most libs which is why I asked if there was some breaking scenario. But sounds like we're all good there. |
Looking at the Preact export interface VNode<P = {}> {
type: ComponentType<P> | string;
props: P & { children: ComponentChildren };
...
}
Types are part of the public API (application programming interface). Interface means not only how you use it but also the inline type documentation on how to use it. For example, if, instead of the I think this PR is a step down from that since it has no breaking behavior but adds the ability for Consider the function RootComponent() {
return <div></div>;
} The type of |
I wouldn't necessarily put too much weight/trust into those types, they'll generally work fine but there are some rough edges 😅
For better or for worse, that isn't really the case. Any change to the types would inherently be a major -- there is no fully backwards compatible type change. Including it as part of the semver process is therefore something no library truly does. Should be fine as a patch in this case IMO. |
Yeah, I saw when I looked at the implementation. There are some pros of the relaxed types like human readability.
So would a breaking type change be a minor change for just preact-render-to-string or all preact packages in general? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I'd call that a minor in any package, not just Preact, but yeah, we generally follow that. Types (especially in JS-first libs) are a best-effort to reflect the runtime constraints. If they're incorrect, that's a bug, and semver is a-okay with fixing bugs (even those a user might rely upon) in a patch (but I'd argue for a minor if it could be reasonably relied upon). Obviously we don't want to break anyone's setup, but pushing out majors to fix them being out of sync would be a bit much. |
Ran into type errors when running the following:
This PR should fix it.
After checking if this change has any runtime implications, it seems that only
Fragment
s are affected. So, I've added a fix for that as well. Not sure why anyone would want aFragment
withnull
props though.