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:
string
doesn't match up with
string[]
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[];