vercel / styled-jsx

Full CSS support for JSX without compromises
http://npmjs.com/styled-jsx
MIT License
7.65k stars 266 forks source link

Make <reference types="styled-jsx" /> include global.d.ts? #825

Closed addlistener closed 1 year ago

addlistener commented 1 year ago

We cannot do <reference types="styled-jsx/global" />. And import 'styled-jsx/global'; does not work either.

image

I believe it's a huge pain point for people to use styled-jsx smoothly. https://github.com/vercel/styled-jsx/issues/90

We have to write a duplicated global.d.ts for the typescript code to work. Next.js do it this way. It does not make sense for people to do it every time they want to use it.

image
addlistener commented 1 year ago

I managed to make it work using import type from 'styled-jsx/global'. Wouldn't it be nice that we document it?

Or could we explicitly export <reference types="styled-jsx/global" />?

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 5.1.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

adarshaacharya commented 11 months ago

@addlistener using Next 13.x and still facing same issue, For now created custom.d.ts in src/ and pasted given code it works now

import 'react';

declare module 'react' {
  interface StyleHTMLAttributes<T> extends React.HTMLAttributes<T> {
    jsx?: boolean;
    global?: boolean;
  }
}

Are there any better option than that?

addlistener commented 10 months ago

@adarshaacharya

Have you tried the following?

  1. checking your styled-jsx version?
  2. import type from 'styled-jsx/global'
  3. <reference types="styled-jsx/global" />