mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
66 lines
2.6 KiB
Plaintext
66 lines
2.6 KiB
Plaintext
//// [tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts] ////
|
|
|
|
=== derivedClassConstructorWithoutSuperCall.ts ===
|
|
// derived class constructors must contain a super call
|
|
|
|
class Base {
|
|
>Base : Symbol(Base, Decl(derivedClassConstructorWithoutSuperCall.ts, 0, 0))
|
|
|
|
x: string;
|
|
>x : Symbol(Base.x, Decl(derivedClassConstructorWithoutSuperCall.ts, 2, 12))
|
|
}
|
|
|
|
class Derived extends Base {
|
|
>Derived : Symbol(Derived, Decl(derivedClassConstructorWithoutSuperCall.ts, 4, 1))
|
|
>Base : Symbol(Base, Decl(derivedClassConstructorWithoutSuperCall.ts, 0, 0))
|
|
|
|
constructor() { // error
|
|
}
|
|
}
|
|
|
|
class Base2<T> {
|
|
>Base2 : Symbol(Base2, Decl(derivedClassConstructorWithoutSuperCall.ts, 9, 1))
|
|
>T : Symbol(T, Decl(derivedClassConstructorWithoutSuperCall.ts, 11, 12))
|
|
|
|
x: T;
|
|
>x : Symbol(Base2.x, Decl(derivedClassConstructorWithoutSuperCall.ts, 11, 16))
|
|
>T : Symbol(T, Decl(derivedClassConstructorWithoutSuperCall.ts, 11, 12))
|
|
}
|
|
|
|
class Derived2<T> extends Base2<T> {
|
|
>Derived2 : Symbol(Derived2, Decl(derivedClassConstructorWithoutSuperCall.ts, 13, 1))
|
|
>T : Symbol(T, Decl(derivedClassConstructorWithoutSuperCall.ts, 15, 15))
|
|
>Base2 : Symbol(Base2, Decl(derivedClassConstructorWithoutSuperCall.ts, 9, 1))
|
|
>T : Symbol(T, Decl(derivedClassConstructorWithoutSuperCall.ts, 15, 15))
|
|
|
|
constructor() { // error for no super call (nested scopes don't count)
|
|
var r2 = () => super(); // error for misplaced super call (nested function)
|
|
>r2 : Symbol(r2, Decl(derivedClassConstructorWithoutSuperCall.ts, 17, 11))
|
|
}
|
|
}
|
|
|
|
class Derived3<T> extends Base2<T> {
|
|
>Derived3 : Symbol(Derived3, Decl(derivedClassConstructorWithoutSuperCall.ts, 19, 1))
|
|
>T : Symbol(T, Decl(derivedClassConstructorWithoutSuperCall.ts, 21, 15))
|
|
>Base2 : Symbol(Base2, Decl(derivedClassConstructorWithoutSuperCall.ts, 9, 1))
|
|
>T : Symbol(T, Decl(derivedClassConstructorWithoutSuperCall.ts, 21, 15))
|
|
|
|
constructor() { // error
|
|
var r = function () { super() } // error
|
|
>r : Symbol(r, Decl(derivedClassConstructorWithoutSuperCall.ts, 23, 11))
|
|
}
|
|
}
|
|
|
|
class Derived4<T> extends Base2<T> {
|
|
>Derived4 : Symbol(Derived4, Decl(derivedClassConstructorWithoutSuperCall.ts, 25, 1))
|
|
>T : Symbol(T, Decl(derivedClassConstructorWithoutSuperCall.ts, 27, 15))
|
|
>Base2 : Symbol(Base2, Decl(derivedClassConstructorWithoutSuperCall.ts, 9, 1))
|
|
>T : Symbol(T, Decl(derivedClassConstructorWithoutSuperCall.ts, 27, 15))
|
|
|
|
constructor() {
|
|
var r = super(); // ok
|
|
>r : Symbol(r, Decl(derivedClassConstructorWithoutSuperCall.ts, 29, 11))
|
|
>super : Symbol(Base2, Decl(derivedClassConstructorWithoutSuperCall.ts, 9, 1))
|
|
}
|
|
}
|