-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
TypeScript Version: 3.0.1-insiders.20180726
Search Terms: I don't even
Code
class Endpoint<T = {}> { // This actually has 2+ parameters
t!: T;
}
class ConfigReader<TEndpoint extends Endpoint> {
constructor(readonly endpoint: TEndpoint) { }
getValue(): NonNullable<TEndpoint['t']> {
return this.endpoint.t;
}
}
Expected behavior:
No compiler error
Actual behavior:
Type '{}' is not assignable to type 'NonNullable<TEndpoint["t"]>'.
Motivation:
In my actual code, ConfigReader
has 4 type parameters, each of which is a further config class with even more nested parameters. I'm trying to avoid putting ~15 type parameters on ConfigReader
by bundling them in this fashion, accepting a single type parameter for each top-level thing and accessing their nested type parameters via []
notation.
This works perfectly (so far), except for this issue.
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed