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

Solid Styled JSX + Typescript #169

Closed
danielpza opened this issue Jun 4, 2020 · 6 comments
Closed

Solid Styled JSX + Typescript #169

danielpza opened this issue Jun 4, 2020 · 6 comments
Labels
bug Something isn't working typescript relating to typescript or types

Comments

@danielpza
Copy link

danielpza commented Jun 4, 2020

I found that I need extra types for typescript to play nice with styled-jsx on solid. Using the style tag make typescript throw an error: Property 'jsx' does not exist on type 'StyleHTMLAttributes<HTMLStyleElement>'. [2322]

I manage to make the errors go away with similar to this issue in styled-jsx:

declare global {
  namespace JSX {
    interface StyleHTMLAttributes<T extends HTMLStyleElement> {
      jsx?: boolean;
      global?: boolean;
    }
  }
}

It would be convenient to put it on the readme or make a package out of it under @types/solid-styled-jsx.

@danielpza danielpza changed the title Solid Styled JSX + typescript Solid Styled JSX + Typescript Jun 4, 2020
@ryansolid
Copy link
Member

Thanks for reporting. I will see what I can do update the types.

@ryansolid ryansolid added the bug Something isn't working label Jun 4, 2020
@littlepoolshark
Copy link

How can solve this problem? Some one helps?

@ryansolid
Copy link
Member

You should just be able to import it: https://github.com/ryansolid/solid/tree/master/packages/solid-styled-jsx#typescript
Let me know if this doesn't work.

@littlepoolshark
Copy link

@ryansolid , it seems like still not work.

@littlepoolshark
Copy link

I just run yarn add solid-styled-jsx --dev and put the import statement import "solid-styled-jsx"; in the top of the root file, and add the plugin config to the wepack.config.js. TS compiler still throw that error to me.

@ryansolid
Copy link
Member

Hmm.. It should be extending the global namespace. I wonder if it is not finding it or the global extension is not working. Can you try writing that declaration in file?

declare global {
  namespace JSX {
    interface StyleHTMLAttributes<T> {
      jsx?: boolean;
      global?: boolean;
      dynamic?: boolean;
    }
  }
}

As far as I know this mechanism should work (same for adding custom elements etc). But let's isolate whether it's the "solution" or the module/build system.

@ryansolid ryansolid added the typescript relating to typescript or types label May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typescript relating to typescript or types
Projects
None yet
Development

No branches or pull requests

3 participants