Closed
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.