-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
test: styled Flow tests #1615
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
test: styled Flow tests #1615
Conversation
💥 No ChangesetLatest commit: bc563d3 Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂 If these changes should be published to npm, you need to add a changeset. Click here to learn what changesets are, and how to add one. Click here if you're a maintainer who wants to add a changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit bc563d3:
|
import createStyled from '../src/base' | ||
import type { CreateStyledComponent, StyledComponent } from '../src/utils' | ||
|
||
export const valid: CreateStyledComponent = createStyled('div') | ||
const valid: StyledComponent<empty> = createStyled('div')({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't ask me how it used to work before, but CreateStyled
return type is not CreateStyledComponent
, it's (...args: Interpolations) => StyledComponent<Props>
(defined inline).
To make the test simpler, I call createStyled
to generate (...args: Interpolations) => StyledComponent<Props>
, and then I call it again, to generate a Styled Component. Then I check the returned type is StyledComponent
.
The result is pretty much the same.
|
||
// $FlowExpectError: we can't cast a StyledComponent to string | ||
export const invalid: string = createStyled('div') | ||
const invalid: string = createStyled('div')({ color: 'red' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here, I test the final StyledComponent type instead of the intermediate type.
|
||
const styled = createStyled('div') | ||
type Props = { color: string } | ||
// prettier-ignore | ||
const Div = styled<Props>({ color: props => props.color }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, no idea how it used to work... createStyled()
doesn't return a polymorphic type, only createStyled.*
are polymorphic types.
I moved the test into styled.js
to test the styled.*
signature.
* Change @emotion/styled-base to @emotion/styled/base * Fix some stuff * Fix some stuff * Fix another thing * Remove styled-base from CodeSandbox CI config * Make @emotion/styled/base TS types working * Restore flowtype tests for @emotion/styled/base * Fix last reference to @emotion/styled-base * fix some flow errors * Brought back @emotion/styled-base, but throw a deprecation error at runtime * fix styled Flow tests (#1615) * fix flow type error * Add changeset * Update spotty-llamas-mate.md * Update index.js * Remove @emotion/styled-base from some changesets
* Change @emotion/styled-base to @emotion/styled/base * Fix some stuff * Fix some stuff * Fix another thing * Remove styled-base from CodeSandbox CI config * Make @emotion/styled/base TS types working * Restore flowtype tests for @emotion/styled/base * Fix last reference to @emotion/styled-base * fix some flow errors * Brought back @emotion/styled-base, but throw a deprecation error at runtime * fix styled Flow tests (emotion-js#1615) * fix flow type error * Add changeset * Update spotty-llamas-mate.md * Update index.js * Remove @emotion/styled-base from some changesets
No description provided.