kobaltedev / kobalte

A UI toolkit for building accessible web apps and design systems with SolidJS.
https://kobalte.dev
MIT License
1.27k stars 69 forks source link

Property 'children' does not exist on type 'IntrinsicAttributes & DialogContentProps'.ts(2322) #374

Closed aminya closed 5 months ago

aminya commented 7 months ago

Describe the bug I am trying to use the Dialog components, but for many of them, TypeScript gives me an error: I cannot put children under the component. It seems the props of all these components inherit the form AsChild, which doesn't allow children.

The same issue exists for assigning class and ID to these components.

Type '{ id: string; }' is not assignable to type 'IntrinsicAttributes & DialogTriggerProps'.
  Property 'id' does not exist on type 'IntrinsicAttributes & DialogTriggerProps'
Type '{ children: Element; class: string; }' is not assignable to type 'IntrinsicAttributes & DialogCloseButtonProps'.
  Property 'children' does not exist on type 'IntrinsicAttributes & DialogCloseButtonProps'.

To Reproduce Steps to reproduce the behaviour:

  <Dialog.Root>
    <Dialog.Trigger id="error-trigger" />
    <Dialog.Portal>
      <Dialog.Overlay class="dialog__overlay" />
      <div class="dialog__positioner">
        <Dialog.Content class="dialog__content">
          <div class="dialog__header">
            <Dialog.Title class="dialog__title">Error</Dialog.Title>
            <Dialog.CloseButton class="dialog__close-button">
              <span innerHTML={cross} />
            </Dialog.CloseButton>
          </div>
          <Dialog.Description class="dialog__description">
            <div id="table-error" />
          </Dialog.Description>
        </Dialog.Content>
      </div>
    </Dialog.Portal>
  </Dialog.Root>

Screenshots

image

Smartphone (please complete the following information):

aminya commented 7 months ago

I have realized the issue is that the types in @kobalte/core depends on @kobalte/utils, but @kobalte/utils types are not being found by TypeScript in VsCode. Installing @kobalte/utils as my dependency fixes the issue, but that is not ideal.

I am using pnpm.

pnpm i --save-dev @kobalte/utils
jer3m01 commented 7 months ago

We're working on fixing and changing our polymorphic and type system. If you'd like to follow progress or offer feedback, check out https://github.com/jer3m01/polymorphic or/and SolidJS' discord.

aminya commented 6 months ago

Using this in .npmrc fixes the issue for me.

node-linker=hoisted

Then:

rm -rf ./node_modules/ ./packages/*/node_modules/
pnpm i
jer3m01 commented 5 months ago

Types have been fixed in #381.