Bug Report
🔎 Search Terms
Array<T>- const integer index
- not overflow index
- indicate element type from array and array index
- array element type might be undefined
🕗 Version & Regression Information
- This is a crash
- This changed between versions ______ and _______
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ Playground Link
Playground link with relevant code
💻 Code
functionfn(s: string){console.log(s)}functionreproduce(input: string[]){switch(reproduce.length){case0asconst:
case1asconst:
fn(input[0asconst])breakdefault:
break}}constinput: string[]=[]switch(input.length){case0asconst:
case1asconst:
fn(input[0asconst])breakdefault:
break}🙁 Actual behavior
// fn(input[0 as const])
Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.
🙂 Expected behavior
// fn(input[0 as const])
OK
Additional
I guess there is already an issue.
But seems not easy to find which to track on from tons of issues.
Bug Report
🔎 Search Terms
Array<T>🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
🙂 Expected behavior
Additional
I guess there is already an issue.
But seems not easy to find which to track on from tons of issues.