Skip to content

Commit

Permalink
Add TypeScript config instructions to readme (#750)
Browse files Browse the repository at this point in the history
This recommended configuration is inspired by Next.js's typescript template which contains a [file](https://github.com/vercel/next.js/blob/canary/packages/create-next-app/templates/typescript/next-env.d.ts) with a similar triple-slash directive that transitively imports styled-jsx's types.

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
  • Loading branch information
Macil and huozhi committed Mar 28, 2022
1 parent 16bc656 commit a7034f1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Code and docs are for v3 which we highly recommend you to try. Looking for style
- [Some styles are missing in production](https://github.com/vercel/styled-jsx/issues/319#issuecomment-349239326)
- [Build a component library with styled-jsx](#build-a-component-library-with-styled-jsx)
- [Syntax Highlighting](#syntax-highlighting)
- [ESLint](#eslint)
- [TypeScript](#typescript)
- [Credits](#credits)

## Getting started

Expand Down Expand Up @@ -1040,6 +1043,14 @@ If you're using `eslint-plugin-import`, the `css` import will generate errors, b
"settings": {"import/core-modules": ["styled-jsx/css"] }
```

## TypeScript

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:

```ts
/// <reference types="styled-jsx" />
```

## Credits

- **Pedram Emrouznejad** ([rijs](https://github.com/rijs/fullstack)) suggested attribute selectors over my initial class prefixing idea.
Expand Down

0 comments on commit a7034f1

Please sign in to comment.