One list of roles

One list can define which role names the program accepts.

your task

Derive Role from the supplied ROLES list. Make a successful isRole check tell TypeScript the input is a Role. Both versions must compile and reject names outside their own list.

roles.ts copies the role names by hand. The caller also gets a type error after isRole returns true. TypeScript still treats the checked value as ordinary text.

Starter code
or press Ctrl EnterNot run yet

checks

Not run yetOriginal rolesThis check uses the supplied files as they are. The list contains guest, member, and admin.

Expected result: no type errors.

Not run yetRoles with owner addedThe team that owns role-list.ts added “owner”. The caller now uses that role.

Expected result: no type errors.