TypeScript Version: 4.0.2
Search Terms: generic constraint, extends infer
Code
typeInferGenericConstraint<Fn>=Fnextends<Textends infer Constraint>(arg: T)=>any
? Constraint
: never;typeGenericFunctionExample=<Textendsnumber>(arg: T)=>void;typeInferredConstraint=InferGenericConstraint<GenericFunctionExample>;
Expected behavior:
- Preferred:
InferredConstraint is number. - Alternative:
infer declaration is disallowed within a generic constraint clause.
Actual behavior:InferredConstraint is never
Playground Link:https://tsplay.dev/gWoYlN
Related Issues:#1213
TypeScript Version: 4.0.2
Search Terms: generic constraint, extends infer
Code
Expected behavior:
InferredConstraintisnumber.inferdeclaration is disallowed within a generic constraint clause.Actual behavior:
InferredConstraintisneverPlayground Link:https://tsplay.dev/gWoYlN
Related Issues:#1213