-
Notifications
You must be signed in to change notification settings - Fork 326
TypeScript error while using stylex.create
after 0.13.0 update - the inferred type cannot be named without a reference
#1070
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
Comments
stylex.create
after 0.13.0 update - the inferred type cannot be named without a reference
The types are all in the package and the export map points to them. Have a look through the published code and let me know if you can tell why you're getting that error now - https://www.npmjs.com/package/@stylexjs/stylex/v/0.13.0?activeTab=code |
These types which are exported here under “types” key doesn’t include all types necessary to generate declaration file. At the screen in the issue you can see that hovered type for the style includes “StyleXClassNameFor” but this type isn’t exported anywhere in public API - hence TS can’t generate the declaration file for it. I hope this explanation is clearer? 😃 What I was referring to was that this entry point got removed from 0.13.0: |
|
Currently From the intellisense screenshot you can see that TS infers type of this variable as some nested Readonly object which has property with value of
Where XXX would be something like
But it’s impossible because “StyleXClassNameFor” isn’t exported anywhere. It’s the same if user wanted to annotate it manually exactly right - it’s impossible (without stuff like |
Typescript made a change somewhat recently where types that don't ever need to be typed manually, such as Interestingly, the types don't actually have to be imported, they only need to be exported from the package, so typescript can represent them in terms of imports. I haven't quite wrapped my head around the exact requirements, but that seems to be the general idea. |
Still seeing this with 0.13.1
looks like this commit only fixed this issue partially |
Describe the issue
Hello 👋
It seems to be somewhat similar to #857 - in 0.13.0 entry point with StyleXTypes were removed. When using
stylex.create
I'm getting type errors because TypeScript can't generated type without having access to e.g.StyleXClassNameFor
(in my tests re-exporting it from package fixed this particular error but I'm unsure whether there're some more cases where it'd fail.If I use any
stylex.create
and TS is configured to generate types for given package it errors:Expected behavior
Project can be properly typechecked via tsc when declaration generation is enabled and
stylex.create
results are exportedSteps to reproduce
I've created small reproduction: https://github.com/pawelblaszczyk5/stylex-incorrect-types-repro
Test case
and TypeScript with
declaration
option enabledAdditional comments
As mentioned - it seems like the whole entry point with types got removed from
package.json
- it seems like some of these types are needed for TS so it can properly build project. In my case I'm using monorepo and having shared styles in a package which is built and I needd.ts
files for itThe text was updated successfully, but these errors were encountered: