Exploring the concept of const assertions
in TypeScript
Looking at the array allDeviceTypes
depicted below, VSCode indicates it has a return type of string[]
when hovering over the variable name.
https://i.sstatic.net/gIYch.png
However, upon using a const assertion to narrow down the type, I observe the desired narrowed type, but encounter an error from TSLint:
This assertion is unnecessary since it does not change the type of the expression. (no-unnecessary-type-assertion)tslint(1)
So, what's the verdict? Is the type of the expression truly unaltered or could there be a display issue with VSCode 1.40.0
and TSlint 5.11.0
?