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
read-only array methods like map get the index as number, which makes some operations cumbersome if setting "noUncheckedIndexedAccess": true in tsconfig.json:
declareinterfaceReadonlyArray<T>{map<U,Aextendsreadonlyunknown[]= this extendsreadonly[...infer X] ? X : never,IextendsIndices<A>=Indices<A>>(callbackfn: (value: A[I],index: I,array: A)=>U,thisArg?: any): U[];}
This also improves typing for the array parameter of callbackfn by actually creating a tuple type for array instead of an array of a union.
I could not yet get following working however: the index parameter is the union of all possible indices, however each iteration only ever has one possible index. This leads to following:
read-only array methods like
map
get the index as number, which makes some operations cumbersome if setting"noUncheckedIndexedAccess": true
intsconfig.json
:Proposal: type index as a tuple of all possible indices.
I also have a version of getting all possible indices of an array myself which does not use recursion. Maybe that helps implementing it:
The text was updated successfully, but these errors were encountered: