TypeScript errors in Plain English

TypeScript Error Translator

Error #1

Conversion of type 'string' to type 'string[]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.


You can't use 'as' to convert string into a string[] - they don't share enough in common.


It looks like you're trying to use as to 'cast' one type into another. Your first type:


doesn't match up with


because there isn't what I call 'sufficient overlap' between them. I.e. they don't look enough like each other.

If you really meant to do this, you should cast string to unknown first. For example, if I wanted to cast string to string[], I'd need to write this code:

const a = 'wow' as unknown as string[];