Skip to content

Commit

Permalink
Added TypeScript definitions for css prop.
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-martin committed Oct 19, 2017
1 parent acfd9a5 commit 80e54df
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/emotion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"stylis-rule-sheet": "^0.0.5"
},
"devDependencies": {
"@types/react": "^16.0.15",
"babel-cli": "^6.24.1",
"babel-plugin-transform-define": "^1.3.0",
"cross-env": "^5.0.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/emotion/typescript_tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"module": "es2015",
"strict": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node"
"moduleResolution": "node",
"jsx": "react"
},
"include": [
"./*.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
hydrate,
cx
} from '../';
import React from 'react';

sheet.speedy(true);
sheet.inject();
Expand Down Expand Up @@ -77,3 +78,10 @@ const cxResult: string = cx(() => () => [
]);

hydrate(['css-123', 'css-456']);

/*
* Can use css prop, transpiled by babel plugin
*/

<div css={`color: red;`} />;
<div css={{ color: 'red' }} />;
8 changes: 7 additions & 1 deletion packages/emotion/typings/emotion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ export function getRegisteredStyles(registeredStyles: string[], classNames: stri

export function cx(...interpolations: Interpolation[]): string;

export function hydrate(ids: string[]): void;
export function hydrate(ids: string[]): void;

declare module 'react' {
interface HTMLAttributes<T> {
css?: Interpolation;
}
}

0 comments on commit 80e54df

Please sign in to comment.