TypeScript Generic Constraint Language Collocations
Practise the standard verbs for constraining and testing TypeScript generics.
0 / 5 completed
1 / 5
Fill in: 'We ___ a generic type parameter to an interface with the properties actually used, so a caller can't pass a type missing the field the function relies on.'
We 'constrain a parameter' — the standard, established TypeScript collocation for bounding a generic with an extends clause. The other options aren't the recognised term here.
2 / 5
Fill in: 'Leaving a generic parameter unconstrained when the function actually needs a specific shape can ___ a caller passing a completely incompatible type without any compiler complaint.'
We say a missing constraint will 'leave' incompatible types accepted — the standard, natural collocation for the resulting gap. The other options aren't idiomatic here.
3 / 5
Fill in: 'We ___ the inferred type at a generic call site deliberately, hovering in the editor, so an unexpected widened type isn't discovered only once a downstream call fails.'
We 'check' an inferred type — the standard, simple collocation for confirming what the compiler resolved a generic to. The other options are less idiomatic here.
4 / 5
Fill in: 'We ___ a default type for a generic parameter that's rarely overridden, so most call sites stay simple while the flexibility remains available when it's actually needed.'
We 'set a default' — the standard, simple collocation for giving a generic parameter a fallback type. The other options are less idiomatic here.
5 / 5
Fill in: 'We ___ a conditional type against several representative inputs before shipping it, since a subtle distributive behaviour over unions can produce a surprising result for one edge case.'
We 'test' a type — the standard, simple collocation for validating a type-level construct's behaviour against real cases. The other options are less idiomatic here.