-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
StyledComponent: More accurate component constraint for TS 4.2 #50046
StyledComponent: More accurate component constraint for TS 4.2 #50046
Conversation
This change makes styled-components pass compilation on Typescript 4.2, which correctly propagates type parameter constraints through certain complex conditional types. Old versions of typescript just dropped the constraint by mistake, so this inconsistency was just not checked before. I'm not certain this is the right solution; in particular, it may be a lot slower. I hope not, because I have no idea what the right fix is otherwise!
Hey @sandersn, 😒 Your PR doesn't modify any tests, so it's hard to know what's being fixed, and your changes might regress in the future. Please consider adding tests to cover the change you're making. Including tests allows this PR to be merged by yourself and the owners of this module. This can potentially save days of time for you. |
@sandersn Thank you for submitting this PR! This is a live comment which I will keep updated. 1 package in this PRCode ReviewsThis PR can be merged once it's reviewed by a DT maintainer. Status
Once every item on this list is checked, I'll ask you for permission to merge and publish the changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 50046,
"author": "sandersn",
"headCommitAbbrOid": "ee98c46",
"headCommitOid": "ee98c46b741b0072da9a99e7ee54fe339aa3f416",
"lastPushDate": "2020-12-09T22:10:33.000Z",
"lastActivityDate": "2020-12-10T00:45:51.000Z",
"maintainerBlessed": false,
"hasMergeConflict": false,
"isFirstContribution": false,
"popularityLevel": "Popular",
"pkgInfo": [
{
"name": "styled-components",
"kind": "edit",
"files": [
{
"path": "types/styled-components/index.d.ts",
"kind": "definition"
}
],
"owners": [
"Igorbek",
"Igmat",
"lavoaster",
"Jessidhia",
"jkillian",
"eps1lon",
"flavordaaave",
"wagerfield",
"Lazyuki",
"mgoszcz2",
"danilofuchs"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Popular"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "eps1lon",
"date": "2020-12-10T00:45:51.000Z",
"isMaintainer": false
}
],
"ciResult": "pass"
} |
🔔 @Igorbek @Igmat @lavoaster @Jessidhia @jkillian @eps1lon @flavordaaave @wagerfield @Lazyuki @mgoszcz2 @danilofuchs — please review this PR in the next few days. Be sure to explicitly select |
Inspecting the JavaScript source for this package found some properties that are not in the .d.ts files. styled-components (unpkg)was missing the following properties:
|
👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings. Let’s review the numbers, shall we? Comparison details 📊
It looks like nothing changed too much. I won’t post performance data again unless it gets worse. |
This change makes styled-components pass compilation on Typescript 4.2, which correctly propagates type parameter constraints through certain
complex conditional types. Old versions of typescript just dropped the constraint by mistake, so this inconsistency was just not checked before.
I'm not certain this is the right solution; in particular, it may be a lot slower. I hope not, because I have no idea what the right fix is otherwise!
Edit:
keyof JSX.Intrinsic
tostring
might also fix the error, at the cost of some type accuracy.