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
In version 4.2.0-dev.20201115, InferredConstraint is unknown rather than never. I tried a large number of variations, but none of them can work around the fundamental fact that the type inferred for the constraint just isn’t right.
Now ConstraintOf<<T extends number>(arg: T) => void> evaluates to number. So that solves the problem that @lazytype was working on.
The bug should stay open, though, because as far as I can tell, the other variations on this idea should have worked, too, and it’s kind of madness that this one worked and those didn’t. If anything, this version makes way less sense. What’s occurring here is that trying to test Fn against (arg: infer Arg) => any seems to “fix” S as the broadest possible value, here number, before moving on—and so the Arg has that value. This works, but is pretty weird and counter-intuitive.
TypeScript Version: 4.0.2
Search Terms: generic constraint, extends infer
Code
Expected behavior:
InferredConstraint
isnumber
.infer
declaration is disallowed within a generic constraint clause.Actual behavior:
InferredConstraint
isnever
Playground Link: https://tsplay.dev/gWoYlN
Related Issues: #1213
The text was updated successfully, but these errors were encountered: