Skip to content

Conversation

f0x52
Copy link
Contributor

@f0x52 f0x52 commented Jan 10, 2025

Currently the vnode argument for these two functions always defaults to VNode (which defaults to VNode<{}>), this causes issues with some arguments that are otherwise valid (and run fine, it's purely a TypeScript typecheck issue).

const Context = createContext({});
renderToPipeableStream(h(Context.Provider, { value: {} }), {});
/*
src/index.ts:6:24 - error TS2345: Argument of type 'VNode<Attributes & { value: {}; children?: ComponentChildren; }>' is not assignable to parameter of type 'VNode<{}>'.
  Types of property 'type' are incompatible.
    Type 'string | ComponentType<Attributes & { value: {}; children?: ComponentChildren; }>' is not assignable to type 'string | ComponentType<{}>'.
      Type 'ComponentClass<Attributes & { value: {}; children?: ComponentChildren; }, {}>' is not assignable to type 'string | ComponentType<{}>'.
        Type 'ComponentClass<Attributes & { value: {}; children?: ComponentChildren; }, {}>' is not assignable to type 'ComponentClass<{}, {}>'.
          Types of parameters 'props' and 'props' are incompatible.
            Type '{}' is not assignable to type 'Attributes & { value: {}; children?: ComponentChildren; }'.
              Property 'value' is missing in type '{}' but required in type '{ value: {}; children?: ComponentChildren; }'.

6 renderToPipeableStream(h(Context.Provider, { value: {} }), {});
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  node_modules/preact/src/index.d.ts:383:3
    383   value: T;
          ~~~~~
    'value' is declared here.

https://codesandbox.io/p/devbox/2tk3ws

Using the same fix as 3dcf098 for these functions solves it

Copy link

changeset-bot bot commented Jan 10, 2025

🦋 Changeset detected

Latest commit: dd90281

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

This PR includes changesets to release 1 package
Name Type
preact-render-to-string 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

@JoviDeCroock
Copy link
Member

Needs changeset

…peableStream, similar to other render functions
@JoviDeCroock JoviDeCroock merged commit 2afaf31 into preactjs:main Jan 10, 2025
1 check passed
@github-actions github-actions bot mentioned this pull request Jan 10, 2025
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.

2 participants