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

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

Closed
addlistener opened this issue Jan 13, 2023 · 4 comments · Fixed by #826
Closed

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

addlistener opened this issue Jan 13, 2023 · 4 comments · Fixed by #826
Labels

Comments

@addlistener
Copy link

addlistener commented Jan 13, 2023

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.
#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 addlistener changed the title Styled-jsx in an npm module? Make <reference types="styled-jsx" /> include global.d.ts? Jan 14, 2023
@addlistener
Copy link
Author

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
Copy link

🎉 This issue has been resolved in version 5.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@adarshaacharya
Copy link

adarshaacharya commented Aug 12, 2023

@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
Copy link
Author

@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" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants