Which fix removes the bug?
const ids: number[] = [];
ids.push('7' as unknown as number);
- Parse the string first
- Widen the array type
- Use a const assertion
- Declare ids as any[]
The double assertion silences the compiler while leaving a string in a number array.
Play Problem Solving ▸