Skip to content

Component props can be defined as a string #2304

@waynevanson

Description

@waynevanson

Describe the bug

ComponentType<Props> can be defined where Props is a string.

Component types that contains strings cannot be consumed via JSX.

const First: ComponentType<string> = (props) => null
const First = (props: string) => null

//@ts-expect-error
const Second = () => <First />

Error when hovering over second

Type '{}' is not assignable to type 'IntrinsicAttributes & string'.
  Type '{}' is not assignable to type 'string'.(2322)

Your Example Website or App

https://stackblitz.com/edit/solidjs-templates-wb1s7a?file=src%2FApp.tsx&view=editor

Steps to Reproduce the Bug or Issue

Go to the stack blitz url.

Expected behavior

Component props shouldn't be strings, since they can't be used in JSX.

Screenshots or Videos

No response

Platform

  • OS: Linux
  • Browser: Firefox
  • Version: ^1.8.20 (1.8.22)

Additional context

Problem is that {} === string.

I think this should instead be object, Record<string, any> or Record<string, unknown>.
Not sure which though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions