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

Cannot infer the 'as' and 'forwardedAs' props by React.ComponentProps #4294

Open
XaveScor opened this issue Apr 24, 2024 · 0 comments
Open

Comments

@XaveScor
Copy link

XaveScor commented Apr 24, 2024

Environment

typescript: 5.4.5
styled-components: 6.1.8

Reproduction

import * as React from "react";
import styled from "styled-components";

const A = styled.div``;

// Shows a typescript error in v5.4.5
type T1 = React.ComponentProps<typeof A>["as"]
type T2 = React.ComponentProps<typeof A>["forwardedAs"]

// but no error here
<A as='a' />;
<A forwardedAs='a' />;

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAKjgQwM5wEoFNkGN4BmUEIcARFDvmQNwBQokscqMAngDZYAmcRJ5Vpx4BaXCUgA7LJJipadOuMms4AQTgBeFuy7cAdN2AA3AAan6dAPRW4AZQAWEAO7pkcdmCypcUYGHgsKGIoOGBJOGMAVn0AFn0ouk8sOAAVAEYtTCoYfQBhCQhpWQAFYjBUAB5kiAJ1AD4AbTI0MgBdJLYvNIAmLOw8XILwIpkYMogK6q6sWobmgmhnZChuHjV5DutbACMAV3hJCDggkLgHIKw6So00TQByZHu4K3r6G74llbXuDYenl5vIA

Steps to reproduce

  1. Open typescript playground

Expected Behavior

as and forwardedAs props are available inside React.ComponentProps type

Actual Behavior

There are no these props

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

No branches or pull requests

1 participant