-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Types: Missing overload for default export from @emotion/styled ? #1640
Comments
+ latest `typescript` as `devDependency` on the root level + `tsconfig.json` & types for dependencies per package + npm script `types` per package issue with types from `@emotion/styles` described in emotion-js/emotion#1640
Hi! Current typings (on master) are less than ideal - we have improvements in the works though. They are available on the |
Hi, I tried to switch just Here is the exact output (using typescript 3.7.2):
One more detail: I just verified that the problem is in the "second half" of the expression. PS: It seems a bit odd that the error message didn't change, I'll check again the the updates have been applied as expected, but not sure how soon I'm able to do that. Might take some days. |
It would be great if you could share the updated version of this so we could inspect the repro case quickly (without setting things ourselves - which we could mess up). |
as recommended in emotion-js/emotion#1640 has warnings when running `yarn`
ping (just in case the above commit didn't trigger any notification): the fork has been updated with your suggestion. And I also checked that they have been applied as expected. So steps to reproduce:
|
Thanks for the ping - referencing the issue from a commit didnt trigger any notification. I’ll try look into it this week |
I've started looking into this. I see the error, but I'm wondering about one thing. Are you trying to generate types here from vanilla JS file? |
Yes, exactly:
But also not only "vanilla JS" files: the types for all the things that are imported are available to typescript. They are also generated, but when there is an error like the one I described it just put's (And there are also ways to add more type information using jsdoc, so without changing the actual code.) But for this to work properly I need to understand what kind of call this actually is. (Maybe it can just not be inferred but could be added in another way.) |
I've made some progress - you had 2 copies of I get now:
which is caused by I'm not sure how to fix it but in general Theme-related types are being reworked now in #1609 and also I've noticed that there is some mess around Interpolation & CSSInterpolation types. I plan to dig deeper into those and cleanup this and I hope both of those will fix a problem with that |
Thx for digging into it to this level. I subscribed to the PR you mentioned, so I'll be informed when it lands. |
While digging into it I've even encountered:
😅 That got me to realize there are 2 conflicting versions of csstype. I believe that last part (that |
I've released emotion/packages/core/types/index.d.ts Line 99 in 0362fd2
and it's not compatible with this: emotion/packages/styled/types/base.d.ts Lines 74 to 79 in 0362fd2
But I'm also not sure if you should try to compose it like this. I don't know much about styled-system so maybe I'm missing something, but at least from emotion's perspective, |
If I understood you correctly you are not sure why Maybe we can invite @jxnblk to the discussion to help us understand that? (Not regarding types, just the code.) |
Yes. I suppose emotion/packages/core/types/index.d.ts Lines 97 to 101 in 0362fd2
|
@karfau the manually added |
Ok, it makes sense - but it still doesn't play OK with defined types because we want to target a styled component with this but this I'm not entirely sure about this - but maybe you could add inline annotations (using comments - I think TS supports this) to cast this to any (for starters) and maybe try to type it to an expected type. Don't have a better idea than this right now. Because of mismatching versions of emotion in that repository with current v11 I had to do extra manual steps each time to get to that |
The problem
I wanted to generate types for rebass modules using the existing js files (for more details read the Additional Context section).
But the way the rebass lib uses @emotion/styled doesn't seem to be supported by the current types, when running
tsc --declaration
(with some other basic configuration to get everything together) the following error is reported:src/index.js:50:28 - error TS2769: No overload matches this call. ...
I would love be able to add the missing overload to the types, but after looking at the nested modules the are involved I was kinda lost when reaching https://github.com/emotion-js/emotion/blob/master/packages/serialize/src/index.js#L342
My understanding of the argument types passed to styled in @rebass/reflexbox are
Maybe these
transformers
are of typeFunctionInterpolation
but the allowed types would beInterpolation
(from the same file)?Proposed solution
Adding the missing overload to the types.
Alternative solutions
Help me to understand/find the related documentation so I can create a PR.
Additional context
The types for the main rebass module are "only" existing in DefinitelyTyped, are incomplete and hardly maintained and the types for other
@rebass/*
modules don't exist as far as I know.So I wanted to experiment if there is a(n "easy") way to create and maintain the types by generating the definition files from the js source files.
It's possible to do that and since the underlying modules all offer types I was quite hopefull.
On the lowest level of rebass is
@rebass/reflexbox
so I started with it.(I pushed my changes to my fork: https://github.com/karfau/rebass/tree/generating-types)
Potentially related issues (I'm not sure):
The text was updated successfully, but these errors were encountered: