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
{{ message }}
Repository navigation
NonNullable is accidentally simplified away from generic index accessesΒ #50539
interfaceStateSchema{states?: {[key: string]: StateSchema;};}declareclassStateNode<TStateSchemaextendsStateSchema>{schema: TStateSchema;}// worked in 4.7 but perhaps accidentallytypeStateNodesConfigCurrent<TStateSchemaextendsStateSchema>={[KinkeyofTStateSchema["states"]]: StateNode<TStateSchema["states"][K]>;};// this OTOH should work right now but it doesn'ttypeStateNodesConfigNew<TStateSchemaextendsStateSchema>={[KinkeyofTStateSchema["states"]]: StateNode<NonNullable<TStateSchema["states"]>[K]>;};
π Actual behavior
NonNullable disappears when computing getConstraintFromIndexedAccess. Essentially this type:
In here, those {}[string | number | symbol] are just reduced to unknown and T & unknown gets reduced to T. So that's how NonNullable "disappears" here.
After updating from 4.7 to 4.8, I believe I'm running into a related issue. Unfortunately I'm not able to explain it in such technical detail but here's a reproducible:
typeOrdering<TOrderByextendsstring>={orderBy: TOrderBy}typeQuery<TOrderByextendsstring>={order?: Ordering<TOrderBy>}typeQueryHandler<TQueryextendsQuery<TOrderBy>,TOrderByextendsstring=NonNullable<TQuery["order"]>["orderBy"]// Worked in 4.7>={}
... does not satisfy the constraint 'string'.
... cannot be used to index type 'NonNullable...
Activity
kasparkallas commentedon Sep 1, 2022
After updating from 4.7 to 4.8, I believe I'm running into a related issue. Unfortunately I'm not able to explain it in such technical detail but here's a reproducible:
Playground Link
Disabling
strictNullCheckshides the problem.Andarist commentedon Sep 1, 2022
I can confirm that this is also fixed by my PR. I'm gonna add this as an additional test case in a moment