-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed as not planned
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
π Search Terms
discriminate union in nested objects
π Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ for entries about generic.
β― Playground Link
π» Code
const config: { [T in Keys]: { logger: Logger<T>; } } = { ... };
const loggers: { [T in Keys]?: Logger<T>; } = { ... };
items.forEach(<T extends Keys>(key: T) => {
// TS does not understand that Loggers[T] (type of getters[key]) is the same as Logger<T> (type of config[key].logger)
getters[key] = config[key].logger;
});π Actual behavior
TS does not understand that Loggers[T] (type of getters[key]) is the same as Logger (type of config[key].logger)
π Expected behavior
TS should understand that Loggers[T] (type of getters[key]) is the same as Logger (type of config[key].logger)
Additional information about the issue
No response
bernardobelchior
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed