Can't use `as` prop when using TypeScript
See original GitHub issueCurrent behavior:
The as
prop cannot be used when using TypeScript.
I’m using babel + emotion plugin.
To reproduce: Example copied from the doc: https://emotion.sh/docs/styled#as-prop
Checkout this repository: ExampleComponent.tsx
Environment information:
typescript
version: 4.1.5react
version: 17@emotion/react
version: 11
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:5 (1 by maintainers)
Top Results From Across the Web
react typescript with function passed as prop, but can't access
I want to practice some complex feature by passing function as prop to child component. I remember 'this.props' allows me to access all...
Read more >Passing props in React using Typescript - DEV Community
I've recently been working on a project and attempting to teach myself a bit of TypeScript as I go. It's been.... interesting, to...
Read more >Documentation - Decorators - TypeScript
A Property Decorator is declared just before a property declaration. A property decorator cannot be used in a declaration file, or in any...
Read more >Documentation - Everyday Types - TypeScript
The type names String , Number , and Boolean (starting with capital ... When a value is of type any , you can...
Read more >Documentation - Classes - TypeScript
Just like with const , let , and var , the initializer of a class property will be used to infer its type:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If I remember correctly many people were trying to solve this typing problem in various different libraries and it always came with a severe performance cost. If somebody solves it without degrading performance though - I would be open to merging a PR introducing this.
I solved it by using the
withComponent
tag. https://emotion.sh/docs/typescript#withcomponentAlthough it is not ideal 😃