You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the common tsconfig, set noUncheckedIndexedAccess to true
In packages were we do not have instances of this fixed, explicitly set to false with the goal of slowly migrate these to true
Fixup in StatefulCallClient packlet and Calling-Component-Bindings packlet as examples
Why
We have had several bugs stemming from this issue (often these lead to app crashes).
As an example: What happens is const a: string = some_array[5]; will type a as string. However this is not always the case! if some_array[5] is beyond the range of the array then a is undefined. This causes exceptions, for example if a.someFn() is called, it will throw saying someFn does not exist on undefined. Really a should've been typed as string | undefined then developer handles the undefined case. This is easily gated and handled at compile time with noUncheckedIndexedAccess flag.
The reason will be displayed to describe this comment to others. Learn more.
The ? is added because context.getState().callsEnded[mockCallId] now correctly returns Call | undefined (importantly the | undefined is now added to typescripts interpretation of the return type because the call is accessed via object[key] where key isn't guaranteed to exist)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
noUncheckedIndexedAccesstotrueWhy
We have had several bugs stemming from this issue (often these lead to app crashes).
As an example: What happens is
const a: string = some_array[5];will typeaasstring. However this is not always the case! ifsome_array[5]is beyond the range of the array thenaisundefined. This causes exceptions, for example ifa.someFn()is called, it will throw sayingsomeFndoes not exist onundefined. Really a should've been typed asstring | undefinedthen developer handles the undefined case. This is easily gated and handled at compile time withnoUncheckedIndexedAccessflag.How Tested
CI only