You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get a TS error when I try to directly export a Pattern without explicitly typing its type:
The inferred type of 'MY_PATTERN' cannot be named without a reference to '../.yarn/cache/ts-pattern-npm-5.4.0-2464380e11-f757dd3259.zip/node_modules/ts-pattern/dist/types/Pattern'. This is likely not portable. A type annotation is necessary.
TypeScript playground with a minimal reproduction case
Directly export the needed types in the package.json of ts-pattern
Put the needed types in a namespace, use it in all the other files and then export that namespace
I think the first solution is the simplest and it won't modify the inferred type names when hovering any ts-pattern functions. The only drawback is that internal types will be exposed through ts-pattern/types but I think that's worth it. I'll make a PR for this!
The text was updated successfully, but these errors were encountered:
Having the same problem; I'm missing the Chainable and GuardP types to be able to create a reusable pattern. @gvergnaud, should I whip up another PR, or is someone already on this?
Describe the bug
When working in a yarn project with many workspaces, and having this
compilerOptions
in theirtsconfig.json
:I get a TS error when I try to directly export a
Pattern
without explicitly typing its type:TypeScript playground with a minimal reproduction case
Example: Playground
Versions
Possible solutions
In order to solve this, we could:
package.json
ofts-pattern
I think the first solution is the simplest and it won't modify the inferred type names when hovering any ts-pattern functions. The only drawback is that internal types will be exposed through
ts-pattern/types
but I think that's worth it. I'll make a PR for this!The text was updated successfully, but these errors were encountered: