question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Emotion 10 intrinsics typescript types do not have event handler props

See original GitHub issue
  • emotion version: 10.0.4
  • react version: 16.7.0-alpha.2

Relevant code:

const Form = styled.form({})

const Foo = () => <Form onSubmit={e => { console.log(e) }} />

What you did:

Upgraded to Emotion 10

What happened:

Intrinsics created by styled do not appear to have event handler props like onSubmit/onChange so typescript complains about the implicit any of e.

error TS7006: Parameter 'event' implicitly has an 'any' type.

Reproduction:

Codesandbox doesn’t import emotion types, so it’s not helpful to repro. If there’s a way to make that work, or if there’s a starter project w/ Typescript + emotion 10 I’d gladly whip up a repro.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
aaronjensencommented, Dec 10, 2018

It looks like that will work for me. I don’t need it to accept functions because these are for functions that return styles.

By the way, CSSPropertiesWithMutliValues is misspelled Mutli vs Multi.

Looks like all I need now to upgrade to emotion 10 would be the above new type, innerRef support (I may be missing something here) and the babel jsx pragma eliding fix.

0reactions
aaronjensencommented, Dec 11, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript - Emotion
When using our JSX factory, TypeScript only allows the css prop on components that accept a className prop. This is because @emotion/react resolves...
Read more >
React TypeScript | Correct Type for Event Handler Prop
The easiest solution would be to use the MouseEventHandler type with HTMLButtonElement as the type parameter: interface ButtonProps { play: ...
Read more >
CHANGELOG.md - mui/material-ui - Sourcegraph
Change all occurrences of components and componentsProps props in Base components to slots and slotProps, respectively. Change casing of slots' fields to ...
Read more >
property 'children' does not exist on type 'intrinsicattributes'.ts ...
I have replaced the key prop as it is not recommended to use indexes as keys ... Property children does not exist on...
Read more >
Understanding and improving Emotion 10's TypeScript types
We have this ExtraProps generic argument already, it allows us to make extra props available to the styles, but not require them to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found