🔎 Search Terms
presence of export narrowing typescript typecheck type checking export statement
🕗 Version & Regression Information
- This changed between versions 5.4.5 and 5.5.3
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.5.3#code/MYewdgzgLgBAHgLhgBQIYCcoEtUBsA8ASgKajoAm+YArgLYBGx6ANDAN6pLTpZgDmAXwB8QmAF52AgNwAoGbmKws4mAFZZWAGYAKOAG0sAXQCU7GTHgHDAOlQqA5AAtiuXCHuyLoSLE0r9RrIA9EEWYTAAegD8MgJyITBQ6ACeMNRgALSgtLTEYNj8iY5YEDC4vMQyCcRwAA4gmDDe0Glg6C6oUMTkACrFhRIALFJAA
💻 Code
constx: Partial<Record<number,{a: string}>>={};leti=5;if(x[i]){x[i].a='hello';}// try un-commenting this line// export const unrelatedThing = 4;🙁 Actual behavior
The type narrowing for an index type did not work unless an export was included.
🙂 Expected behavior
The export should not affect the compilation or typechecking of a file at all.
Additional information about the issue
This could possibly be a bug with just the TS playground; I did not test it on my machine.
🔎 Search Terms
presence of export narrowing typescript typecheck type checking export statement
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.5.3#code/MYewdgzgLgBAHgLhgBQIYCcoEtUBsA8ASgKajoAm+YArgLYBGx6ANDAN6pLTpZgDmAXwB8QmAF52AgNwAoGbmKws4mAFZZWAGYAKOAG0sAXQCU7GTHgHDAOlQqA5AAtiuXCHuyLoSLE0r9RrIA9EEWYTAAegD8MgJyITBQ6ACeMNRgALSgtLTEYNj8iY5YEDC4vMQyCcRwAA4gmDDe0Glg6C6oUMTkACrFhRIALFJAA
💻 Code
🙁 Actual behavior
The type narrowing for an index type did not work unless an
exportwas included.🙂 Expected behavior
The
exportshould not affect the compilation or typechecking of a file at all.Additional information about the issue
This could possibly be a bug with just the TS playground; I did not test it on my machine.