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

feat: add TypeScript typings builtin #692

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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