mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
48 lines
1011 B
TypeScript
48 lines
1011 B
TypeScript
//// [tests/cases/compiler/baseIndexSignatureResolution.ts] ////
|
|
|
|
//// [baseIndexSignatureResolution.ts]
|
|
class Base { private a: string; }
|
|
class Derived extends Base { private b: string; }
|
|
|
|
// Note - commmenting "extends Foo" prevents the error
|
|
interface Foo {
|
|
[i: number]: Base;
|
|
}
|
|
interface FooOf<TBase extends Base> extends Foo {
|
|
[i: number]: TBase;
|
|
}
|
|
var x: FooOf<Derived> = null;
|
|
var y: Derived = x[0];
|
|
|
|
/*
|
|
// Note - the equivalent for normal interface methods works fine:
|
|
interface A {
|
|
foo(): Base;
|
|
}
|
|
interface B<TBase extends Base> extends A {
|
|
foo(): TBase;
|
|
}
|
|
var b: B<Derived> = null;
|
|
var z: Derived = b.foo();
|
|
*/
|
|
|
|
//// [baseIndexSignatureResolution.js]
|
|
"use strict";
|
|
class Base {
|
|
}
|
|
class Derived extends Base {
|
|
}
|
|
var x = null;
|
|
var y = x[0];
|
|
/*
|
|
// Note - the equivalent for normal interface methods works fine:
|
|
interface A {
|
|
foo(): Base;
|
|
}
|
|
interface B<TBase extends Base> extends A {
|
|
foo(): TBase;
|
|
}
|
|
var b: B<Derived> = null;
|
|
var z: Derived = b.foo();
|
|
*/
|