birdofpreyru/react-global-state

Double check why variable types not resolved on composed paths with number pieces

Closed this issue · 3 comments

I.e. with

type StateT = {
  key: { [id: string]: 'X' },
};

the value type at the path key[${x}] evaluates correctly to X, but with id typed as number it does not.

It will be mostly solved by the Lodash patch DefinitelyTyped/DefinitelyTyped#69696

That path still does not cover the following corner case:

type ArrT = string[];

type T1 = GetFieldType<ArrT, `[${number}]`>; // Resolves to "undefined" rather than "string"
type T2 = GetFieldType<ArrT, number>; // This works, thought, correctly resolving to "string"

Updated PR should cover all cases

It is effectively the same as #89, thus ready.