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

Component props can be defined as a string #2304

Closed
waynevanson opened this issue Sep 23, 2024 · 3 comments
Closed

Component props can be defined as a string #2304

waynevanson opened this issue Sep 23, 2024 · 3 comments

Comments

@waynevanson
Copy link

waynevanson commented Sep 23, 2024

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.

@atk
Copy link
Contributor

atk commented Sep 23, 2024

How would you set the string props through JSX? The props being an object is Internet to JSX. This is not an error, it's just a limit of the standard we aim to support.

@ryansolid
Copy link
Member

Maybe I'm misunderstanding the issue. But props can't' be a string.. But only contain strings as values of properties.

@waynevanson
Copy link
Author

@atk @ryansolid

Sorry for the confusion.

ComponentType<string> is a valid definition when I don't believe it should be.

@waynevanson waynevanson changed the title Component props can be string Component props can be defined as a string Sep 24, 2024
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

No branches or pull requests

3 participants