As someone who is new to TypeScript, I have a good understanding of the basics but recently came across a typecast error that I am struggling to solve.
const [full, id]: string | null = /.*media\/[^\/]+\/(.*)/.exec(item.uri)
When it comes to [full, id], TypeScript throws an error.
The error message states: Type 'RegExpExecArray | null' is not assignable to type 'string | null'.
Type 'RegExpExecArray' is not assignable to type 'string'.ts(2322)
Type 'string | null' must have a '[Symbol.iterator]()' method that returns an iterator.
While typecasting to Any works, I am determined to find the correct solution as recommended by TypeScript. Unfortunately, my search for an answer has been unsuccessful so far, leading me to seek guidance here. Any help would be greatly appreciated!
Thank you!