TypeScript/tests/baselines/reference/superCallParameterContextualTyping3.types
2015-04-15 16:44:20 -07:00

74 lines
1.7 KiB
Plaintext

=== tests/cases/conformance/expressions/contextualTyping/superCallParameterContextualTyping3.ts ===
interface ContextualType<T> {
>ContextualType : ContextualType<T>
>T : T
method(parameter: T): void;
>method : (parameter: T) => void
>parameter : T
>T : T
}
class CBase<T> {
>CBase : CBase<T>
>T : T
constructor(param: ContextualType<T>) {
>param : ContextualType<T>
>ContextualType : ContextualType<T>
>T : T
}
foo(param: ContextualType<T>) {
>foo : (param: ContextualType<T>) => void
>param : ContextualType<T>
>ContextualType : ContextualType<T>
>T : T
}
}
class C extends CBase<string> {
>C : C
>CBase : CBase<T>
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
}
});
}
}