filmov
tv
TypeScript Plugged In: Compiler Flags: noUncheckedIndexAccess
Показать описание
When using array index access in #typescript, watch out for non-existent elements, as default compiler options will make the compiler infer that all elements of arrays, no matter how big the index is, would exist. Which sometimes is not only true, but could even be illogical. This is where noUncheckedIndexAccess compiler flag come into play.
00:00 intro
00:34 non-existent elements appear to exist
01:36 use type guards when indexing elements
02:05 noUncheckedIndexAccess compiler flag
03:25 obviously existing elements also need to be checked