Complete worked example
typescript
type Role={id:string;country:"US"|"UA"};
function selectCountry(roles:readonly Role[],country:Role["country"]):Role[]{return roles.filter(role=>role.country===country);}- Reasoning
- The finite country contract and immutable filtering behavior need distinct static and runtime checks.