You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you're using TypeScript, then in order to allow <style jsx> tags to be properly understood by it, create a file named "styled-jsx.d.ts" anywhere within your project containing the following, or add this line to the top of any single existing .ts file within your project:
/// <reference types="styled-jsx" />
Is not providing typings for react module argumentation and TS end up with error
TS2322: Type '{ children: string; jsx: true; }' is not assignable to type 'DetailedHTMLProps<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>'.
Property 'jsx' does not exist on type 'DetailedHTMLProps<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>'.
Which is not documented and also not how libraries should expose typings.
If the current behavior is a bug, please provide the steps to reproduce and possibly a minimal demo or testcase in the form of a Next.js app, CodeSandbox URL or similar
create any component that use <style jsx>...</style>
export default () => (
<div>
<p>only this paragraph will get the style :)</p>
<style jsx>{`
p {
color: red;
}
`}</style>
</div>
)
and reference typings
/// <reference types="styled-jsx" />
What is the expected behavior?
[expected] referencing /// <reference types="styled-jsx" /> should be enough to use <style jsx /> or <style jsx global /> without TS errors.
Maybe you should evaluate once again how d.ts files should be structured
Do you want to request a feature or report a bug?
Report a bug
What is the current behavior?
According to documentation section Typescript
Is not providing typings for react module argumentation and TS end up with error
Here is PR that introduce this issue
Current workaround is to use
Which is not documented and also not how libraries should expose typings.
If the current behavior is a bug, please provide the steps to reproduce and possibly a minimal demo or testcase in the form of a Next.js app, CodeSandbox URL or similar
Fallow all steps from documentation section Getting started
npm install --save styled-jsx
{"plugins": ["styled-jsx/babel"]}
<style jsx>...</style>
What is the expected behavior?
/// <reference types="styled-jsx" />
should be enough to use<style jsx />
or<style jsx global />
without TS errors.Maybe you should evaluate once again how
d.ts
files should be structuredFinally remove or update
global.d.ts
fileOr other solution could be to change in
package.json
typings entryfrom
to
/// <reference types="styled-jsx/global" />
Environment (include versions)
Did this work in previous versions?
Yes, last working version is 5.0.2
The text was updated successfully, but these errors were encountered: