Check if a string is included in a readonly string array in TypeScript

Viewed 26
const ReadOnlyStrings = ['a', 'b', 'c'] as const;
const fn = (key: string)=>{
  ReadOnlyStrings.includes(key);
}

Errors in code:
Argument of type 'string' is not assignable to parameter of type '"a" | "b" | "c"'.

How to advoids the error?

0 Answers
Related