1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
=== tests/cases/conformance/expressions/contextualTyping/superCallParameterContextualTyping3.ts ===
interface ContextualType<T> {
method(parameter: T): void;
>method : (parameter: T) => void
>parameter : T
}
class CBase<T> {
>CBase : CBase<T>
constructor(param: ContextualType<T>) {
>param : ContextualType<T>
}
foo(param: ContextualType<T>) {
>foo : (param: ContextualType<T>) => void
>param : ContextualType<T>
}
}
class C extends CBase<string> {
>C : C
>CBase : CBase<string>
constructor() {
// Should be okay.
// 'p' should have type 'string'.
super({
>super({ method(p) { p.length; } }) : void
>super : typeof CBase
>{ method(p) { p.length; } } : { method(p: string): void; }
method(p) {
>method : (p: string) => void
>p : string
p.length;
>p.length : number
>p : string
>length : number
}
});
// Should be okay.
// 'p' should have type 'string'.
super.foo({
>super.foo({ method(p) { p.length; } }) : void
>super.foo : (param: ContextualType<string>) => void
>super : CBase<string>
>foo : (param: ContextualType<string>) => void
>{ method(p) { p.length; } } : { method(p: string): void; }
method(p) {
>method : (p: string) => void
>p : string
p.length;
>p.length : number
>p : string
>length : number
}
});
}
}
|