Skip to content

Conversation

FezVrasta
Copy link
Member

No description provided.

@FezVrasta FezVrasta requested a review from Andarist November 7, 2019 12:35
@changeset-bot
Copy link

changeset-bot bot commented Nov 7, 2019

💥 No Changeset

Latest 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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 7, 2019

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:

Sandbox Source
Emotion Configuration

import createStyled from '../src/base'
import type { CreateStyledComponent, StyledComponent } from '../src/utils'

export const valid: CreateStyledComponent = createStyled('div')
const valid: StyledComponent<empty> = createStyled('div')({
Copy link
Member Author

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' })
Copy link
Member Author

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 })
Copy link
Member Author

@FezVrasta FezVrasta Nov 7, 2019

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.

@Andarist Andarist merged commit 17f45e9 into emotion-js:styled-base-as-an-entrypoint Nov 7, 2019
@FezVrasta FezVrasta deleted the fix/styled-base-as-an-entrypoint-flow branch November 7, 2019 13:25
emmatown added a commit that referenced this pull request Nov 8, 2019
* 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
louisgv pushed a commit to louisgv/emotion that referenced this pull request Sep 6, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants