TypeScript error while using stylex.types
- the inferred type cannot be named without a reference
#857
Labels
bug
Something isn't working
Describe the issue
Hello 👋
stylex.types
functions are typed to return specific class instances for each of the types - all of these are imported fromVarTypes
file. However, these aren't exported anywhere so TypeScript can't properly typecheck/generate declaration for this. If I didn't usestylex.types
and just use standard string value - declaration file would look like this:In cases where I use
stylex.types
there's no type that it can use in place for a given var value - because as mentioned, it's not exported.Here you can see TS error that's caused by this:
Expected behavior
Project can be properly typechecked via
tsc
when declaration generation is enabled andstylex.types
are used on exported memberSteps to reproduce
tsconfig
by settingdeclaration
totrue
stylex.defineVars
from a filetsc
failingI've created small reproduction: https://github.com/pawelblaszczyk5/stylex-incorrect-types-repro
Test case
Enable
declaration
in yourtsconfig
and try this code anywhere:Additional comments
I'm pretty sure this could be fixed by just exporting the classes that are used as a return type from
stylex.types
functionsThe text was updated successfully, but these errors were encountered: