-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add basic flow types for css and styled tags
Now the result of the `css` tag will always be of the type string, and the result of the `styled.x` or `styled(x)` tag will be `React.ComponentType`. If the `styled(x)` tag wraps another component, the type of the props will also include the type from that component. Limitations: - It's not possible to type-check the interpolations currently. I have added annotations for them, but they don't work. - It doesn't handle `defaultProps` property on the styled component, will look into it in future. - The type annotations for tags (e.g. - `styled.div`) are broad, but React DOM [doesn't seem to type it either](https://github.com/facebook/flow/blob/master/lib/react-dom.js#L406).
- Loading branch information
Showing
2 changed files
with
36 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
/* @flow */ | ||
|
||
function css() { | ||
throw new Error( | ||
'Using the "css" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.' | ||
); | ||
} | ||
|
||
module.exports = css; | ||
|
||
/* :: | ||
declare module.exports: (string[], Array<string | number | {}>) => string; | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters