TypeScript error on <style> with attributes `global` and `jsx`
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #137-Ubuntu SMP Wed Jun 15 13:33:07 UTC 2022
Binaries:
Node: 16.14.2
npm: 8.7.0
Yarn: 1.22.5
pnpm: N/A
Relevant packages:
next: 12.2.1-canary.2
eslint-config-next: N/A
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
In my project when I try to create a component with global style I get a TypeScript error:
// Test.tsx
export function Test() {
return (
<div>
<style global jsx>{``}</style>
{/* ~~~~~~ */}
</div>
)
}
Type '{ children: string; global: true; jsx: true; }' is not assignable to type 'DetailedHTMLProps<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>'.
Property 'global' does not exist on type 'DetailedHTMLProps<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>'.ts(2322)
And what seems strange is that styled-jsx@5.0.2
seems to correctly define extension of react
type with:
declare module 'react' {
interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
jsx?: boolean
global?: boolean
}
}
But for some reason, this seems not to be used by TypeScript.
Expected Behavior
No TS error.
Link to reproduction
https://codesandbox.io/s/musing-mcnulty-i2crqc?file=/components/Test.tsx
To Reproduce
Just hover the global
attribute in order to see the TypeScript error.
Issue Analytics
- State:
- Created a year ago
- Comments:20 (4 by maintainers)
Top Results From Across the Web
Styled-jsx typescript error after migrating to monorepo ...
According to this closed issue in vercel, I should be able to fix this by simply running yarn add -D @types/styled-jsx , but...
Read more >TypeScript: Documentation - JSX
As of TypeScript 2.8, if JSX. ElementAttributesProperty is not provided, the type of first parameter of the class element's constructor or Function Component's ......
Read more >TypeScript and React: Styles and CSS - fettblog.eu
Styled JSX js framework. It goes its own route of providing scoped styles in style properties, without changing anything to original components.
Read more >Global attributes - HTML: HyperText Markup Language | MDN
Chrome Edge
accesskey Full support. ChromeYes. Toggle history Full support. Edge12. Tog...
autocapitalize Full support. Chrome43. Toggle history Full support. Edge79. Tog...
autocomplete Full support. ChromeYes....
Read more >Fragments
In the future, we may add support for additional attributes, such as event handlers. Live Demo. You can try out the new JSX...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
file: ./node_modules/next/index.d.ts
If I changed the selected line into
then all problems are addressed.
This issue still exists with
v12.2.5
although I am not using typescript, I still got this error during buildUnknown property 'jsx' found
on here<style jsx>{ }</style>