Skip to content

Commit

Permalink
feat: add TypeScript typings builtin (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
theoludwig authored Jan 15, 2021
1 parent eb65f35 commit 4dd5c13
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
package-lock=false
save-exact = true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"webpack.js",
"license.md"
],
"typings": "./typings/index.d.ts",
"scripts": {
"build": "babel src --out-dir dist",
"test": "ava",
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ const Button = ({ children }) => (
}
```

### Syntax Highlighting [Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=blanu.vscode-styled-jsx)
### Syntax Highlighting [Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=Divlo.vscode-styled-jsx-syntax)
Launch VS Code Quick Open (⌘+P), paste the following command, and press enter.
```
ext install Divlo.vscode-styled-jsx-syntax
Expand All @@ -984,7 +984,7 @@ If you use Stylus instead of plain CSS, install [vscode-styled-jsx-stylus](https
ext install vscode-styled-jsx-stylus
```

### Autocomplete [Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=AndrewRazumovsky.vscode-styled-jsx-languageserver)
### Autocomplete [Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=Divlo.vscode-styled-jsx-languageserver)
Launch VS Code Quick Open (⌘+P), paste the following command, and press enter.
```
ext install Divlo.vscode-styled-jsx-languageserver
Expand Down
11 changes: 11 additions & 0 deletions typings/css.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Definitions by: @types/styled-jsx <https://www.npmjs.com/package/@types/styled-jsx>

declare function css(chunks: TemplateStringsArray, ...args: any[]): JSX.Element
declare namespace css {
function global(chunks: TemplateStringsArray, ...args: any[]): JSX.Element
function resolve(
chunks: TemplateStringsArray,
...args: any[]
): { className: string; styles: JSX.Element }
}
export { css }
13 changes: 13 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Definitions by: @types/styled-jsx <https://www.npmjs.com/package/@types/styled-jsx>

import 'react'

export * from './server'
export * from './css'

declare module 'react' {
interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
jsx?: boolean
global?: boolean
}
}
11 changes: 11 additions & 0 deletions typings/server.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Definitions by: @types/styled-jsx <https://www.npmjs.com/package/@types/styled-jsx>

import { ReactElement } from 'react'

declare function flushToHTML(opts?: { nonce?: string }): string
declare function flushToReact<T>(opts?: {
nonce?: string
}): Array<ReactElement<T>>

export { flushToHTML }
export default flushToReact

0 comments on commit 4dd5c13

Please sign in to comment.