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

Add typing for create-emotion-styled #668

Merged
merged 8 commits into from
May 24, 2018

Conversation

Ailrun
Copy link
Member

@Ailrun Ailrun commented May 22, 2018

What: Add typing for create-emotion-styled package

Why: To allow TS users to use create-emotion-styled

How: By consulting with glamorous typing and old react-emotion typing

Checklist:

  • [N/A] Documentation
  • Tests
  • Code complete

I'm not sure this is complete typing. Could you give me more idea for testing? What usecases did I miss?

After typing for this package is completed and #667 is merged without complex problems, I want to fix react-emotion typing and add preact-emotion typing.

@Ailrun Ailrun force-pushed the typing/create-emotion-styled branch 4 times, most recently from 756c02a to 9cdd376 Compare May 22, 2018 18:27
@vadistic
Copy link

Wow, what a nice suprise! Thank you, It will come useful 👍

// Btw. please please fix StyledOptions in react-emotion typings
export interface Options {
  string?: string;
}

@Ailrun Ailrun force-pushed the typing/create-emotion-styled branch from 9cdd376 to 759a293 Compare May 22, 2018 19:35
@Ailrun
Copy link
Member Author

Ailrun commented May 22, 2018

@vadistic My pleasure. Actually, it's broken in many ways, wrong typed Options, using Component instead of ComponentClass, ....
Because of paypal/glamorous#419, I want to migrate to emotion, but these typing issues does not allow me to migrate.

@Ailrun Ailrun force-pushed the typing/create-emotion-styled branch 2 times, most recently from 7236a0e to 68398c7 Compare May 22, 2018 19:43
@Ailrun Ailrun force-pushed the typing/create-emotion-styled branch from 68398c7 to 1757288 Compare May 22, 2018 19:44
e?: string;
label?: string;
target?: string;
shouldForwardProp?: (name?: string) => boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be (name: string) => boolean, the name argument will always be there.

}, (props) => ({
height: props.theme ? '200px' : '100px',
}));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some tests with the string syntax?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, tests for strings. Thx! I missed them!

@Ailrun
Copy link
Member Author

Ailrun commented May 23, 2018

@mitchellhamilton I added/fixed those! Could you suggest more tests I missed? I don't think those tests are enough...

Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of anymore tests that would need to be added.

const StyledClassComp0 = createStyled(TestClassComp)({
width: '200px',
}, (props) => ({
height: props.theme ? '200px' : '100px',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

props.theme will never be falsy, if there isn't a ThemeProvider, props.theme will be an empty object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't know that. I should fix typing also.

display: inline;
position: fixed;
flexGrow: 20;
${(props: StyledFunProps, context) => `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning a string with css properties isn't something we recommend because it breaks syntax highlighting, formatting and minifying. Could you change it to this?

css`
  content: ${context.name};
  color: ${props.color};
`

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. i will change it.

@Ailrun
Copy link
Member Author

Ailrun commented May 23, 2018

@mitchellhamilton It's now fixed! Thank you for reviewing my PR!

Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!

@emmatown emmatown merged commit f1a563e into emotion-js:master May 24, 2018
@Ailrun Ailrun mentioned this pull request May 24, 2018
2 tasks
emmatown pushed a commit that referenced this pull request May 25, 2018
**What**:
1. All types introduced in #668 live in single file, so it's hard to write preact type using common things.
    ~I do really hate global JSX namespace idea.~
1. It used ReactHTML, but it's not an interface for props, but for factories. Therefore it does not provide HTML attributes like `onClick` as props.
1. ReactHTML problem occurs because of lack of tests, so I add some tests too.

**Why**: Typing introduced in #668 is wrong.

**How**: By using `JSX.IntrinsicElements`

**Checklist**:
<!-- add "N/A" to the end of each line that's irrelevant to your changes -->
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->
- [N/A] Documentation
- [x] Tests
- [x] Code complete
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.

4 participants