Accept baselines

And the code is still wrong!
This commit is contained in:
Nathan Shively-Sanders
2021-11-03 13:29:57 -07:00
parent 22fa978438
commit 70447cbcc9
938 changed files with 13550 additions and 5927 deletions
+1 -1
View File
@@ -12712,7 +12712,7 @@ namespace ts {
}
else {
// TODO: should provide this=the 'this' argument of the call (if it's a call)
return (getDeclaredTypeOfSymbol(symbol) as InterfaceType).thisType;
return (getDeclaredTypeOfSymbol(symbol) as InterfaceType) //.thisType
}
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ class Board {
>this.ships.every(function (val) { return val.isSunk; }) : boolean
>this.ships.every : { <S extends Ship>(predicate: (value: Ship, index: number, array: Ship[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Ship, index: number, array: Ship[]) => unknown, thisArg?: any): boolean; }
>this.ships : Ship[]
>this : this
>this : Board
>ships : Ship[]
>every : { <S extends Ship>(predicate: (value: Ship, index: number, array: Ship[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: Ship, index: number, array: Ship[]) => unknown, thisArg?: any): boolean; }
>function (val) { return val.isSunk; } : (val: Ship) => boolean
@@ -13,14 +13,14 @@ module X.Y {
this.x = x;
>this.x = x : number
>this.x : number
>this : this
>this : Point
>x : number
>x : number
this.y = y;
>this.y = y : number
>this.y : number
>this : this
>this : Point
>y : number
>y : number
}
@@ -13,14 +13,14 @@ module X.Y {
this.x = x;
>this.x = x : number
>this.x : number
>this : this
>this : Point
>x : number
>x : number
this.y = y;
>this.y = y : number
>this.y : number
>this : this
>this : Point
>y : number
>y : number
}
@@ -20,13 +20,13 @@ class StringIterator {
};
}
[Symbol.iterator]() {
>[Symbol.iterator] : () => this
>[Symbol.iterator] : () => StringIterator
>Symbol.iterator : any
>Symbol : any
>iterator : any
return this;
>this : this
>this : StringIterator
}
}
@@ -31,14 +31,14 @@ module X.Y {
this.x = x;
>this.x = x : number
>this.x : number
>this : this
>this : Point
>x : number
>x : number
this.y = y;
>this.y = y : number
>this.y : number
>this : this
>this : Point
>y : number
>y : number
}
@@ -14,7 +14,7 @@ abstract class A {
>console : Console
>log : (...data: any[]) => void
>this.x : string
>this : this
>this : A
>x : string
}
}
@@ -14,7 +14,7 @@ abstract class A {
>console : Console
>log : (...data: any[]) => void
>this.x : string
>this : this
>this : A
>x : string
}
}
@@ -3,7 +3,9 @@ tests/cases/compiler/abstractPropertyInConstructor.ts(7,18): error TS2715: Abstr
tests/cases/compiler/abstractPropertyInConstructor.ts(9,14): error TS2715: Abstract property 'cb' in class 'AbstractClass' cannot be accessed in the constructor.
tests/cases/compiler/abstractPropertyInConstructor.ts(25,18): error TS2715: Abstract property 'prop' in class 'AbstractClass' cannot be accessed in the constructor.
tests/cases/compiler/abstractPropertyInConstructor.ts(25,18): error TS2729: Property 'prop' is used before its initialization.
tests/cases/compiler/abstractPropertyInConstructor.ts(37,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'AbstractClass'.
tests/cases/compiler/abstractPropertyInConstructor.ts(39,22): error TS2715: Abstract property 'prop' in class 'AbstractClass' cannot be accessed in the constructor.
tests/cases/compiler/abstractPropertyInConstructor.ts(54,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'DerivedAbstractClass'.
tests/cases/compiler/abstractPropertyInConstructor.ts(78,15): error TS2715: Abstract property 'x' in class 'C1' cannot be accessed in the constructor.
tests/cases/compiler/abstractPropertyInConstructor.ts(78,18): error TS2715: Abstract property 'y' in class 'C1' cannot be accessed in the constructor.
tests/cases/compiler/abstractPropertyInConstructor.ts(79,12): error TS2715: Abstract property 'x' in class 'C1' cannot be accessed in the constructor.
@@ -11,7 +13,7 @@ tests/cases/compiler/abstractPropertyInConstructor.ts(79,15): error TS2715: Abst
tests/cases/compiler/abstractPropertyInConstructor.ts(79,22): error TS2715: Abstract property 'y' in class 'C1' cannot be accessed in the constructor.
==== tests/cases/compiler/abstractPropertyInConstructor.ts (11 errors) ====
==== tests/cases/compiler/abstractPropertyInConstructor.ts (13 errors) ====
abstract class AbstractClass {
constructor(str: string, other: AbstractClass) {
this.method(parseInt(str));
@@ -60,6 +62,8 @@ tests/cases/compiler/abstractPropertyInConstructor.ts(79,22): error TS2715: Abst
constructor(str: string, other: AbstractClass, yetAnother: DerivedAbstractClass) {
super(str, other);
~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'AbstractClass'.
// there is no implementation of 'prop' in any base class
this.cb(this.prop.toLowerCase());
~~~~
@@ -79,6 +83,8 @@ tests/cases/compiler/abstractPropertyInConstructor.ts(79,22): error TS2715: Abst
constructor(str: string, other: AbstractClass, yetAnother: DerivedAbstractClass) {
super(str, other, yetAnother);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'DerivedAbstractClass'.
this.cb(this.prop);
}
@@ -9,7 +9,7 @@ abstract class AbstractClass {
this.method(parseInt(str));
>this.method(parseInt(str)) : void
>this.method : (num: number) => void
>this : this
>this : AbstractClass
>method : (num: number) => void
>parseInt(str) : number
>parseInt : (string: string, radix?: number) => number
@@ -20,7 +20,7 @@ abstract class AbstractClass {
>this.prop.toLowerCase() : string
>this.prop.toLowerCase : () => string
>this.prop : string
>this : this
>this : AbstractClass
>prop : string
>toLowerCase : () => string
@@ -31,14 +31,14 @@ abstract class AbstractClass {
this.prop = "Hello World";
>this.prop = "Hello World" : "Hello World"
>this.prop : string
>this : this
>this : AbstractClass
>prop : string
>"Hello World" : "Hello World"
}
this.cb(str);
>this.cb(str) : void
>this.cb : (s: string) => void
>this : this
>this : AbstractClass
>cb : (s: string) => void
>str : string
@@ -49,7 +49,7 @@ abstract class AbstractClass {
return this.prop;
>this.prop : string
>this : this
>this : AbstractClass
>prop : string
}
@@ -94,11 +94,11 @@ abstract class AbstractClass {
this.prop = this.prop + "!";
>this.prop = this.prop + "!" : string
>this.prop : string
>this : this
>this : AbstractClass
>prop : string
>this.prop + "!" : string
>this.prop : string
>this : this
>this : AbstractClass
>prop : string
>"!" : "!"
}
@@ -128,19 +128,19 @@ abstract class DerivedAbstractClass extends AbstractClass {
this.cb(this.prop.toLowerCase());
>this.cb(this.prop.toLowerCase()) : void
>this.cb : (s: string) => void
>this : this
>this : DerivedAbstractClass
>cb : (s: string) => void
>this.prop.toLowerCase() : string
>this.prop.toLowerCase : () => string
>this.prop : string
>this : this
>this : DerivedAbstractClass
>prop : string
>toLowerCase : () => string
this.method(1);
>this.method(1) : void
>this.method : (num: number) => void
>this : this
>this : DerivedAbstractClass
>method : (num: number) => void
>1 : 1
@@ -193,10 +193,10 @@ class Implementation extends DerivedAbstractClass {
this.cb(this.prop);
>this.cb(this.prop) : void
>this.cb : (s: string) => void
>this : this
>this : Implementation
>cb : (s: string) => void
>this.prop : string
>this : this
>this : Implementation
>prop : string
}
@@ -207,11 +207,11 @@ class Implementation extends DerivedAbstractClass {
this.cb(this.prop + n);
>this.cb(this.prop + n) : void
>this.cb : (s: string) => void
>this : this
>this : Implementation
>cb : (s: string) => void
>this.prop + n : string
>this.prop : string
>this : this
>this : Implementation
>prop : string
>n : number
}
@@ -261,25 +261,25 @@ abstract class C1 {
constructor() {
let self = this; // ok
>self : this
>this : this
>self : C1
>this : C1
let { x, y: y1 } = this; // error
>x : string
>y : any
>y1 : string
>this : this
>this : C1
({ x, y: y1, "y": y1 } = this); // error
>({ x, y: y1, "y": y1 } = this) : this
>{ x, y: y1, "y": y1 } = this : this
>({ x, y: y1, "y": y1 } = this) : C1
>{ x, y: y1, "y": y1 } = this : C1
>{ x, y: y1, "y": y1 } : { x: string; y: string; }
>x : string
>y : string
>y1 : string
>"y" : string
>y1 : string
>this : this
>this : C1
}
}
@@ -294,25 +294,25 @@ class C2 {
constructor() {
let self = this; // ok
>self : this
>this : this
>self : C2
>this : C2
let { x, y: y1 } = this; // ok
>x : string
>y : any
>y1 : string
>this : this
>this : C2
({ x, y: y1, "y": y1 } = this); // ok
>({ x, y: y1, "y": y1 } = this) : this
>{ x, y: y1, "y": y1 } = this : this
>({ x, y: y1, "y": y1 } = this) : C2
>{ x, y: y1, "y": y1 } = this : C2
>{ x, y: y1, "y": y1 } : { x: string; y: string; }
>x : string
>y : string
>y1 : string
>"y" : string
>y1 : string
>this : this
>this : C2
}
}
@@ -0,0 +1,21 @@
tests/cases/compiler/accessOverriddenBaseClassMember1.ts(9,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Point'.
==== tests/cases/compiler/accessOverriddenBaseClassMember1.ts (1 errors) ====
class Point {
constructor(public x: number, public y: number) { }
public toString() {
return "x=" + this.x + " y=" + this.y;
}
}
class ColoredPoint extends Point {
constructor(x: number, y: number, public color: string) {
super(x, y);
~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Point'.
}
public toString() {
return super.toString() + " color=" + this.color;
}
}
@@ -15,11 +15,11 @@ class Point {
>"x=" + this.x : string
>"x=" : "x="
>this.x : number
>this : this
>this : Point
>x : number
>" y=" : " y="
>this.y : number
>this : this
>this : Point
>y : number
}
}
@@ -50,7 +50,7 @@ class ColoredPoint extends Point {
>toString : () => string
>" color=" : " color="
>this.color : string
>this : this
>this : ColoredPoint
>color : string
}
}
@@ -32,7 +32,7 @@ class D extends C {
get p() { return this._secret } // error
>p : number
>this._secret : number
>this : this
>this : D
>_secret : number
set p(value) { this._secret = value } // error
@@ -40,7 +40,7 @@ class D extends C {
>value : number
>this._secret = value : number
>this._secret : number
>this : this
>this : D
>_secret : number
>value : number
}
@@ -16,7 +16,7 @@ class Lion extends Animal {
get sound() { return this._sound } // error here
>sound : string
>this._sound : string
>this : this
>this : Lion
>_sound : string
set sound(val) { this._sound = val }
@@ -24,7 +24,7 @@ class Lion extends Animal {
>val : string
>this._sound = val : string
>this._sound : string
>this : this
>this : Lion
>_sound : string
>val : string
}
@@ -16,7 +16,7 @@ class Lion extends Animal {
get sound(): string { return this._sound }
>sound : string
>this._sound : string
>this : this
>this : Lion
>_sound : string
set sound(val: string) { this._sound = val }
@@ -24,7 +24,7 @@ class Lion extends Animal {
>val : string
>this._sound = val : string
>this._sound : string
>this : this
>this : Lion
>_sound : string
>val : string
}
@@ -32,7 +32,7 @@ class D extends C {
get p() { return this._secret } // error
>p : number
>this._secret : number
>this : this
>this : D
>_secret : number
set p(value) { this._secret = value } // error
@@ -40,7 +40,7 @@ class D extends C {
>value : number
>this._secret = value : number
>this._secret : number
>this : this
>this : D
>_secret : number
>value : number
}
@@ -23,7 +23,7 @@ class C2 {
return this.x;
>this.x : IHasVisualizationModel
>this : this
>this : C2
>x : IHasVisualizationModel
}
set A(x) {
@@ -31,7 +31,7 @@ class TestClass {
this.bar(x); // should not error
>this.bar(x) : void
>this.bar : { (x: string): void; (x: string[]): void; }
>this : this
>this : TestClass
>bar : { (x: string): void; (x: string[]): void; }
>x : any
}
@@ -71,7 +71,7 @@ class TestClass2 {
return this.bar(x); // should not error
>this.bar(x) : number
>this.bar : { (x: string): number; (x: string[]): number; }
>this : this
>this : TestClass2
>bar : { (x: string): number; (x: string[]): number; }
>x : any
}
@@ -10,7 +10,7 @@ class Foo {
this.x = 5;
>this.x = 5 : 5
>this.x : number
>this : this
>this : Foo
>x : number
>5 : 5
}
@@ -11,7 +11,7 @@ class Foo {
this.x = 5;
>this.x = 5 : 5
>this.x : number
>this : this
>this : Foo
>x : number
>5 : 5
}
@@ -13,7 +13,7 @@ export class C {
this.assets = {};
>this.assets = {} : {}
>this.assets : { [assetName: string]: number; }
>this : this
>this : C
>assets : { [assetName: string]: number; }
>{} : {}
}
@@ -24,7 +24,7 @@ export class C {
>mappy(this.assets) : void
>mappy : (map: { [s: string]: number; }) => void
>this.assets : { [assetName: string]: number; }
>this : this
>this : C
>assets : { [assetName: string]: number; }
}
}
@@ -12,7 +12,7 @@ while (0) {
>methodA : () => void
this; //note: a this reference of some kind is required to trigger the bug
>this : this
>this : A
}
}
@@ -24,12 +24,12 @@ while (0) {
this.methodA; // error
>this.methodA : any
>this : this
>this : B
>methodA : any
this.methodB; // ok
>this.methodB : () => void
>this : this
>this : B
>methodB : () => void
}
}
@@ -17,7 +17,7 @@ class A {
this.arguments = foo;
>this.arguments = foo : any
>this.arguments : any
>this : this
>this : A
>arguments : any
>foo : any
}
@@ -17,7 +17,7 @@ class A {
this["arguments"] = foo;
>this["arguments"] = foo : any
>this["arguments"] : any
>this : this
>this : A
>"arguments" : "arguments"
>foo : any
}
@@ -35,7 +35,7 @@ class B extends A {
this.foo = foo;
>this.foo = foo : any
>this.foo : any
>this : this
>this : B
>foo : any
>foo : any
@@ -45,7 +45,7 @@ class B extends A {
this.bar = super.arguments.foo;
>this.bar = super.arguments.foo : error
>this.bar : any
>this : this
>this : B
>bar : any
>super.arguments.foo : error
>super.arguments : { bar: {}; }
@@ -21,7 +21,7 @@ class A {
this.foo = foo;
>this.foo = foo : any
>this.foo : any
>this : this
>this : A
>foo : any
>foo : any
@@ -31,7 +31,7 @@ class A {
const arguments = this.arguments;
>arguments : any
>this.arguments : { bar: {}; }
>this : this
>this : A
>arguments : { bar: {}; }
/**
@@ -40,7 +40,7 @@ class A {
this.bar = arguments.bar;
>this.bar = arguments.bar : any
>this.bar : any
>this : this
>this : A
>bar : any
>arguments.bar : any
>arguments : any
@@ -52,7 +52,7 @@ class A {
this.baz = arguments[key];
>this.baz = arguments[key] : any
>this.baz : any
>this : this
>this : A
>baz : any
>arguments[key] : any
>arguments : any
@@ -64,7 +64,7 @@ class A {
this.options = arguments;
>this.options = arguments : any
>this.options : any
>this : this
>this : A
>options : any
>arguments : any
}
@@ -26,7 +26,7 @@ class A {
this.foo = foo;
>this.foo = foo : any
>this.foo : any
>this : this
>this : A
>foo : any
>foo : any
@@ -36,7 +36,7 @@ class A {
this.bar = bar.arguments;
>this.bar = bar.arguments : {}
>this.bar : any
>this : this
>this : A
>bar : any
>bar.arguments : {}
>bar : { arguments: {}; }
@@ -9,7 +9,7 @@ class A {
this.foo = arguments;
>this.foo = arguments : IArguments
>this.foo : any
>this : this
>this : A
>foo : any
>arguments : IArguments
}
@@ -9,7 +9,7 @@ class A {
this.callee = arguments.callee;
>this.callee = arguments.callee : Function
>this.callee : Function
>this : this
>this : A
>callee : Function
>arguments.callee : Function
>arguments : IArguments
@@ -16,7 +16,7 @@ class A {
this.arguments = foo;
>this.arguments = foo : any
>this.arguments : any
>this : this
>this : A
>arguments : any
>foo : any
}
@@ -16,7 +16,7 @@ class A {
this["arguments"] = foo;
>this["arguments"] = foo : any
>this["arguments"] : any
>this : this
>this : A
>"arguments" : "arguments"
>foo : any
}
@@ -30,7 +30,7 @@ class B extends A {
this.x = foo;
>this.x = foo : any
>this.x : any
>this : this
>this : B
>x : any
>foo : any
@@ -40,7 +40,7 @@ class B extends A {
this.y = super.arguments.bar;
>this.y = super.arguments.bar : {}
>this.y : any
>this : this
>this : B
>y : any
>super.arguments.bar : {}
>super.arguments : { bar: {}; }
@@ -20,7 +20,7 @@ class A {
this.foo = foo;
>this.foo = foo : any
>this.foo : any
>this : this
>this : A
>foo : any
>foo : any
@@ -30,7 +30,7 @@ class A {
const arguments = this.arguments;
>arguments : any
>this.arguments : { bar: {}; }
>this : this
>this : A
>arguments : { bar: {}; }
/**
@@ -39,7 +39,7 @@ class A {
this.bar = arguments.bar;
>this.bar = arguments.bar : any
>this.bar : any
>this : this
>this : A
>bar : any
>arguments.bar : any
>arguments : any
@@ -51,7 +51,7 @@ class A {
this.baz = arguments[key];
>this.baz = arguments[key] : any
>this.baz : any
>this : this
>this : A
>baz : any
>arguments[key] : any
>arguments : any
@@ -63,7 +63,7 @@ class A {
this.options = arguments;
>this.options = arguments : any
>this.options : any
>this : this
>this : A
>options : any
>arguments : any
}
@@ -25,7 +25,7 @@ class A {
this.foo = foo;
>this.foo = foo : any
>this.foo : any
>this : this
>this : A
>foo : any
>foo : any
@@ -35,7 +35,7 @@ class A {
this.bar = bar.arguments;
>this.bar = bar.arguments : {}
>this.bar : any
>this : this
>this : A
>bar : any
>bar.arguments : {}
>bar : { arguments: {}; }
@@ -11,7 +11,7 @@ class A {
this.foo = arguments;
>this.foo = arguments : IArguments
>this.foo : any
>this : this
>this : A
>foo : any
>arguments : IArguments
}
@@ -11,7 +11,7 @@ class A {
this.callee = arguments.callee;
>this.callee = arguments.callee : Function
>this.callee : Function
>this : this
>this : A
>callee : Function
>arguments.callee : Function
>arguments : IArguments
@@ -47,7 +47,7 @@ module Test {
>lineTokens : ILineTokens
>this.tokenize(line, state, true) : ILineTokens
>this.tokenize : (line: string, state: IState, includeStates: boolean) => ILineTokens
>this : this
>this : Bug
>tokenize : (line: string, state: IState, includeStates: boolean) => ILineTokens
>line : string
>state : IState
@@ -69,7 +69,7 @@ module Test {
return this.onEnter(line, tokens, offset); // <== this should produce an error since onEnter can not be called with (string, IStateToken[], offset)
>this.onEnter(line, tokens, offset) : IAction
>this.onEnter : (line: string, state: IState, offset: number) => IAction
>this : this
>this : Bug
>onEnter : (line: string, state: IState, offset: number) => IAction
>line : string
>tokens : IStateToken[]
@@ -47,7 +47,7 @@ module EmptyTypes {
>(this.voidIfAny([4, 2][0])) : number
>this.voidIfAny([4, 2][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[4, 2][0] : number
>[4, 2] : number[]
@@ -60,7 +60,7 @@ module EmptyTypes {
>(this.voidIfAny([4, 2, undefined][0])) : number
>this.voidIfAny([4, 2, undefined][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[4, 2, undefined][0] : number
>[4, 2, undefined] : number[]
@@ -74,7 +74,7 @@ module EmptyTypes {
>(this.voidIfAny([undefined, 2, 4][0])) : number
>this.voidIfAny([undefined, 2, 4][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, 2, 4][0] : number
>[undefined, 2, 4] : number[]
@@ -88,7 +88,7 @@ module EmptyTypes {
>(this.voidIfAny([null, 2, 4][0])) : number
>this.voidIfAny([null, 2, 4][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[null, 2, 4][0] : number
>[null, 2, 4] : number[]
@@ -102,7 +102,7 @@ module EmptyTypes {
>(this.voidIfAny([2, 4, null][0])) : number
>this.voidIfAny([2, 4, null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[2, 4, null][0] : number
>[2, 4, null] : number[]
@@ -116,7 +116,7 @@ module EmptyTypes {
>(this.voidIfAny([undefined, 4, null][0])) : number
>this.voidIfAny([undefined, 4, null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, 4, null][0] : number
>[undefined, 4, null] : number[]
@@ -130,7 +130,7 @@ module EmptyTypes {
>(this.voidIfAny(['', "q"][0])) : number
>this.voidIfAny(['', "q"][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>['', "q"][0] : string
>['', "q"] : string[]
@@ -143,7 +143,7 @@ module EmptyTypes {
>(this.voidIfAny(['', "q", undefined][0])) : number
>this.voidIfAny(['', "q", undefined][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>['', "q", undefined][0] : string
>['', "q", undefined] : string[]
@@ -157,7 +157,7 @@ module EmptyTypes {
>(this.voidIfAny([undefined, "q", ''][0])) : number
>this.voidIfAny([undefined, "q", ''][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, "q", ''][0] : string
>[undefined, "q", ''] : string[]
@@ -171,7 +171,7 @@ module EmptyTypes {
>(this.voidIfAny([null, "q", ''][0])) : number
>this.voidIfAny([null, "q", ''][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[null, "q", ''][0] : string
>[null, "q", ''] : string[]
@@ -185,7 +185,7 @@ module EmptyTypes {
>(this.voidIfAny(["q", '', null][0])) : number
>this.voidIfAny(["q", '', null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>["q", '', null][0] : string
>["q", '', null] : string[]
@@ -199,7 +199,7 @@ module EmptyTypes {
>(this.voidIfAny([undefined, '', null][0])) : number
>this.voidIfAny([undefined, '', null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, '', null][0] : string
>[undefined, '', null] : string[]
@@ -213,7 +213,7 @@ module EmptyTypes {
>(this.voidIfAny([[3, 4], [null]][0][0])) : number
>this.voidIfAny([[3, 4], [null]][0][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[[3, 4], [null]][0][0] : number
>[[3, 4], [null]][0] : number[]
@@ -443,7 +443,7 @@ module NonEmptyTypes {
>(this.voidIfAny([4, 2][0])) : number
>this.voidIfAny([4, 2][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[4, 2][0] : number
>[4, 2] : number[]
@@ -456,7 +456,7 @@ module NonEmptyTypes {
>(this.voidIfAny([4, 2, undefined][0])) : number
>this.voidIfAny([4, 2, undefined][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[4, 2, undefined][0] : number
>[4, 2, undefined] : number[]
@@ -470,7 +470,7 @@ module NonEmptyTypes {
>(this.voidIfAny([undefined, 2, 4][0])) : number
>this.voidIfAny([undefined, 2, 4][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, 2, 4][0] : number
>[undefined, 2, 4] : number[]
@@ -484,7 +484,7 @@ module NonEmptyTypes {
>(this.voidIfAny([null, 2, 4][0])) : number
>this.voidIfAny([null, 2, 4][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[null, 2, 4][0] : number
>[null, 2, 4] : number[]
@@ -498,7 +498,7 @@ module NonEmptyTypes {
>(this.voidIfAny([2, 4, null][0])) : number
>this.voidIfAny([2, 4, null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[2, 4, null][0] : number
>[2, 4, null] : number[]
@@ -512,7 +512,7 @@ module NonEmptyTypes {
>(this.voidIfAny([undefined, 4, null][0])) : number
>this.voidIfAny([undefined, 4, null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, 4, null][0] : number
>[undefined, 4, null] : number[]
@@ -526,7 +526,7 @@ module NonEmptyTypes {
>(this.voidIfAny(['', "q"][0])) : number
>this.voidIfAny(['', "q"][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>['', "q"][0] : string
>['', "q"] : string[]
@@ -539,7 +539,7 @@ module NonEmptyTypes {
>(this.voidIfAny(['', "q", undefined][0])) : number
>this.voidIfAny(['', "q", undefined][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>['', "q", undefined][0] : string
>['', "q", undefined] : string[]
@@ -553,7 +553,7 @@ module NonEmptyTypes {
>(this.voidIfAny([undefined, "q", ''][0])) : number
>this.voidIfAny([undefined, "q", ''][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, "q", ''][0] : string
>[undefined, "q", ''] : string[]
@@ -567,7 +567,7 @@ module NonEmptyTypes {
>(this.voidIfAny([null, "q", ''][0])) : number
>this.voidIfAny([null, "q", ''][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[null, "q", ''][0] : string
>[null, "q", ''] : string[]
@@ -581,7 +581,7 @@ module NonEmptyTypes {
>(this.voidIfAny(["q", '', null][0])) : number
>this.voidIfAny(["q", '', null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>["q", '', null][0] : string
>["q", '', null] : string[]
@@ -595,7 +595,7 @@ module NonEmptyTypes {
>(this.voidIfAny([undefined, '', null][0])) : number
>this.voidIfAny([undefined, '', null][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[undefined, '', null][0] : string
>[undefined, '', null] : string[]
@@ -609,7 +609,7 @@ module NonEmptyTypes {
>(this.voidIfAny([[3, 4], [null]][0][0])) : number
>this.voidIfAny([[3, 4], [null]][0][0]) : number
>this.voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>this : this
>this : f
>voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; }
>[[3, 4], [null]][0][0] : number
>[[3, 4], [null]][0] : number[]
@@ -16,7 +16,7 @@ class Road {
this.cars = cars;
>this.cars = cars : Car[]
>this.cars : Car[]
>this : this
>this : Road
>cars : Car[]
>cars : Car[]
}
+2 -2
View File
@@ -35,12 +35,12 @@ class parser {
this.options = this.options.sort(function(a, b) {
>this.options = this.options.sort(function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } }) : IOptions[]
>this.options : IOptions[]
>this : this
>this : parser
>options : IOptions[]
>this.options.sort(function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } }) : IOptions[]
>this.options.sort : (compareFn?: (a: IOptions, b: IOptions) => number) => IOptions[]
>this.options : IOptions[]
>this : this
>this : parser
>options : IOptions[]
>sort : (compareFn?: (a: IOptions, b: IOptions) => number) => IOptions[]
>function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } } : (a: IOptions, b: IOptions) => 1 | -1 | 0
@@ -1,12 +1,14 @@
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(2,1): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(13,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Base'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(30,9): error TS18033: Only numeric enums can have computed members, but this expression has type '() => number'. If you do not need exhaustiveness checks, consider using an object literal instead.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(31,16): error TS2332: 'this' cannot be referenced in current location.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(43,5): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(54,13): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Base'.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(71,13): error TS18033: Only numeric enums can have computed members, but this expression has type '() => number'. If you do not need exhaustiveness checks, consider using an object literal instead.
tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(72,20): error TS2332: 'this' cannot be referenced in current location.
==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (6 errors) ====
==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (8 errors) ====
// Arrow function used in with statement
with (window) {
~~~~~~~~~~~~~
@@ -22,6 +24,8 @@ tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(72,20): e
class Derived extends Base {
constructor() {
super(() => this);
~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Base'.
}
}
@@ -69,6 +73,8 @@ tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(72,20): e
class Derived extends Base {
constructor() {
super(() => this);
~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Base'.
}
}
@@ -25,8 +25,8 @@ class Derived extends Base {
super(() => this);
>super(() => this) : void
>super : typeof Base
>() => this : () => this
>this : this
>() => this : () => Derived
>this : Derived
}
}
@@ -128,8 +128,8 @@ module M2 {
super(() => this);
>super(() => this) : void
>super : typeof Base
>() => this : () => this
>this : this
>() => this : () => Derived
>this : Derived
}
}
@@ -148,12 +148,12 @@ class MyClass {
>1 : 1
var p = (n) => n && this;
>p : (n: any) => this
>(n) => n && this : (n: any) => this
>p : (n: any) => MyClass
>(n) => n && this : (n: any) => MyClass
>n : any
>n && this : this
>n && this : MyClass
>n : any
>this : this
>this : MyClass
}
}
@@ -333,6 +333,7 @@ class Test {
this.z;
>this.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
>this : Symbol(Test2, Decl(assertionTypePredicates1.ts, 127, 1))
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
}
this.assertIsTest2();
@@ -342,6 +343,7 @@ class Test {
this.z;
>this.z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
>this : Symbol(Test2, Decl(assertionTypePredicates1.ts, 127, 1))
>z : Symbol(Test2.z, Decl(assertionTypePredicates1.ts, 129, 26))
}
baz(x: number) {
@@ -372,7 +372,7 @@ class Test {
return this instanceof Test2;
>this instanceof Test2 : boolean
>this : this
>this : Test
>Test2 : typeof Test2
}
assertIsTest2(): asserts this is Test2 {
@@ -380,7 +380,7 @@ class Test {
if (this instanceof Test2) return;
>this instanceof Test2 : boolean
>this : this
>this : Test
>Test2 : typeof Test2
throw new Error();
@@ -392,7 +392,7 @@ class Test {
if (!this) return;
>!this : false
>this : this
>this : Test
throw new Error();
>new Error() : Error
@@ -404,11 +404,11 @@ class Test {
this.assertThis();
>this.assertThis() : void
>this.assertThis : () => asserts this
>this : this
>this : Test
>assertThis : () => asserts this
this;
>this : this
>this : Test
}
foo(x: unknown) {
>foo : (x: unknown) => void
@@ -417,7 +417,7 @@ class Test {
this.assert(typeof x === "string");
>this.assert(typeof x === "string") : void
>this.assert : (value: unknown) => asserts value
>this : this
>this : Test
>assert : (value: unknown) => asserts value
>typeof x === "string" : boolean
>typeof x : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
@@ -432,23 +432,23 @@ class Test {
if (this.isTest2()) {
>this.isTest2() : boolean
>this.isTest2 : () => this is Test2
>this : this
>this : Test
>isTest2 : () => this is Test2
this.z;
>this.z : number
>this : this & Test2
>this : Test2
>z : number
}
this.assertIsTest2();
>this.assertIsTest2() : void
>this.assertIsTest2 : () => asserts this is Test2
>this : this
>this : Test
>assertIsTest2 : () => asserts this is Test2
this.z;
>this.z : number
>this : this & Test2
>this : Test2
>z : number
}
baz(x: number) {
@@ -458,7 +458,7 @@ class Test {
this.assert(false);
>this.assert(false) : void
>this.assert : (value: unknown) => asserts value
>this : this
>this : Test
>assert : (value: unknown) => asserts value
>false : false
@@ -39,7 +39,7 @@ class C {
this.foo // ok
>this.foo : string
>this : this
>this : C
>foo : string
}
m3 = function() { }
@@ -72,7 +72,7 @@ class C {
this.foo // ok
>this.foo : string
>this : this
>this : C
>foo : string
}
}
@@ -16,6 +16,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(3
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,21): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,36): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(44,19): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(46,27): error TS1034: 'super' must be followed by an argument list or member access.
@@ -39,7 +40,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ====
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (40 errors) ====
// expected error for all the LHS of assignments
var value: any;
@@ -118,6 +119,8 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
// super
class Derived extends C {
constructor() { super(); super = value; }
~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
~
!!! error TS1034: 'super' must be followed by an argument list or member access.
@@ -9,13 +9,13 @@ class C {
constructor() { this = value; }
>this = value : any
>this : this
>this : C
>value : any
foo() { this = value; }
>foo : () => void
>this = value : any
>this : this
>this : C
>value : any
static sfoo() { this = value; }
@@ -16,7 +16,7 @@ class C {
>other.apply : (this: Function, thisArg: any, argArray?: any) => any
>other : () => void
>apply : (this: Function, thisArg: any, argArray?: any) => any
>this : this
>this : C
>arguments : IArguments
}
}
@@ -16,7 +16,7 @@ class C {
>other.apply : (this: Function, thisArg: any, argArray?: any) => any
>other : () => void
>apply : (this: Function, thisArg: any, argArray?: any) => any
>this : this
>this : C
>arguments : IArguments
}
}
@@ -16,7 +16,7 @@ class C {
>other.apply : (this: Function, thisArg: any, argArray?: any) => any
>other : () => void
>apply : (this: Function, thisArg: any, argArray?: any) => any
>this : this
>this : C
>arguments : IArguments
}
}
@@ -6,10 +6,10 @@ class C {
>method : () => void
var fn = async () => await this;
>fn : () => Promise<this>
>async () => await this : () => Promise<this>
>await this : this
>this : this
>fn : () => Promise<C>
>async () => await this : () => Promise<C>
>await this : C
>this : C
}
}
@@ -6,10 +6,10 @@ class C {
>method : () => void
var fn = async () => await this;
>fn : () => Promise<this>
>async () => await this : () => Promise<this>
>await this : this
>this : this
>fn : () => Promise<C>
>async () => await this : () => Promise<C>
>await this : C
>this : C
}
}
@@ -6,10 +6,10 @@ class C {
>method : () => void
var fn = async () => await this;
>fn : () => Promise<this>
>async () => await this : () => Promise<this>
>await this : this
>this : this
>fn : () => Promise<C>
>async () => await this : () => Promise<C>
>await this : C
>this : C
}
}
+6 -6
View File
@@ -6,13 +6,13 @@ class A
constructor() {
this.foo: any;
>this.foo : any
>this : this
>this : A
>foo : any
>any : any
this.bar: any;
>this.bar : any
>this : this
>this : A
>bar : any
>any : any
}
@@ -24,14 +24,14 @@ class A
this.foo = "foo";
>this.foo = "foo" : "foo"
>this.foo : any
>this : this
>this : A
>foo : any
>"foo" : "foo"
this.bar = "bar";
>this.bar = "bar" : "bar"
>this.bar : any
>this : this
>this : A
>bar : any
>"bar" : "bar"
@@ -45,7 +45,7 @@ class A
>(p) => this.foo : (p: number) => any
>p : number
>this.foo : any
>this : this
>this : A
>foo : any
[1, 2].forEach((p) => this.bar);
@@ -58,7 +58,7 @@ class A
>(p) => this.bar : (p: number) => any
>p : number
>this.bar : any
>this : this
>this : A
>bar : any
}
@@ -1,7 +1,8 @@
tests/cases/compiler/autolift4.ts(15,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Point'.
tests/cases/compiler/autolift4.ts(19,70): error TS2339: Property 'm' does not exist on type 'Point3D'.
==== tests/cases/compiler/autolift4.ts (1 errors) ====
==== tests/cases/compiler/autolift4.ts (2 errors) ====
class Point {
constructor(public x: number, public y: number) {
@@ -17,6 +18,8 @@ tests/cases/compiler/autolift4.ts(19,70): error TS2339: Property 'm' does not ex
constructor(x: number, y: number, public z: number, m:number) {
super(x, y);
~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Point'.
}
getDist() {
+10 -10
View File
@@ -18,17 +18,17 @@ class Point {
>this.x*this.x + this.y*this.y : number
>this.x*this.x : number
>this.x : number
>this : this
>this : Point
>x : number
>this.x : number
>this : this
>this : Point
>x : number
>this.y*this.y : number
>this.y : number
>this : this
>this : Point
>y : number
>this.y : number
>this : this
>this : Point
>y : number
}
static origin = new Point(0,0);
@@ -68,24 +68,24 @@ class Point3D extends Point {
>this.x*this.x + this.y*this.y : number
>this.x*this.x : number
>this.x : number
>this : this
>this : Point3D
>x : number
>this.x : number
>this : this
>this : Point3D
>x : number
>this.y*this.y : number
>this.y : number
>this : this
>this : Point3D
>y : number
>this.y : number
>this : this
>this : Point3D
>y : number
>this.z*this.m : number
>this.z : number
>this : this
>this : Point3D
>z : number
>this.m : any
>this : this
>this : Point3D
>m : any
}
}
@@ -137,7 +137,7 @@ class Api<D = {}> {
>post : <T = D>() => Promise<T>
>this.request<T>() : Promise<T>
>this.request : <D>() => Promise<D>
>this : this
>this : Api<D>
>request : <D>() => Promise<D>
async request<D>(): Promise<D> { throw new Error(); }
@@ -22,8 +22,8 @@ class Greeter {
>() => { var x = this; } : () => void
var x = this;
>x : this
>this : this
>x : Greeter
>this : Greeter
});
});
+13 -4
View File
@@ -1,24 +1,31 @@
tests/cases/compiler/baseCheck.ts(4,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
tests/cases/compiler/baseCheck.ts(9,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
tests/cases/compiler/baseCheck.ts(9,18): error TS2552: Cannot find name 'loc'. Did you mean 'ELoc'?
tests/cases/compiler/baseCheck.ts(17,53): error TS2554: Expected 2 arguments, but got 1.
tests/cases/compiler/baseCheck.ts(17,59): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/baseCheck.ts(18,53): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
tests/cases/compiler/baseCheck.ts(18,62): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/baseCheck.ts(19,59): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
tests/cases/compiler/baseCheck.ts(19,53): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
tests/cases/compiler/baseCheck.ts(19,68): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/baseCheck.ts(22,9): error TS2304: Cannot find name 'x'.
tests/cases/compiler/baseCheck.ts(23,7): error TS2304: Cannot find name 'x'.
tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'.
==== tests/cases/compiler/baseCheck.ts (9 errors) ====
==== tests/cases/compiler/baseCheck.ts (12 errors) ====
class C { constructor(x: number, y: number) { } }
class ELoc extends C {
constructor(x: number) {
super(0, x);
~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
}
}
class ELocVar extends C {
constructor(x: number) {
super(0, loc);
~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
~~~
!!! error TS2552: Cannot find name 'loc'. Did you mean 'ELoc'?
!!! related TS2728 tests/cases/compiler/baseCheck.ts:2:7: 'ELoc' is declared here.
@@ -36,11 +43,13 @@ tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'.
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
class E extends C { constructor(public z: number) { super(0, this.z) } }
~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
class F extends C { constructor(public z: number) { super("hello", this.z) } } // first param type
~~~~~~~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
+3 -3
View File
@@ -48,7 +48,7 @@ class D extends C { constructor(public z: number) { super(this.z) } } // too fe
>super(this.z) : void
>super : typeof C
>this.z : number
>this : this
>this : D
>z : number
class E extends C { constructor(public z: number) { super(0, this.z) } }
@@ -59,7 +59,7 @@ class E extends C { constructor(public z: number) { super(0, this.z) } }
>super : typeof C
>0 : 0
>this.z : number
>this : this
>this : E
>z : number
class F extends C { constructor(public z: number) { super("hello", this.z) } } // first param type
@@ -70,7 +70,7 @@ class F extends C { constructor(public z: number) { super("hello", this.z) } } /
>super : typeof C
>"hello" : "hello"
>this.z : number
>this : this
>this : F
>z : number
function f() {
@@ -23,7 +23,7 @@ export function classExtender<TFunction>(superClass: TFunction, _instanceModifie
_instanceModifier(this, args);
>_instanceModifier(this, args) : void
>_instanceModifier : (instance: any, args: any[]) => void
>this : this
>this : decoratorFunc
>args : any[]
}
};
@@ -58,7 +58,7 @@ export function classExtender2<TFunction extends new (...args: string[]) => MyCl
_instanceModifier(this, args);
>_instanceModifier(this, args) : void
>_instanceModifier : (instance: any, args: any[]) => void
>this : this
>this : decoratorFunc
>args : any[]
}
};
@@ -0,0 +1,44 @@
tests/cases/compiler/baseTypeWrappingInstantiationChain.ts(19,36): error TS2345: Argument of type 'C<T1>' is not assignable to parameter of type 'Parameter<Wrapper<T1>>'.
Types of property 'method' are incompatible.
Type '(t: Wrapper<T1>) => void' is not assignable to type '(t: Wrapper<T1>) => void'. Two different types with this name exist, but they are unrelated.
The 'this' types of each signature are incompatible.
Type 'Parameter<T4>' is missing the following properties from type 'C<T1>': works, alsoWorks
tests/cases/compiler/baseTypeWrappingInstantiationChain.ts(22,23): error TS2345: Argument of type 'C<T1>' is not assignable to parameter of type 'Parameter<Wrapper<T1>>'.
==== tests/cases/compiler/baseTypeWrappingInstantiationChain.ts (2 errors) ====
class CBaseBase<T3> {
constructor(x: Parameter<T3>) { }
}
class CBase<T2> extends CBaseBase<Wrapper<T2>> {
}
class Parameter<T4> {
method(t: T4) { }
}
class Wrapper<T5> {
property: T5;
}
class C<T1> extends CBase<T1> {
public works() {
new CBaseBase<Wrapper<T1>>(this);
~~~~
!!! error TS2345: Argument of type 'C<T1>' is not assignable to parameter of type 'Parameter<Wrapper<T1>>'.
!!! error TS2345: Types of property 'method' are incompatible.
!!! error TS2345: Type '(t: Wrapper<T1>) => void' is not assignable to type '(t: Wrapper<T1>) => void'. Two different types with this name exist, but they are unrelated.
!!! error TS2345: The 'this' types of each signature are incompatible.
!!! error TS2345: Type 'Parameter<T4>' is missing the following properties from type 'C<T1>': works, alsoWorks
}
public alsoWorks() {
new CBase<T1>(this); // Should not error, parameter is of type Parameter<Wrapper<T1>>
~~~~
!!! error TS2345: Argument of type 'C<T1>' is not assignable to parameter of type 'Parameter<Wrapper<T1>>'.
}
public method(t: Wrapper<T1>) { }
}
@@ -37,7 +37,7 @@ class C<T1> extends CBase<T1> {
new CBaseBase<Wrapper<T1>>(this);
>new CBaseBase<Wrapper<T1>>(this) : CBaseBase<Wrapper<T1>>
>CBaseBase : typeof CBaseBase
>this : this
>this : C<T1>
}
public alsoWorks() {
>alsoWorks : () => void
@@ -45,7 +45,7 @@ class C<T1> extends CBase<T1> {
new CBase<T1>(this); // Should not error, parameter is of type Parameter<Wrapper<T1>>
>new CBase<T1>(this) : CBase<T1>
>CBase : typeof CBase
>this : this
>this : C<T1>
}
public method(t: Wrapper<T1>) { }
+2 -2
View File
@@ -10,7 +10,7 @@ class B {
constructor() {
this.y: any;
>this.y : any
>this : this
>this : B
>y : any
>any : any
}
@@ -23,7 +23,7 @@ class C extends B implements I {
constructor() {
this.x: any;
>this.x : any
>this : this
>this : C
>x : any
>any : any
}
@@ -32,7 +32,7 @@ module Test {
>name : string
>this.getName() : string
>this.getName : () => string
>this : this
>this : Bug
>getName : () => string
>length : number
>0 : 0
@@ -185,7 +185,7 @@ function foo12() {
this.a = x;
>this.a = x : any
>this.a : any
>this : this
>this : y
>a : any
>x : any
}
@@ -0,0 +1,46 @@
tests/cases/conformance/types/typeParameters/typeArgumentLists/callGenericFunctionWithZeroTypeArguments.ts(30,10): error TS2684: The 'this' context of type 'C2<unknown>' is not assignable to method's 'this' of type 'C2<T>'.
Type 'unknown' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'unknown'.
==== tests/cases/conformance/types/typeParameters/typeArgumentLists/callGenericFunctionWithZeroTypeArguments.ts (1 errors) ====
// valid invocations of generic functions with no explicit type arguments provided
function f<T>(x: T): T { return null; }
var r = f(1);
var f2 = <T>(x: T): T => { return null; }
var r2 = f2(1);
var f3: { <T>(x: T): T; }
var r3 = f3(1);
class C {
f<T>(x: T): T {
return null;
}
}
var r4 = (new C()).f(1);
interface I {
f<T>(x: T): T;
}
var i: I;
var r5 = i.f(1);
class C2<T> {
f(x: T): T {
return null;
}
}
var r6 = (new C2()).f(1);
~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'C2<unknown>' is not assignable to method's 'this' of type 'C2<T>'.
!!! error TS2684: Type 'unknown' is not assignable to type 'T'.
!!! error TS2684: 'T' could be instantiated with an arbitrary type which could be unrelated to 'unknown'.
interface I2<T> {
f(x: T): T;
}
var i2: I2<number>;
var r7 = i2.f(1);
@@ -1,3 +1,10 @@
tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(9,1): error TS2684: The 'this' context of type 'X<void>' is not assignable to method's 'this' of type 'X<T>'.
Type 'void' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'void'.
tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(12,1): error TS2684: The 'this' context of type 'X<number | void>' is not assignable to method's 'this' of type 'X<T>'.
Type 'number | void' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'number | void'.
tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(13,1): error TS2684: The 'this' context of type 'X<number | void>' is not assignable to method's 'this' of type 'X<T>'.
tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(16,6): error TS2554: Expected 1 arguments, but got 0.
tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(19,10): error TS2554: Expected 1 arguments, but got 0.
tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(22,8): error TS2554: Expected 1 arguments, but got 0.
@@ -11,7 +18,7 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(57,1):
tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1): error TS2554: Expected 3 arguments, but got 1.
==== tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts (11 errors) ====
==== tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts (14 errors) ====
// From #4260
class X<T> {
f(t: T) {
@@ -21,10 +28,20 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1):
declare const x: X<void>;
x.f() // no error because f expects void
~
!!! error TS2684: The 'this' context of type 'X<void>' is not assignable to method's 'this' of type 'X<T>'.
!!! error TS2684: Type 'void' is not assignable to type 'T'.
!!! error TS2684: 'T' could be instantiated with an arbitrary type which could be unrelated to 'void'.
declare const xUnion: X<void | number>;
xUnion.f(42) // no error because f accepts number
~~~~~~
!!! error TS2684: The 'this' context of type 'X<number | void>' is not assignable to method's 'this' of type 'X<T>'.
!!! error TS2684: Type 'number | void' is not assignable to type 'T'.
!!! error TS2684: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number | void'.
xUnion.f() // no error because f accepts void
~~~~~~
!!! error TS2684: The 'this' context of type 'X<number | void>' is not assignable to method's 'this' of type 'X<T>'.
declare const xAny: X<any>;
xAny.f() // error, any still expects an argument
@@ -0,0 +1,67 @@
tests/cases/conformance/expressions/functionCalls/callWithSpread.ts(50,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
tests/cases/conformance/expressions/functionCalls/callWithSpread.ts(51,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
==== tests/cases/conformance/expressions/functionCalls/callWithSpread.ts (2 errors) ====
interface X {
foo(x: number, y: number, ...z: string[]): X;
}
function foo(x: number, y: number, ...z: string[]) {
}
var a: string[];
var z: number[];
var obj: X;
var xa: X[];
foo(1, 2, "abc");
foo(1, 2, ...a);
foo(1, 2, ...a, "abc");
obj.foo(1, 2, "abc");
obj.foo(1, 2, ...a);
obj.foo(1, 2, ...a, "abc");
obj.foo(1, 2, ...a).foo(1, 2, "abc");
obj.foo(1, 2, ...a).foo(1, 2, ...a);
obj.foo(1, 2, ...a).foo(1, 2, ...a, "abc");
(obj.foo)(1, 2, "abc");
(obj.foo)(1, 2, ...a);
(obj.foo)(1, 2, ...a, "abc");
((obj.foo)(1, 2, ...a).foo)(1, 2, "abc");
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a);
((obj.foo)(1, 2, ...a).foo)(1, 2, ...a, "abc");
xa[1].foo(1, 2, "abc");
xa[1].foo(1, 2, ...a);
xa[1].foo(1, 2, ...a, "abc");
(<Function>xa[1].foo)(...[1, 2, "abc"]);
class C {
constructor(x: number, y: number, ...z: string[]) {
this.foo(x, y);
this.foo(x, y, ...z);
}
foo(x: number, y: number, ...z: string[]) {
}
}
class D extends C {
constructor() {
super(1, 2);
~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
super(1, 2, ...a);
~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
}
foo() {
super.foo(1, 2);
super.foo(1, 2, ...a);
}
}
@@ -283,7 +283,7 @@ class C {
this.foo(x, y);
>this.foo(x, y) : void
>this.foo : (x: number, y: number, ...z: string[]) => void
>this : this
>this : C
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
@@ -291,7 +291,7 @@ class C {
this.foo(x, y, ...z);
>this.foo(x, y, ...z) : void
>this.foo : (x: number, y: number, ...z: string[]) => void
>this : this
>this : C
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
@@ -0,0 +1,59 @@
tests/cases/conformance/expressions/functionCalls/callWithSpreadES6.ts(42,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
tests/cases/conformance/expressions/functionCalls/callWithSpreadES6.ts(43,9): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
==== tests/cases/conformance/expressions/functionCalls/callWithSpreadES6.ts (2 errors) ====
interface X {
foo(x: number, y: number, ...z: string[]);
}
function foo(x: number, y: number, ...z: string[]) {
}
var a: string[];
var z: number[];
var obj: X;
var xa: X[];
foo(1, 2, "abc");
foo(1, 2, ...a);
foo(1, 2, ...a, "abc");
obj.foo(1, 2, "abc");
obj.foo(1, 2, ...a);
obj.foo(1, 2, ...a, "abc");
(obj.foo)(1, 2, "abc");
(obj.foo)(1, 2, ...a);
(obj.foo)(1, 2, ...a, "abc");
xa[1].foo(1, 2, "abc");
xa[1].foo(1, 2, ...a);
xa[1].foo(1, 2, ...a, "abc");
(<Function>xa[1].foo)(...[1, 2, "abc"]);
class C {
constructor(x: number, y: number, ...z: string[]) {
this.foo(x, y);
this.foo(x, y, ...z);
}
foo(x: number, y: number, ...z: string[]) {
}
}
class D extends C {
constructor() {
super(1, 2);
~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
super(1, 2, ...a);
~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'C'.
}
foo() {
super.foo(1, 2);
super.foo(1, 2, ...a);
}
}
@@ -175,7 +175,7 @@ class C {
this.foo(x, y);
>this.foo(x, y) : void
>this.foo : (x: number, y: number, ...z: string[]) => void
>this : this
>this : C
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
@@ -183,7 +183,7 @@ class C {
this.foo(x, y, ...z);
>this.foo(x, y, ...z) : void
>this.foo : (x: number, y: number, ...z: string[]) => void
>this : this
>this : C
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
+1 -1
View File
@@ -27,7 +27,7 @@ class SharedClass {
/** @type {SharedId<S>} */
this.id;
>this.id : SharedId<S>
>this : this
>this : SharedClass
>id : SharedId<S>
}
}
@@ -0,0 +1,17 @@
tests/cases/compiler/captureSuperPropertyAccessInSuperCall01.ts(9,3): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'A'.
==== tests/cases/compiler/captureSuperPropertyAccessInSuperCall01.ts (1 errors) ====
class A {
constructor(f: () => string) {
}
public blah(): string { return ""; }
}
class B extends A {
constructor() {
super(() => { return super.blah(); })
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'A'.
}
}
@@ -0,0 +1,14 @@
tests/cases/compiler/captureThisInSuperCall.ts(6,21): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'A'.
==== tests/cases/compiler/captureThisInSuperCall.ts (1 errors) ====
class A {
constructor(p:any) {}
}
class B extends A {
constructor() { super({ test: () => this.someMethod()}); }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'A'.
someMethod() {}
}
@@ -18,7 +18,7 @@ class B extends A {
>() => this.someMethod() : () => void
>this.someMethod() : void
>this.someMethod : () => void
>this : this
>this : B
>someMethod : () => void
someMethod() {}
@@ -18,7 +18,7 @@ class A {
this.bar(f());
>this.bar(f()) : void
>this.bar : (a: number) => void
>this : this
>this : A
>bar : (a: number) => void
>f() : number
>f : () => number
@@ -55,7 +55,7 @@ class A {
this.bar(b());
>this.bar(b()) : void
>this.bar : (a: number) => void
>this : this
>this : A
>bar : (a: number) => void
>b() : number
>b : () => number
@@ -63,7 +63,7 @@ class A {
this.bar(a());
>this.bar(a()) : void
>this.bar : (a: number) => void
>this : this
>this : A
>bar : (a: number) => void
>a() : number
>a : () => number
@@ -85,7 +85,7 @@ class A {
this.bar(a());
>this.bar(a()) : void
>this.bar : (a: number) => void
>this : this
>this : A
>bar : (a: number) => void
>a() : number
>a : () => number
@@ -103,7 +103,7 @@ class A {
this.bar(b());
>this.bar(b()) : void
>this.bar : (a: number) => void
>this : this
>this : A
>bar : (a: number) => void
>b() : number
>b : () => number
@@ -137,7 +137,7 @@ class B {
this.bar(f());
>this.bar(f()) : void
>this.bar : (a: number) => void
>this : this
>this : B
>bar : (a: number) => void
>f() : number
>f : () => number
@@ -18,7 +18,7 @@ class A {
this.bar(f());
>this.bar(f()) : void
>this.bar : (a: number) => void
>this : this
>this : A
>bar : (a: number) => void
>f() : number
>f : () => number
@@ -55,7 +55,7 @@ class A {
this.bar(b());
>this.bar(b()) : void
>this.bar : (a: number) => void
>this : this
>this : A
>bar : (a: number) => void
>b() : number
>b : () => number
@@ -63,7 +63,7 @@ class A {
this.bar(a());
>this.bar(a()) : void
>this.bar : (a: number) => void
>this : this
>this : A
>bar : (a: number) => void
>a() : number
>a : () => number
@@ -85,7 +85,7 @@ class A {
this.bar(a());
>this.bar(a()) : void
>this.bar : (a: number) => void
>this : this
>this : A
>bar : (a: number) => void
>a() : number
>a : () => number
@@ -103,7 +103,7 @@ class A {
this.bar(b());
>this.bar(b()) : void
>this.bar : (a: number) => void
>this : this
>this : A
>bar : (a: number) => void
>b() : number
>b : () => number
@@ -137,7 +137,7 @@ class B {
this.bar(f());
>this.bar(f()) : void
>this.bar : (a: number) => void
>this : this
>this : B
>bar : (a: number) => void
>f() : number
>f : () => number
@@ -6,7 +6,7 @@ class Main {
this.register("a", "b", "c");
>this.register("a", "b", "c") : void
>this.register : (...names: string[]) => void
>this : this
>this : Main
>register : (...names: string[]) => void
>"a" : "a"
>"b" : "b"
@@ -24,7 +24,7 @@ class Main {
this.bar({
>this.bar({ [name + ".a"]: () => { this.foo(name); }, }) : void
>this.bar : (a: any) => void
>this : this
>this : Main
>bar : (a: any) => void
>{ [name + ".a"]: () => { this.foo(name); }, } : { [x: string]: () => void; }
@@ -36,7 +36,7 @@ class Main {
>() => { this.foo(name); } : () => void
>this.foo(name) : void
>this.foo : (name: string) => void
>this : this
>this : Main
>foo : (name: string) => void
>name : string
@@ -319,7 +319,7 @@ class C {
>() => this.N * i : () => number
>this.N * i : number
>this.N : number
>this : this
>this : C
>N : number
>i : number
}
@@ -318,7 +318,7 @@ class C {
>() => this.N * i : () => number
>this.N * i : number
>this.N : number
>this : this
>this : C
>N : number
>i : number
}
@@ -1,8 +1,12 @@
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,64): error TS2741: Property 'z' is missing in type 'B' but required in type 'C'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,81): error TS2739: Type 'A' is missing the following properties from type 'C': z, y
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,1): error TS2684: The 'this' context of type 'Chain<A>' is not assignable to method's 'this' of type 'Chain<T>'.
Type 'A' is not assignable to type 'T'.
'A' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,1): error TS2684: The 'this' context of type 'Chain<A>' is not assignable to method's 'this' of type 'Chain<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,1): error TS2684: The 'this' context of type 'Chain<A>' is not assignable to method's 'this' of type 'Chain<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,1): error TS2684: The 'this' context of type 'Chain<A>' is not assignable to method's 'this' of type 'Chain<T>'.
==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (2 errors) ====
==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (4 errors) ====
class Chain<T extends A> {
constructor(public value: T) { }
then<S extends T>(cb: (x: T) => S): Chain<S> {
@@ -22,10 +26,13 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete
// Ok to go down the chain, but error to try to climb back up
(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A);
~~~~~
!!! error TS2741: Property 'z' is missing in type 'B' but required in type 'C'.
!!! related TS2728 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:15:5: 'z' is declared here.
!!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature.
~~~~~
!!! error TS2739: Type 'A' is missing the following properties from type 'C': z, y
!!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature.
~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain<A>' is not assignable to method's 'this' of type 'Chain<T>'.
!!! error TS2684: Type 'A' is not assignable to type 'T'.
!!! error TS2684: 'A' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'A'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain<A>' is not assignable to method's 'this' of type 'Chain<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain<A>' is not assignable to method's 'this' of type 'Chain<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain<A>' is not assignable to method's 'this' of type 'Chain<T>'.
@@ -38,13 +38,13 @@ class C extends B {
// Ok to go down the chain, but error to try to climb back up
(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A);
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A) : Chain<C>
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then : <S extends C>(cb: (x: C) => S) => Chain<S>
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B) : Chain<C>
>(new Chain(new A)).then(a => new B).then(b => new C).then : <S extends C>(cb: (x: C) => S) => Chain<S>
>(new Chain(new A)).then(a => new B).then(b => new C) : Chain<C>
>(new Chain(new A)).then(a => new B).then : <S extends B>(cb: (x: B) => S) => Chain<S>
>(new Chain(new A)).then(a => new B) : Chain<B>
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A) : Chain<A>
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then : <S extends A>(cb: (x: A) => S) => Chain<S>
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B) : Chain<A>
>(new Chain(new A)).then(a => new B).then(b => new C).then : <S extends A>(cb: (x: A) => S) => Chain<S>
>(new Chain(new A)).then(a => new B).then(b => new C) : Chain<A>
>(new Chain(new A)).then(a => new B).then : <S extends A>(cb: (x: A) => S) => Chain<S>
>(new Chain(new A)).then(a => new B) : Chain<A>
>(new Chain(new A)).then : <S extends A>(cb: (x: A) => S) => Chain<S>
>(new Chain(new A)) : Chain<A>
>new Chain(new A) : Chain<A>
@@ -56,19 +56,19 @@ class C extends B {
>a : A
>new B : B
>B : typeof B
>then : <S extends B>(cb: (x: B) => S) => Chain<S>
>b => new C : (b: B) => C
>b : B
>then : <S extends A>(cb: (x: A) => S) => Chain<S>
>b => new C : (b: A) => C
>b : A
>new C : C
>C : typeof C
>then : <S extends C>(cb: (x: C) => S) => Chain<S>
>c => new B : (c: C) => B
>c : C
>then : <S extends A>(cb: (x: A) => S) => Chain<S>
>c => new B : (c: A) => B
>c : A
>new B : B
>B : typeof B
>then : <S extends C>(cb: (x: C) => S) => Chain<S>
>b => new A : (b: C) => A
>b : C
>then : <S extends A>(cb: (x: A) => S) => Chain<S>
>b => new A : (b: A) => A
>b : A
>new A : A
>A : typeof A
@@ -2,12 +2,24 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete
'S' could be instantiated with an arbitrary type which could be unrelated to 'T'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(10,35): error TS2322: Type 'T' is not assignable to type 'S'.
'S' could be instantiated with an arbitrary type which could be unrelated to 'T'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(32,9): error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
Type 'I' is not assignable to type 'T'.
'I' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'I'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(32,9): error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(32,9): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(36,9): error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(36,9): error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(36,9): error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(36,9): error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(36,9): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(37,9): error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(37,9): error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(37,9): error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(37,9): error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(37,9): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts (5 errors) ====
==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts (15 errors) ====
class Chain<T> {
constructor(public value: T) { }
then<S extends T>(cb: (x: T) => S): Chain<S> {
@@ -48,15 +60,37 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete
// Ok to go down the chain, check the constraint at the end.
// Should get an error that we are assigning a string to a number
(new Chain2(i)).then(ii => t).then(tt => s).value.x = "";
~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
!!! error TS2684: Type 'I' is not assignable to type 'T'.
!!! error TS2684: 'I' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'I'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
// Staying at T or S should keep the constraint.
// Get an error when we assign a string to a number in both cases
(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value.x = "";
~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value.x = "";
~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'Chain2<I>' is not assignable to method's 'this' of type 'Chain2<T>'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
@@ -132,10 +132,10 @@ class Chain2<T extends I> {
(new Chain2(i)).then(ii => t).then(tt => s).value.x = "";
>(new Chain2(i)).then(ii => t).then(tt => s).value.x = "" : ""
>(new Chain2(i)).then(ii => t).then(tt => s).value.x : number
>(new Chain2(i)).then(ii => t).then(tt => s).value : S
>(new Chain2(i)).then(ii => t).then(tt => s) : Chain2<S>
>(new Chain2(i)).then(ii => t).then : <S extends T>(cb: (x: T) => S) => Chain2<S>
>(new Chain2(i)).then(ii => t) : Chain2<T>
>(new Chain2(i)).then(ii => t).then(tt => s).value : I
>(new Chain2(i)).then(ii => t).then(tt => s) : Chain2<I>
>(new Chain2(i)).then(ii => t).then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>(new Chain2(i)).then(ii => t) : Chain2<I>
>(new Chain2(i)).then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>(new Chain2(i)) : Chain2<I>
>new Chain2(i) : Chain2<I>
@@ -145,11 +145,11 @@ class Chain2<T extends I> {
>ii => t : (ii: I) => T
>ii : I
>t : T
>then : <S extends T>(cb: (x: T) => S) => Chain2<S>
>tt => s : (tt: T) => S
>tt : T
>then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>tt => s : (tt: I) => S
>tt : I
>s : S
>value : S
>value : I
>x : number
>"" : ""
@@ -158,14 +158,14 @@ class Chain2<T extends I> {
(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value.x = "";
>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value.x = "" : ""
>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value.x : number
>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value : T
>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t) : Chain2<T>
>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then : <S extends T>(cb: (x: T) => S) => Chain2<S>
>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t) : Chain2<T>
>(new Chain2(i)).then(ii => t).then(tt => t).then : <S extends T>(cb: (x: T) => S) => Chain2<S>
>(new Chain2(i)).then(ii => t).then(tt => t) : Chain2<T>
>(new Chain2(i)).then(ii => t).then : <S extends T>(cb: (x: T) => S) => Chain2<S>
>(new Chain2(i)).then(ii => t) : Chain2<T>
>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value : I
>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t) : Chain2<I>
>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t) : Chain2<I>
>(new Chain2(i)).then(ii => t).then(tt => t).then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>(new Chain2(i)).then(ii => t).then(tt => t) : Chain2<I>
>(new Chain2(i)).then(ii => t).then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>(new Chain2(i)).then(ii => t) : Chain2<I>
>(new Chain2(i)).then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>(new Chain2(i)) : Chain2<I>
>new Chain2(i) : Chain2<I>
@@ -175,33 +175,33 @@ class Chain2<T extends I> {
>ii => t : (ii: I) => T
>ii : I
>t : T
>then : <S extends T>(cb: (x: T) => S) => Chain2<S>
>tt => t : (tt: T) => T
>tt : T
>then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>tt => t : (tt: I) => T
>tt : I
>t : T
>then : <S extends T>(cb: (x: T) => S) => Chain2<S>
>tt => t : (tt: T) => T
>tt : T
>then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>tt => t : (tt: I) => T
>tt : I
>t : T
>then : <S extends T>(cb: (x: T) => S) => Chain2<S>
>tt => t : (tt: T) => T
>tt : T
>then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>tt => t : (tt: I) => T
>tt : I
>t : T
>value : T
>value : I
>x : number
>"" : ""
(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value.x = "";
>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value.x = "" : ""
>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value.x : number
>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value : S
>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s) : Chain2<S>
>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then : <S extends S>(cb: (x: S) => S) => Chain2<S>
>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s) : Chain2<S>
>(new Chain2(i)).then(ii => s).then(ss => s).then : <S extends S>(cb: (x: S) => S) => Chain2<S>
>(new Chain2(i)).then(ii => s).then(ss => s) : Chain2<S>
>(new Chain2(i)).then(ii => s).then : <S extends S>(cb: (x: S) => S) => Chain2<S>
>(new Chain2(i)).then(ii => s) : Chain2<S>
>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value : I
>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s) : Chain2<I>
>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s) : Chain2<I>
>(new Chain2(i)).then(ii => s).then(ss => s).then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>(new Chain2(i)).then(ii => s).then(ss => s) : Chain2<I>
>(new Chain2(i)).then(ii => s).then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>(new Chain2(i)).then(ii => s) : Chain2<I>
>(new Chain2(i)).then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>(new Chain2(i)) : Chain2<I>
>new Chain2(i) : Chain2<I>
@@ -211,19 +211,19 @@ class Chain2<T extends I> {
>ii => s : (ii: I) => S
>ii : I
>s : S
>then : <S extends S>(cb: (x: S) => S) => Chain2<S>
>ss => s : (ss: S) => S
>ss : S
>then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>ss => s : (ss: I) => S
>ss : I
>s : S
>then : <S extends S>(cb: (x: S) => S) => Chain2<S>
>ss => s : (ss: S) => S
>ss : S
>then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>ss => s : (ss: I) => S
>ss : I
>s : S
>then : <S extends S>(cb: (x: S) => S) => Chain2<S>
>ss => s : (ss: S) => S
>ss : S
>then : <S extends I>(cb: (x: I) => S) => Chain2<S>
>ss => s : (ss: I) => S
>ss : I
>s : S
>value : S
>value : I
>x : number
>"" : ""
@@ -24,7 +24,7 @@ someFunction(function(BaseClass) {
this.foo = "bar";
>this.foo = "bar" : "bar"
>this.foo : any
>this : this
>this : Hello
>foo : any
>"bar" : "bar"
}
@@ -7,19 +7,19 @@ class C {
this.a = true;
>this.a = true : true
>this.a : boolean
>this : this
>this : C
>a : boolean
>true : true
this.a = !!this.a;
>this.a = !!this.a : boolean
>this.a : boolean
>this : this
>this : C
>a : boolean
>!!this.a : boolean
>!this.a : boolean
>this.a : true
>this : this
>this : C
>a : true
}
}
@@ -0,0 +1,25 @@
tests/cases/compiler/a.js(13,5): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'A'.
==== tests/cases/compiler/a.js (1 errors) ====
// @ts-check
class A {
constructor() {
}
foo() {
return 4;
}
}
class B extends A {
constructor() {
super();
~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'A'.
this.foo = () => 3;
}
}
const i = new B();
i.foo();
@@ -26,7 +26,7 @@ class B extends A {
this.foo = () => 3;
>this.foo = () => 3 : () => number
>this.foo : any
>this : this
>this : B
>foo : any
>() => 3 : () => number
>3 : 3
@@ -0,0 +1,93 @@
tests/cases/conformance/jsx/file.tsx(10,5): error TS2416: Property 'render' in type 'Button' is not assignable to the same property in base type 'Component<ButtonProp, any>'.
Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
The 'this' types of each signature are incompatible.
Type 'Component<P, S>' is not assignable to type 'Button'.
Types of property 'render' are incompatible.
Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
The 'this' types of each signature are incompatible.
Type 'Button' is not assignable to type 'Component<P, S>'.
Types of property 'setState' are incompatible.
Type '{ (f: (prevState: any, props: ButtonProp) => any, callback?: () => any): void; (state: any, callback?: () => any): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: () => any): void; (state: S, callback?: () => any): void; }'.
Types of parameters 'f' and 'f' are incompatible.
Types of parameters 'props' and 'props' are incompatible.
Type 'ButtonProp' is not assignable to type 'P'.
'P' could be instantiated with an arbitrary type which could be unrelated to 'ButtonProp'.
tests/cases/conformance/jsx/file.tsx(28,2): error TS2416: Property 'render' in type 'InnerButton' is not assignable to the same property in base type 'Component<InnerButtonProp, any>'.
Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
The 'this' types of each signature are incompatible.
Type 'Component<P, S>' is not assignable to type 'InnerButton'.
Types of property 'render' are incompatible.
Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
The 'this' types of each signature are incompatible.
Type 'InnerButton' is not assignable to type 'Component<P, S>'.
Types of property 'setState' are incompatible.
Type '{ (f: (prevState: any, props: InnerButtonProp) => any, callback?: () => any): void; (state: any, callback?: () => any): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: () => any): void; (state: S, callback?: () => any): void; }'.
Types of parameters 'f' and 'f' are incompatible.
Types of parameters 'props' and 'props' are incompatible.
Type 'InnerButtonProp' is not assignable to type 'P'.
'P' could be instantiated with an arbitrary type which could be unrelated to 'InnerButtonProp'.
==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
import React = require('react');
interface ButtonProp {
a: number,
b: string,
children: Button;
}
class Button extends React.Component<ButtonProp, any> {
render() {
~~~~~~
!!! error TS2416: Property 'render' in type 'Button' is not assignable to the same property in base type 'Component<ButtonProp, any>'.
!!! error TS2416: Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'Component<P, S>' is not assignable to type 'Button'.
!!! error TS2416: Types of property 'render' are incompatible.
!!! error TS2416: Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'Button' is not assignable to type 'Component<P, S>'.
!!! error TS2416: Types of property 'setState' are incompatible.
!!! error TS2416: Type '{ (f: (prevState: any, props: ButtonProp) => any, callback?: () => any): void; (state: any, callback?: () => any): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: () => any): void; (state: S, callback?: () => any): void; }'.
!!! error TS2416: Types of parameters 'f' and 'f' are incompatible.
!!! error TS2416: Types of parameters 'props' and 'props' are incompatible.
!!! error TS2416: Type 'ButtonProp' is not assignable to type 'P'.
!!! error TS2416: 'P' could be instantiated with an arbitrary type which could be unrelated to 'ButtonProp'.
let condition: boolean;
if (condition) {
return <InnerButton {...this.props} />
}
else {
return (<InnerButton {...this.props} >
<div>Hello World</div>
</InnerButton>);
}
}
}
interface InnerButtonProp {
a: number
}
class InnerButton extends React.Component<InnerButtonProp, any> {
render() {
~~~~~~
!!! error TS2416: Property 'render' in type 'InnerButton' is not assignable to the same property in base type 'Component<InnerButtonProp, any>'.
!!! error TS2416: Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'Component<P, S>' is not assignable to type 'InnerButton'.
!!! error TS2416: Types of property 'render' are incompatible.
!!! error TS2416: Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'InnerButton' is not assignable to type 'Component<P, S>'.
!!! error TS2416: Types of property 'setState' are incompatible.
!!! error TS2416: Type '{ (f: (prevState: any, props: InnerButtonProp) => any, callback?: () => any): void; (state: any, callback?: () => any): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: () => any): void; (state: S, callback?: () => any): void; }'.
!!! error TS2416: Types of parameters 'f' and 'f' are incompatible.
!!! error TS2416: Types of parameters 'props' and 'props' are incompatible.
!!! error TS2416: Type 'InnerButtonProp' is not assignable to type 'P'.
!!! error TS2416: 'P' could be instantiated with an arbitrary type which could be unrelated to 'InnerButtonProp'.
return (<button>Hello</button>);
}
}
@@ -32,7 +32,7 @@ class Button extends React.Component<ButtonProp, any> {
><InnerButton {...this.props} /> : JSX.Element
>InnerButton : typeof InnerButton
>this.props : ButtonProp & { children?: React.ReactNode; }
>this : this
>this : Button
>props : ButtonProp & { children?: React.ReactNode; }
}
else {
@@ -41,7 +41,7 @@ class Button extends React.Component<ButtonProp, any> {
><InnerButton {...this.props} > <div>Hello World</div> </InnerButton> : JSX.Element
>InnerButton : typeof InnerButton
>this.props : ButtonProp & { children?: React.ReactNode; }
>this : this
>this : Button
>props : ButtonProp & { children?: React.ReactNode; }
<div>Hello World</div>
@@ -1,7 +1,35 @@
tests/cases/conformance/jsx/file.tsx(10,5): error TS2416: Property 'render' in type 'Button' is not assignable to the same property in base type 'Component<ButtonProp, any>'.
Type '() => Element' is not assignable to type '() => Element | null'.
The 'this' types of each signature are incompatible.
Type 'Component<P, S>' is not assignable to type 'Button'.
Types of property 'render' are incompatible.
Type '() => Element | null' is not assignable to type '() => Element'.
The 'this' types of each signature are incompatible.
Type 'Button' is not assignable to type 'Component<P, S>'.
Types of property 'setState' are incompatible.
Type '{ (f: (prevState: any, props: ButtonProp) => any, callback?: (() => any) | undefined): void; (state: any, callback?: (() => any) | undefined): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: (() => any) | undefined): void; (state: S, callback?: (() => any) | undefined): void; }'.
Types of parameters 'f' and 'f' are incompatible.
Types of parameters 'props' and 'props' are incompatible.
Type 'ButtonProp' is not assignable to type 'P'.
'P' could be instantiated with an arbitrary type which could be unrelated to 'ButtonProp'.
tests/cases/conformance/jsx/file.tsx(12,30): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
tests/cases/conformance/jsx/file.tsx(23,2): error TS2416: Property 'render' in type 'InnerButton' is not assignable to the same property in base type 'Component<InnerButtonProp, any>'.
Type '() => Element' is not assignable to type '() => Element | null'.
The 'this' types of each signature are incompatible.
Type 'Component<P, S>' is not assignable to type 'InnerButton'.
Types of property 'render' are incompatible.
Type '() => Element | null' is not assignable to type '() => Element'.
The 'this' types of each signature are incompatible.
Type 'InnerButton' is not assignable to type 'Component<P, S>'.
Types of property 'setState' are incompatible.
Type '{ (f: (prevState: any, props: InnerButtonProp) => any, callback?: (() => any) | undefined): void; (state: any, callback?: (() => any) | undefined): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: (() => any) | undefined): void; (state: S, callback?: (() => any) | undefined): void; }'.
Types of parameters 'f' and 'f' are incompatible.
Types of parameters 'props' and 'props' are incompatible.
Type 'InnerButtonProp' is not assignable to type 'P'.
'P' could be instantiated with an arbitrary type which could be unrelated to 'InnerButtonProp'.
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
import React = require('react');
interface ButtonProp {
@@ -12,6 +40,21 @@ tests/cases/conformance/jsx/file.tsx(12,30): error TS2710: 'children' are specif
class Button extends React.Component<ButtonProp, any> {
render() {
~~~~~~
!!! error TS2416: Property 'render' in type 'Button' is not assignable to the same property in base type 'Component<ButtonProp, any>'.
!!! error TS2416: Type '() => Element' is not assignable to type '() => Element | null'.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'Component<P, S>' is not assignable to type 'Button'.
!!! error TS2416: Types of property 'render' are incompatible.
!!! error TS2416: Type '() => Element | null' is not assignable to type '() => Element'.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'Button' is not assignable to type 'Component<P, S>'.
!!! error TS2416: Types of property 'setState' are incompatible.
!!! error TS2416: Type '{ (f: (prevState: any, props: ButtonProp) => any, callback?: (() => any) | undefined): void; (state: any, callback?: (() => any) | undefined): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: (() => any) | undefined): void; (state: S, callback?: (() => any) | undefined): void; }'.
!!! error TS2416: Types of parameters 'f' and 'f' are incompatible.
!!! error TS2416: Types of parameters 'props' and 'props' are incompatible.
!!! error TS2416: Type 'ButtonProp' is not assignable to type 'P'.
!!! error TS2416: 'P' could be instantiated with an arbitrary type which could be unrelated to 'ButtonProp'.
// Error children are specified twice
return (<InnerButton {...this.props} children="hi">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -27,6 +70,21 @@ tests/cases/conformance/jsx/file.tsx(12,30): error TS2710: 'children' are specif
class InnerButton extends React.Component<InnerButtonProp, any> {
render() {
~~~~~~
!!! error TS2416: Property 'render' in type 'InnerButton' is not assignable to the same property in base type 'Component<InnerButtonProp, any>'.
!!! error TS2416: Type '() => Element' is not assignable to type '() => Element | null'.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'Component<P, S>' is not assignable to type 'InnerButton'.
!!! error TS2416: Types of property 'render' are incompatible.
!!! error TS2416: Type '() => Element | null' is not assignable to type '() => Element'.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'InnerButton' is not assignable to type 'Component<P, S>'.
!!! error TS2416: Types of property 'setState' are incompatible.
!!! error TS2416: Type '{ (f: (prevState: any, props: InnerButtonProp) => any, callback?: (() => any) | undefined): void; (state: any, callback?: (() => any) | undefined): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: (() => any) | undefined): void; (state: S, callback?: (() => any) | undefined): void; }'.
!!! error TS2416: Types of parameters 'f' and 'f' are incompatible.
!!! error TS2416: Types of parameters 'props' and 'props' are incompatible.
!!! error TS2416: Type 'InnerButtonProp' is not assignable to type 'P'.
!!! error TS2416: 'P' could be instantiated with an arbitrary type which could be unrelated to 'InnerButtonProp'.
return (<button>Hello</button>);
}
}
@@ -28,7 +28,7 @@ class Button extends React.Component<ButtonProp, any> {
><InnerButton {...this.props} children="hi"> <div>Hello World</div> </InnerButton> : JSX.Element
>InnerButton : typeof InnerButton
>this.props : ButtonProp & { children?: React.ReactNode | undefined; }
>this : this
>this : Button
>props : ButtonProp & { children?: React.ReactNode | undefined; }
>children : string
@@ -0,0 +1,71 @@
tests/cases/conformance/jsx/file.tsx(12,5): error TS2416: Property 'render' in type 'FetchUser' is not assignable to the same property in base type 'Component<IFetchUserProps, any>'.
Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
The 'this' types of each signature are incompatible.
Type 'Component<P, S>' is not assignable to type 'FetchUser'.
Types of property 'render' are incompatible.
Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
The 'this' types of each signature are incompatible.
Type 'FetchUser' is not assignable to type 'Component<P, S>'.
Types of property 'setState' are incompatible.
Type '{ (f: (prevState: any, props: IFetchUserProps) => any, callback?: () => any): void; (state: any, callback?: () => any): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: () => any): void; (state: S, callback?: () => any): void; }'.
Types of parameters 'f' and 'f' are incompatible.
Types of parameters 'props' and 'props' are incompatible.
Type 'IFetchUserProps' is not assignable to type 'P'.
'P' could be instantiated with an arbitrary type which could be unrelated to 'IFetchUserProps'.
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
import React = require('react');
interface IUser {
Name: string;
}
interface IFetchUserProps {
children: (user: IUser) => JSX.Element;
}
class FetchUser extends React.Component<IFetchUserProps, any> {
render() {
~~~~~~
!!! error TS2416: Property 'render' in type 'FetchUser' is not assignable to the same property in base type 'Component<IFetchUserProps, any>'.
!!! error TS2416: Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'Component<P, S>' is not assignable to type 'FetchUser'.
!!! error TS2416: Types of property 'render' are incompatible.
!!! error TS2416: Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'FetchUser' is not assignable to type 'Component<P, S>'.
!!! error TS2416: Types of property 'setState' are incompatible.
!!! error TS2416: Type '{ (f: (prevState: any, props: IFetchUserProps) => any, callback?: () => any): void; (state: any, callback?: () => any): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: () => any): void; (state: S, callback?: () => any): void; }'.
!!! error TS2416: Types of parameters 'f' and 'f' are incompatible.
!!! error TS2416: Types of parameters 'props' and 'props' are incompatible.
!!! error TS2416: Type 'IFetchUserProps' is not assignable to type 'P'.
!!! error TS2416: 'P' could be instantiated with an arbitrary type which could be unrelated to 'IFetchUserProps'.
return this.state
? this.props.children(this.state.result)
: null;
}
}
// Ok
function UserName0() {
return (
<FetchUser>
{ user => (
<h1>{ user.Name }</h1>
) }
</FetchUser>
);
}
function UserName1() {
return (
<FetchUser>
{ user => (
<h1>{ user.Name }</h1>
) }
</FetchUser>
);
}
@@ -26,19 +26,19 @@ class FetchUser extends React.Component<IFetchUserProps, any> {
return this.state
>this.state ? this.props.children(this.state.result) : null : JSX.Element
>this.state : any
>this : this
>this : FetchUser
>state : any
? this.props.children(this.state.result)
>this.props.children(this.state.result) : JSX.Element
>this.props.children : ((user: IUser) => JSX.Element) & React.ReactNode
>this.props : IFetchUserProps & { children?: React.ReactNode; }
>this : this
>this : FetchUser
>props : IFetchUserProps & { children?: React.ReactNode; }
>children : ((user: IUser) => JSX.Element) & React.ReactNode
>this.state.result : any
>this.state : any
>this : this
>this : FetchUser
>state : any
>result : any
@@ -1,3 +1,17 @@
tests/cases/conformance/jsx/file.tsx(12,5): error TS2416: Property 'render' in type 'FetchUser' is not assignable to the same property in base type 'Component<IFetchUserProps, any>'.
Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
The 'this' types of each signature are incompatible.
Type 'Component<P, S>' is not assignable to type 'FetchUser'.
Types of property 'render' are incompatible.
Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
The 'this' types of each signature are incompatible.
Type 'FetchUser' is not assignable to type 'Component<P, S>'.
Types of property 'setState' are incompatible.
Type '{ (f: (prevState: any, props: IFetchUserProps) => any, callback?: () => any): void; (state: any, callback?: () => any): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: () => any): void; (state: S, callback?: () => any): void; }'.
Types of parameters 'f' and 'f' are incompatible.
Types of parameters 'props' and 'props' are incompatible.
Type 'IFetchUserProps' is not assignable to type 'P'.
'P' could be instantiated with an arbitrary type which could be unrelated to 'IFetchUserProps'.
tests/cases/conformance/jsx/file.tsx(24,28): error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'?
tests/cases/conformance/jsx/file.tsx(36,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'boolean | any[] | ReactChild'.
Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props
@@ -5,7 +19,7 @@ tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) =
Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
==== tests/cases/conformance/jsx/file.tsx (4 errors) ====
import React = require('react');
interface IUser {
@@ -18,6 +32,21 @@ tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) =
class FetchUser extends React.Component<IFetchUserProps, any> {
render() {
~~~~~~
!!! error TS2416: Property 'render' in type 'FetchUser' is not assignable to the same property in base type 'Component<IFetchUserProps, any>'.
!!! error TS2416: Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'Component<P, S>' is not assignable to type 'FetchUser'.
!!! error TS2416: Types of property 'render' are incompatible.
!!! error TS2416: Type '() => JSX.Element' is not assignable to type '() => JSX.Element'. Two different types with this name exist, but they are unrelated.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'FetchUser' is not assignable to type 'Component<P, S>'.
!!! error TS2416: Types of property 'setState' are incompatible.
!!! error TS2416: Type '{ (f: (prevState: any, props: IFetchUserProps) => any, callback?: () => any): void; (state: any, callback?: () => any): void; }' is not assignable to type '{ (f: (prevState: S, props: P) => S, callback?: () => any): void; (state: S, callback?: () => any): void; }'.
!!! error TS2416: Types of parameters 'f' and 'f' are incompatible.
!!! error TS2416: Types of parameters 'props' and 'props' are incompatible.
!!! error TS2416: Type 'IFetchUserProps' is not assignable to type 'P'.
!!! error TS2416: 'P' could be instantiated with an arbitrary type which could be unrelated to 'IFetchUserProps'.
return this.state
? this.props.children(this.state.result)
: null;
@@ -26,19 +26,19 @@ class FetchUser extends React.Component<IFetchUserProps, any> {
return this.state
>this.state ? this.props.children(this.state.result) : null : JSX.Element
>this.state : any
>this : this
>this : FetchUser
>state : any
? this.props.children(this.state.result)
>this.props.children(this.state.result) : JSX.Element
>this.props.children : ((user: IUser) => JSX.Element) & React.ReactNode
>this.props : IFetchUserProps & { children?: React.ReactNode; }
>this : this
>this : FetchUser
>props : IFetchUserProps & { children?: React.ReactNode; }
>children : ((user: IUser) => JSX.Element) & React.ReactNode
>this.state.result : any
>this.state : any
>this : this
>this : FetchUser
>state : any
>result : any
@@ -0,0 +1,50 @@
tests/cases/conformance/jsx/checkJsxSubtleSkipContextSensitiveBug.tsx(13,5): error TS2416: Property 'render' in type 'AsyncLoader<TResult>' is not assignable to the same property in base type 'Component<AsyncLoaderProps<TResult>, {}, any>'.
Type '() => null' is not assignable to type '() => ReactNode'.
The 'this' types of each signature are incompatible.
Type 'Component<P, S, SS>' is not assignable to type 'AsyncLoader<TResult>'.
Types of property 'render' are incompatible.
Type '() => ReactNode' is not assignable to type '() => null'.
The 'this' types of each signature are incompatible.
Type 'AsyncLoader<TResult>' is not assignable to type 'Component<P, S, SS>'.
Types of property 'props' are incompatible.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<AsyncLoaderProps<TResult>>' is not assignable to type 'Readonly<{ children?: ReactNode; }> & Readonly<P>'.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<AsyncLoaderProps<TResult>>' is not assignable to type 'Readonly<P>'.
==== tests/cases/conformance/jsx/checkJsxSubtleSkipContextSensitiveBug.tsx (1 errors) ====
/// <reference path="/.lib/react16.d.ts" />
import * as React from "react";
interface ErrorResult { error: true }
interface AsyncLoaderProps<TResult> {
readonly prop1: () => Promise<TResult>;
readonly prop2: (result: Exclude<TResult, ErrorResult>) => any;
}
class AsyncLoader<TResult> extends React.Component<AsyncLoaderProps<TResult>> {
render() { return null; }
~~~~~~
!!! error TS2416: Property 'render' in type 'AsyncLoader<TResult>' is not assignable to the same property in base type 'Component<AsyncLoaderProps<TResult>, {}, any>'.
!!! error TS2416: Type '() => null' is not assignable to type '() => ReactNode'.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'Component<P, S, SS>' is not assignable to type 'AsyncLoader<TResult>'.
!!! error TS2416: Types of property 'render' are incompatible.
!!! error TS2416: Type '() => ReactNode' is not assignable to type '() => null'.
!!! error TS2416: The 'this' types of each signature are incompatible.
!!! error TS2416: Type 'AsyncLoader<TResult>' is not assignable to type 'Component<P, S, SS>'.
!!! error TS2416: Types of property 'props' are incompatible.
!!! error TS2416: Type 'Readonly<{ children?: ReactNode; }> & Readonly<AsyncLoaderProps<TResult>>' is not assignable to type 'Readonly<{ children?: ReactNode; }> & Readonly<P>'.
!!! error TS2416: Type 'Readonly<{ children?: ReactNode; }> & Readonly<AsyncLoaderProps<TResult>>' is not assignable to type 'Readonly<P>'.
}
async function load(): Promise<{ success: true } | ErrorResult> {
return { success: true };
}
const loader = <AsyncLoader
prop1={load}
prop2={result => result}
/>;
@@ -10,10 +10,14 @@ tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(43,18): error TS17009: 's
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(44,18): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(45,18): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(59,27): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(60,13): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Foo'.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(63,13): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Foo'.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(72,13): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Foo'.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(75,27): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(76,13): error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Foo'.
==== tests/cases/compiler/checkSuperCallBeforeThisAccess.ts (13 errors) ====
==== tests/cases/compiler/checkSuperCallBeforeThisAccess.ts (17 errors) ====
class A {
x = 1;
}
@@ -98,9 +102,13 @@ tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(75,27): error TS17009: 's
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
super(value);
~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Foo'.
}
else {
super(1337);
~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Foo'.
}
}
bar(): number { return 4; }
@@ -110,12 +118,16 @@ tests/cases/compiler/checkSuperCallBeforeThisAccess.ts(75,27): error TS17009: 's
constructor(something: boolean) {
if (something) {
super(1337);
~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Foo'.
}
else {
const value = this.bar(); // Error
~~~~
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
super(value);
~~~~~~~~~~~~
!!! error TS2684: The 'this' context of type 'void' is not assignable to method's 'this' of type 'Foo'.
}
}
bar(): number { return 4; }

Some files were not shown because too many files have changed in this diff Show More