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 support for TSAsExpressions when trying to stringify expressions #634

Merged
merged 2 commits into from
Jul 2, 2022

Conversation

ggascoigne
Copy link
Contributor

Using a combination of forwardRefs and generics leads to wanting to use type assertions to retain the generic nature of the wrapped class. This plays rather poorly with propTypes. After a lot of mucking around I decided to simply assert the desired type when setting propTypes and defaults.

This leads to code like this:

(MenuItem as ComponentObjectOf<typeof MenuItem>).propTypes - {...}

This change extends expressionTo.toArray to deal with the typescript expression.

Using a combination of forwardRefs and generics leads to wanting to use type assertions to retain the generic nature of the wrapped class.  This plays rather poorly with propTypes.  After a lot of mucking around I decided to simply assert the desired type when setting propTypes and defaults.

 This leads to code like this:

 ```tsx
 (MenuItem as ComponentObjectOf<typeof MenuItem>).propTypes - {...}
 ```

 This change extends expressionTo.toArray to deal with the typescript expression.
@danez danez merged commit 51e56b6 into reactjs:main Jul 2, 2022
danez pushed a commit that referenced this pull request Jul 2, 2022
…ions (#634)

Using a combination of forwardRefs and generics leads to wanting to use type assertions to retain the generic nature of the wrapped class.  This plays rather poorly with propTypes.  After a lot of mucking around I decided to simply assert the desired type when setting propTypes and defaults.

 This leads to code like this:

 ```tsx
 (MenuItem as ComponentObjectOf<typeof MenuItem>).propTypes - {...}
 ```

 This change extends expressionTo.toArray to deal with the typescript expression.

Co-authored-by: Daniel Tschinder <231804+danez@users.noreply.github.com>
# Conflicts:
#	src/__tests__/__snapshots__/main-test.js.snap
#	src/utils/__tests__/expressionTo-test.ts
@danez danez mentioned this pull request Jul 2, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants