diff --git a/tests/baselines/reference/arrayBufferIsViewNarrowsType.types b/tests/baselines/reference/arrayBufferIsViewNarrowsType.types index b9d4f3db81b..129b7d601d8 100644 --- a/tests/baselines/reference/arrayBufferIsViewNarrowsType.types +++ b/tests/baselines/reference/arrayBufferIsViewNarrowsType.types @@ -4,7 +4,7 @@ var obj: Object; >Object : Object if (ArrayBuffer.isView(obj)) { ->ArrayBuffer.isView(obj) : arg is ArrayBufferView +>ArrayBuffer.isView(obj) : boolean >ArrayBuffer.isView : (arg: any) => arg is ArrayBufferView >ArrayBuffer : ArrayBufferConstructor >isView : (arg: any) => arg is ArrayBufferView diff --git a/tests/baselines/reference/computedPropertyNames36_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames36_ES5.errors.txt index 6c38043c8e0..506a9ca15d1 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames36_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts(8,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts(8,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES5.ts(8, // Computed properties get ["get1"]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. set ["set1"](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames36_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames36_ES6.errors.txt index 8127898fde4..cf50807ac54 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames36_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts(8,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts(8,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames36_ES6.ts(8, // Computed properties get ["get1"]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. set ["set1"](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames38_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames38_ES5.errors.txt index acc08ee5527..2e5313caa41 100644 --- a/tests/baselines/reference/computedPropertyNames38_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames38_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts(8,5): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts(8,9): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES5.ts(8, // Computed properties get [1 << 6]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'. set [1 << 6](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames38_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames38_ES6.errors.txt index 0a95b37f9a9..4c6e78c5b04 100644 --- a/tests/baselines/reference/computedPropertyNames38_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames38_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts(8,5): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts(8,9): error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames38_ES6.ts(8, // Computed properties get [1 << 6]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '[1 << 6]' of type 'Foo' is not assignable to string index type 'Foo2'. set [1 << 6](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames39_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames39_ES5.errors.txt index 669314676f9..a204ef4ae34 100644 --- a/tests/baselines/reference/computedPropertyNames39_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames39_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts(8,5): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts(8,9): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES5.ts(8, // Computed properties get [1 << 6]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'. set [1 << 6](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames39_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames39_ES6.errors.txt index 38f432162d5..d2e2494c87a 100644 --- a/tests/baselines/reference/computedPropertyNames39_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames39_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts(8,5): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts(8,9): error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames39_ES6.ts(8, // Computed properties get [1 << 6]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2412: Property '[1 << 6]' of type 'Foo' is not assignable to numeric index type 'Foo2'. set [1 << 6](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames43_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames43_ES5.errors.txt index 62c239a5a54..d777ae659de 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames43_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts(10,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts(10,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES5.ts(10 class D extends C { // Computed properties get ["get1"]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. set ["set1"](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames43_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames43_ES6.errors.txt index 0efe0ba39ec..6af43ebfa5c 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames43_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts(10,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts(10,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames43_ES6.ts(10 class D extends C { // Computed properties get ["get1"]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. set ["set1"](p: Foo2) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames44_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames44_ES5.errors.txt index 35ab422e093..43801ab3d62 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames44_ES5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(6,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. -tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(10,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(6,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(10,9): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts (2 errors) ==== @@ -9,12 +9,12 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES5.ts(10 class C { [s: string]: Foo2; get ["get1"]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. } class D extends C { set ["set1"](p: Foo) { } - ~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames44_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames44_ES6.errors.txt index 5170746395c..28b861347a3 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames44_ES6.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(6,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. -tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(10,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(6,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(10,9): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts (2 errors) ==== @@ -9,12 +9,12 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames44_ES6.ts(10 class C { [s: string]: Foo2; get ["get1"]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. } class D extends C { set ["set1"](p: Foo) { } - ~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames45_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames45_ES5.errors.txt index 8baae68f337..f06d199ba5a 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames45_ES5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(5,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. -tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(5,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11,9): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts (2 errors) ==== @@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11 class C { get ["get1"]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. } @@ -16,6 +16,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES5.ts(11 // No error when the indexer is in a class more derived than the computed property [s: string]: Foo2; set ["set1"](p: Foo) { } - ~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames45_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames45_ES6.errors.txt index e329785f4cf..626ed14ad1a 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames45_ES6.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(5,5): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. -tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11,5): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(5,9): error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11,9): error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts (2 errors) ==== @@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11 class C { get ["get1"]() { return new Foo } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["get1"]' of type 'Foo' is not assignable to string index type 'Foo2'. } @@ -16,6 +16,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames45_ES6.ts(11 // No error when the indexer is in a class more derived than the computed property [s: string]: Foo2; set ["set1"](p: Foo) { } - ~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2411: Property '["set1"]' of type 'Foo' is not assignable to string index type 'Foo2'. } \ No newline at end of file diff --git a/tests/baselines/reference/getAndSetNotIdenticalType.errors.txt b/tests/baselines/reference/getAndSetNotIdenticalType.errors.txt index 6c55f966eee..a16cbfe7b37 100644 --- a/tests/baselines/reference/getAndSetNotIdenticalType.errors.txt +++ b/tests/baselines/reference/getAndSetNotIdenticalType.errors.txt @@ -1,23 +1,21 @@ -tests/cases/compiler/getAndSetNotIdenticalType.ts(2,5): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/compiler/getAndSetNotIdenticalType.ts(2,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/getAndSetNotIdenticalType.ts(5,5): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/compiler/getAndSetNotIdenticalType.ts(2,9): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/compiler/getAndSetNotIdenticalType.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/getAndSetNotIdenticalType.ts(5,9): error TS2380: 'get' and 'set' accessor must have the same type. ==== tests/cases/compiler/getAndSetNotIdenticalType.ts (4 errors) ==== class C { get x(): number { - ~~~~~~~~~~~~~~~~~ ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + ~ +!!! error TS2380: 'get' and 'set' accessor must have the same type. return 1; - ~~~~~~~~~~~~~~~~~ } - ~~~~~ -!!! error TS2380: 'get' and 'set' accessor must have the same type. set x(v: string) { } - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2380: 'get' and 'set' accessor must have the same type. ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + ~ +!!! error TS2380: 'get' and 'set' accessor must have the same type. } \ No newline at end of file diff --git a/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt b/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt index 5cdb9b3a36f..c9fae8cc89c 100644 --- a/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt +++ b/tests/baselines/reference/getAndSetNotIdenticalType2.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,5): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,5): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/compiler/getAndSetNotIdenticalType2.ts(5,9): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/getAndSetNotIdenticalType2.ts(8,9): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/compiler/getAndSetNotIdenticalType2.ts(9,9): error TS2322: Type 'A' is not assignable to type 'A'. Type 'string' is not assignable to type 'T'. @@ -12,26 +12,22 @@ tests/cases/compiler/getAndSetNotIdenticalType2.ts(9,9): error TS2322: Type 'A { data: A; get x(): A { - ~~~~~~~~~~~~~~~ ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - return this.data; - ~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ + ~ !!! error TS2380: 'get' and 'set' accessor must have the same type. + return this.data; + } set x(v: A) { - ~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + ~ +!!! error TS2380: 'get' and 'set' accessor must have the same type. this.data = v; - ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2322: Type 'A' is not assignable to type 'A'. !!! error TS2322: Type 'string' is not assignable to type 'T'. } - ~~~~~ -!!! error TS2380: 'get' and 'set' accessor must have the same type. } var x = new C(); diff --git a/tests/baselines/reference/getAndSetNotIdenticalType3.errors.txt b/tests/baselines/reference/getAndSetNotIdenticalType3.errors.txt index 0aac384f7c3..3fb17d65a40 100644 --- a/tests/baselines/reference/getAndSetNotIdenticalType3.errors.txt +++ b/tests/baselines/reference/getAndSetNotIdenticalType3.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/getAndSetNotIdenticalType3.ts(5,5): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/compiler/getAndSetNotIdenticalType3.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/getAndSetNotIdenticalType3.ts(8,5): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/compiler/getAndSetNotIdenticalType3.ts(5,9): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/compiler/getAndSetNotIdenticalType3.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/getAndSetNotIdenticalType3.ts(8,9): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/compiler/getAndSetNotIdenticalType3.ts(9,9): error TS2322: Type 'A' is not assignable to type 'A'. Type 'string' is not assignable to type 'number'. @@ -12,26 +12,22 @@ tests/cases/compiler/getAndSetNotIdenticalType3.ts(9,9): error TS2322: Type 'A { data: A; get x(): A { - ~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - return this.data; - ~~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ + ~ !!! error TS2380: 'get' and 'set' accessor must have the same type. + return this.data; + } set x(v: A) { - ~~~~~~~~~~~~~~~~~~~~~ ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + ~ +!!! error TS2380: 'get' and 'set' accessor must have the same type. this.data = v; - ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ !!! error TS2322: Type 'A' is not assignable to type 'A'. !!! error TS2322: Type 'string' is not assignable to type 'number'. } - ~~~~~ -!!! error TS2380: 'get' and 'set' accessor must have the same type. } var x = new C(); diff --git a/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt b/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt index 36538aef4f3..bb43d96b003 100644 --- a/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt +++ b/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(23,10): error TS7024: F tests/cases/compiler/implicitAnyFromCircularInference.ts(26,10): error TS7023: 'h' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. tests/cases/compiler/implicitAnyFromCircularInference.ts(28,14): error TS7023: 'foo' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. tests/cases/compiler/implicitAnyFromCircularInference.ts(41,5): error TS7022: 's' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/compiler/implicitAnyFromCircularInference.ts(46,5): error TS7023: 'x' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. +tests/cases/compiler/implicitAnyFromCircularInference.ts(46,9): error TS7023: 'x' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. ==== tests/cases/compiler/implicitAnyFromCircularInference.ts (11 errors) ==== @@ -78,11 +78,9 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(46,5): error TS7023: 'x class D { // Error expected get x() { - ~~~~~~~~~ - return this.x; - ~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ + ~ !!! error TS7023: 'x' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. + return this.x; + } } \ No newline at end of file diff --git a/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt b/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt index 4d9008cd56a..460ff97b10e 100644 --- a/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt +++ b/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(3,5): error TS7008: Member 'getAndSet' implicitly has an 'any' type. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(4,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,5): error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,28): error TS7006: Parameter 'newXValue' implicitly has an 'any' type. -tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,5): error TS7010: 'haveOnlyGet', which lacks return-type annotation, implicitly has an 'any' return type. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): error TS7010: 'haveOnlyGet', which lacks return-type annotation, implicitly has an 'any' return type. ==== tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts (8 errors) ==== @@ -30,24 +30,21 @@ tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): er class SetterOnly { public set haveOnlySet(newXValue) { // error at "haveOnlySet, newXValue" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + ~~~~~~~~~~~ +!!! error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation. ~~~~~~~~~ !!! error TS7006: Parameter 'newXValue' implicitly has an 'any' type. } - ~~~~~ -!!! error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation. } class GetterOnly { public get haveOnlyGet() { // error at "haveOnlyGet" - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. - return null; - ~~~~~~~~~~~~~~~~~~~~ - } - ~~~~~ + ~~~~~~~~~~~ !!! error TS7010: 'haveOnlyGet', which lacks return-type annotation, implicitly has an 'any' return type. + return null; + } } \ No newline at end of file diff --git a/tests/baselines/reference/isArray.types b/tests/baselines/reference/isArray.types index de54e9d064c..bc452b12bef 100644 --- a/tests/baselines/reference/isArray.types +++ b/tests/baselines/reference/isArray.types @@ -4,7 +4,7 @@ var maybeArray: number | number[]; if (Array.isArray(maybeArray)) { ->Array.isArray(maybeArray) : arg is any[] +>Array.isArray(maybeArray) : boolean >Array.isArray : (arg: any) => arg is any[] >Array : ArrayConstructor >isArray : (arg: any) => arg is any[] diff --git a/tests/baselines/reference/objectLiteralErrors.errors.txt b/tests/baselines/reference/objectLiteralErrors.errors.txt index 19935f52bdc..134b79a443e 100644 --- a/tests/baselines/reference/objectLiteralErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralErrors.errors.txt @@ -89,11 +89,11 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(39,26) tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,13): error TS2300: Duplicate identifier 'a'. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46): error TS1119: An object literal cannot have property and accessor with the same name. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46): error TS2300: Duplicate identifier 'a'. -tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,12): error TS2380: 'get' and 'set' accessor must have the same type. -tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,43): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,16): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,47): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,29): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,12): error TS2380: 'get' and 'set' accessor must have the same type. -tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,51): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,16): error TS2380: 'get' and 'set' accessor must have the same type. +tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,55): error TS2380: 'get' and 'set' accessor must have the same type. ==== tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts (96 errors) ==== @@ -322,16 +322,16 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,51) // Get and set accessor with mismatched type annotations var g1 = { get a(): number { return 4; }, set a(n: string) { } }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS2380: 'get' and 'set' accessor must have the same type. - ~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS2380: 'get' and 'set' accessor must have the same type. var g2 = { get a() { return 4; }, set a(n: string) { } }; ~ !!! error TS2322: Type 'number' is not assignable to type 'string'. var g3 = { get a(): number { return undefined; }, set a(n: string) { } }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS2380: 'get' and 'set' accessor must have the same type. - ~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS2380: 'get' and 'set' accessor must have the same type. \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralCheckedInIf02.types b/tests/baselines/reference/stringLiteralCheckedInIf02.types index f91eea03097..79f4c6a223a 100644 --- a/tests/baselines/reference/stringLiteralCheckedInIf02.types +++ b/tests/baselines/reference/stringLiteralCheckedInIf02.types @@ -31,7 +31,7 @@ function f(foo: T) { >T : ("a" | "b")[] | "a" | "b" if (isS(foo)) { ->isS(foo) : t is "a" | "b" +>isS(foo) : boolean >isS : (t: ("a" | "b")[] | "a" | "b") => t is "a" | "b" >foo : ("a" | "b")[] | "a" | "b" diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.types b/tests/baselines/reference/stringLiteralTypesAsTags01.types index 6966ede5482..a7f403e76ec 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags01.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.types @@ -88,7 +88,7 @@ let x: A = { } if (hasKind(x, "A")) { ->hasKind(x, "A") : entity is A +>hasKind(x, "A") : boolean >hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; (entity: Entity, kind: "A" | "B"): entity is Entity; } >x : A >"A" : "A" @@ -105,7 +105,7 @@ else { if (!hasKind(x, "B")) { >!hasKind(x, "B") : boolean ->hasKind(x, "B") : entity is B +>hasKind(x, "B") : boolean >hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; (entity: Entity, kind: "A" | "B"): entity is Entity; } >x : A >"B" : "B" diff --git a/tests/baselines/reference/stringLiteralTypesAsTags03.types b/tests/baselines/reference/stringLiteralTypesAsTags03.types index a1d83a1c058..25816659388 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags03.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags03.types @@ -85,7 +85,7 @@ let x: A = { } if (hasKind(x, "A")) { ->hasKind(x, "A") : entity is A +>hasKind(x, "A") : boolean >hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; } >x : A >"A" : "A" @@ -102,7 +102,7 @@ else { if (!hasKind(x, "B")) { >!hasKind(x, "B") : boolean ->hasKind(x, "B") : entity is B +>hasKind(x, "B") : boolean >hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; } >x : A >"B" : "B" diff --git a/tests/baselines/reference/typeGuardFunction.types b/tests/baselines/reference/typeGuardFunction.types index 9bab1e7ca2c..50a5fcaf324 100644 --- a/tests/baselines/reference/typeGuardFunction.types +++ b/tests/baselines/reference/typeGuardFunction.types @@ -54,7 +54,7 @@ var b: B; // Basic if (isC(a)) { ->isC(a) : p1 is C +>isC(a) : boolean >isC : (p1: any) => p1 is C >a : A @@ -70,7 +70,7 @@ var subType: C; >C : C if(isA(subType)) { ->isA(subType) : p1 is A +>isA(subType) : boolean >isA : (p1: any) => p1 is A >subType : C @@ -87,7 +87,7 @@ var union: A | B; >B : B if(isA(union)) { ->isA(union) : p1 is A +>isA(union) : boolean >isA : (p1: any) => p1 is A >union : A | B @@ -118,7 +118,7 @@ declare function isC_multipleParams(p1, p2): p1 is C; >C : C if (isC_multipleParams(a, 0)) { ->isC_multipleParams(a, 0) : p1 is C +>isC_multipleParams(a, 0) : boolean >isC_multipleParams : (p1: any, p2: any) => p1 is C >a : A >0 : number @@ -197,7 +197,7 @@ declare function acceptingBoolean(a: boolean); acceptingBoolean(isA(a)); >acceptingBoolean(isA(a)) : any >acceptingBoolean : (a: boolean) => any ->isA(a) : p1 is A +>isA(a) : boolean >isA : (p1: any) => p1 is A >a : A @@ -223,8 +223,8 @@ let union2: C | B; let union3: boolean | B = isA(union2) || union2; >union3 : boolean | B >B : B ->isA(union2) || union2 : p1 is A | B ->isA(union2) : p1 is A +>isA(union2) || union2 : boolean | B +>isA(union2) : boolean >isA : (p1: any) => p1 is A >union2 : C | B >union2 : B diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 9ecad007672..8e4bf651518 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(2,7): error TS2300: Duplicate identifier 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type 'string' is not assignable to type 'x is A'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type 'string' is not assignable to type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,55): error TS2304: Cannot find name 'x'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS1144: '{' or ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS2304: Cannot find name 'is'. @@ -43,9 +43,13 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,22) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,22): error TS2304: Cannot find name 'is'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,25): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,27): error TS1005: ';' expected. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2322: Type 'boolean' is not assignable to type 'D'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(111,16): error TS2408: Setters cannot return a value. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(116,18): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,22): error TS2304: Cannot find name 'p1'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,25): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,25): error TS2304: Cannot find name 'is'. @@ -57,7 +61,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,34 tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern. -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (50 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (54 errors) ==== class A { ~ @@ -76,7 +80,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 function hasANonBooleanReturnStatement(x): x is A { return ''; ~~ -!!! error TS2322: Type 'string' is not assignable to type 'x is A'. +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. } function hasTypeGuardTypeInsideTypeGuardType(x): x is x is A { @@ -245,6 +249,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 // Non-compatiable type predicate positions for signature declarations class D { constructor(p1: A): p1 is C { + ~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return true; ~~~~ !!! error TS2322: Type 'boolean' is not assignable to type 'D'. @@ -252,9 +258,13 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } get m1(p1: A): p1 is C { + ~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return true; } set m2(p1: A): p1 is C { + ~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return true; ~~~~ !!! error TS2408: Setters cannot return a value. @@ -263,6 +273,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 interface I1 { new (p1: A): p1 is C; + ~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. } interface I2 { diff --git a/tests/baselines/reference/typeGuardFunctionGenerics.types b/tests/baselines/reference/typeGuardFunctionGenerics.types index 1f2ad2b69be..c4655e71f0c 100644 --- a/tests/baselines/reference/typeGuardFunctionGenerics.types +++ b/tests/baselines/reference/typeGuardFunctionGenerics.types @@ -100,7 +100,7 @@ let test1: boolean = funA(isB); >isB : (p1: any) => p1 is B if (funB(retC, a)) { ->funB(retC, a) : p2 is C +>funB(retC, a) : boolean >funB : (p1: (p1: any) => T, p2: any) => p2 is T >retC : (x: any) => C >a : A @@ -118,7 +118,7 @@ let test2: B = funC(isB); >isB : (p1: any) => p1 is B if (funD(isC, a)) { ->funD(isC, a) : p2 is C +>funD(isC, a) : boolean >funD : (p1: (p1: any) => p1 is T, p2: any) => p2 is T >isC : (p1: any) => p1 is C >a : A diff --git a/tests/baselines/reference/typeGuardFunctionOfFormThis.types b/tests/baselines/reference/typeGuardFunctionOfFormThis.types index e91c77dd07a..6b21fea3457 100644 --- a/tests/baselines/reference/typeGuardFunctionOfFormThis.types +++ b/tests/baselines/reference/typeGuardFunctionOfFormThis.types @@ -45,7 +45,7 @@ let a: RoyalGuard = new FollowerGuard(); >FollowerGuard : typeof FollowerGuard if (a.isLeader()) { ->a.isLeader() : this is LeadGuard +>a.isLeader() : boolean >a.isLeader : () => this is LeadGuard >a : RoyalGuard >isLeader : () => this is LeadGuard @@ -57,7 +57,7 @@ if (a.isLeader()) { >lead : () => void } else if (a.isFollower()) { ->a.isFollower() : this is FollowerGuard +>a.isFollower() : boolean >a.isFollower : () => this is FollowerGuard >a : RoyalGuard >isFollower : () => this is FollowerGuard @@ -78,7 +78,7 @@ let b: GuardInterface; >GuardInterface : GuardInterface if (b.isLeader()) { ->b.isLeader() : this is LeadGuard +>b.isLeader() : boolean >b.isLeader : () => this is LeadGuard >b : GuardInterface >isLeader : () => this is LeadGuard @@ -90,7 +90,7 @@ if (b.isLeader()) { >lead : () => void } else if (b.isFollower()) { ->b.isFollower() : this is FollowerGuard +>b.isFollower() : boolean >b.isFollower : () => this is FollowerGuard >b : GuardInterface >isFollower : () => this is FollowerGuard @@ -103,8 +103,8 @@ else if (b.isFollower()) { } if (((a.isLeader)())) { ->((a.isLeader)()) : this is LeadGuard ->(a.isLeader)() : this is LeadGuard +>((a.isLeader)()) : boolean +>(a.isLeader)() : boolean >(a.isLeader) : () => this is LeadGuard >a.isLeader : () => this is LeadGuard >a : RoyalGuard @@ -117,8 +117,8 @@ if (((a.isLeader)())) { >lead : () => void } else if (((a).isFollower())) { ->((a).isFollower()) : this is FollowerGuard ->(a).isFollower() : this is FollowerGuard +>((a).isFollower()) : boolean +>(a).isFollower() : boolean >(a).isFollower : () => this is FollowerGuard >(a) : RoyalGuard >a : RoyalGuard @@ -132,8 +132,8 @@ else if (((a).isFollower())) { } if (((a["isLeader"])())) { ->((a["isLeader"])()) : this is LeadGuard ->(a["isLeader"])() : this is LeadGuard +>((a["isLeader"])()) : boolean +>(a["isLeader"])() : boolean >(a["isLeader"]) : () => this is LeadGuard >a["isLeader"] : () => this is LeadGuard >a : RoyalGuard @@ -146,8 +146,8 @@ if (((a["isLeader"])())) { >lead : () => void } else if (((a)["isFollower"]())) { ->((a)["isFollower"]()) : this is FollowerGuard ->(a)["isFollower"]() : this is FollowerGuard +>((a)["isFollower"]()) : boolean +>(a)["isFollower"]() : boolean >(a)["isFollower"] : () => this is FollowerGuard >(a) : RoyalGuard >a : RoyalGuard @@ -166,7 +166,7 @@ var holder2 = {a}; >a : RoyalGuard if (holder2.a.isLeader()) { ->holder2.a.isLeader() : this is LeadGuard +>holder2.a.isLeader() : boolean >holder2.a.isLeader : () => this is LeadGuard >holder2.a : RoyalGuard >holder2 : { a: RoyalGuard; } @@ -232,7 +232,7 @@ let guard = new ArrowGuard(); >ArrowGuard : typeof ArrowGuard if (guard.isElite()) { ->guard.isElite() : this is ArrowElite +>guard.isElite() : boolean >guard.isElite : () => this is ArrowElite >guard : ArrowGuard >isElite : () => this is ArrowElite @@ -244,7 +244,7 @@ if (guard.isElite()) { >defend : () => void } else if (guard.isMedic()) { ->guard.isMedic() : this is ArrowMedic +>guard.isMedic() : boolean >guard.isMedic : () => this is ArrowMedic >guard : ArrowGuard >isMedic : () => this is ArrowMedic @@ -297,7 +297,7 @@ let crate: Crate<{}>; >Crate : Crate if (crate.isSundries()) { ->crate.isSundries() : this is Crate +>crate.isSundries() : boolean >crate.isSundries : () => this is Crate >crate : Crate<{}> >isSundries : () => this is Crate @@ -312,7 +312,7 @@ if (crate.isSundries()) { >true : boolean } else if (crate.isSupplies()) { ->crate.isSupplies() : this is Crate +>crate.isSupplies() : boolean >crate.isSupplies : () => this is Crate >crate : Crate<{}> >isSupplies : () => this is Crate @@ -405,7 +405,7 @@ a.isFollower = mimic.isFollower; >isFollower : () => this is MimicFollower if (mimic.isFollower()) { ->mimic.isFollower() : this is MimicFollower +>mimic.isFollower() : boolean >mimic.isFollower : () => this is MimicFollower >mimic : MimicGuard >isFollower : () => this is MimicFollower diff --git a/tests/baselines/reference/typeGuardOfFormFunctionEquality.js b/tests/baselines/reference/typeGuardOfFormFunctionEquality.js new file mode 100644 index 00000000000..c15c1a739a9 --- /dev/null +++ b/tests/baselines/reference/typeGuardOfFormFunctionEquality.js @@ -0,0 +1,26 @@ +//// [typeGuardOfFormFunctionEquality.ts] +declare function isString1(a: number, b: Object): b is string; + +declare function isString2(a: Object): a is string; + +switch (isString1(0, "")) { + case isString2(""): + default: +} + +var x = isString1(0, "") === isString2(""); + +function isString3(a: number, b: number, c: Object): c is string { + return isString1(0, c); +} + + +//// [typeGuardOfFormFunctionEquality.js] +switch (isString1(0, "")) { + case isString2(""): + default: +} +var x = isString1(0, "") === isString2(""); +function isString3(a, b, c) { + return isString1(0, c); +} diff --git a/tests/baselines/reference/typeGuardOfFormFunctionEquality.symbols b/tests/baselines/reference/typeGuardOfFormFunctionEquality.symbols new file mode 100644 index 00000000000..f1384050176 --- /dev/null +++ b/tests/baselines/reference/typeGuardOfFormFunctionEquality.symbols @@ -0,0 +1,41 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormFunctionEquality.ts === +declare function isString1(a: number, b: Object): b is string; +>isString1 : Symbol(isString1, Decl(typeGuardOfFormFunctionEquality.ts, 0, 0)) +>a : Symbol(a, Decl(typeGuardOfFormFunctionEquality.ts, 0, 27)) +>b : Symbol(b, Decl(typeGuardOfFormFunctionEquality.ts, 0, 37)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>b : Symbol(b, Decl(typeGuardOfFormFunctionEquality.ts, 0, 37)) + +declare function isString2(a: Object): a is string; +>isString2 : Symbol(isString2, Decl(typeGuardOfFormFunctionEquality.ts, 0, 62)) +>a : Symbol(a, Decl(typeGuardOfFormFunctionEquality.ts, 2, 27)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(typeGuardOfFormFunctionEquality.ts, 2, 27)) + +switch (isString1(0, "")) { +>isString1 : Symbol(isString1, Decl(typeGuardOfFormFunctionEquality.ts, 0, 0)) + + case isString2(""): +>isString2 : Symbol(isString2, Decl(typeGuardOfFormFunctionEquality.ts, 0, 62)) + + default: +} + +var x = isString1(0, "") === isString2(""); +>x : Symbol(x, Decl(typeGuardOfFormFunctionEquality.ts, 9, 3)) +>isString1 : Symbol(isString1, Decl(typeGuardOfFormFunctionEquality.ts, 0, 0)) +>isString2 : Symbol(isString2, Decl(typeGuardOfFormFunctionEquality.ts, 0, 62)) + +function isString3(a: number, b: number, c: Object): c is string { +>isString3 : Symbol(isString3, Decl(typeGuardOfFormFunctionEquality.ts, 9, 43)) +>a : Symbol(a, Decl(typeGuardOfFormFunctionEquality.ts, 11, 19)) +>b : Symbol(b, Decl(typeGuardOfFormFunctionEquality.ts, 11, 29)) +>c : Symbol(c, Decl(typeGuardOfFormFunctionEquality.ts, 11, 40)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>c : Symbol(c, Decl(typeGuardOfFormFunctionEquality.ts, 11, 40)) + + return isString1(0, c); +>isString1 : Symbol(isString1, Decl(typeGuardOfFormFunctionEquality.ts, 0, 0)) +>c : Symbol(c, Decl(typeGuardOfFormFunctionEquality.ts, 11, 40)) +} + diff --git a/tests/baselines/reference/typeGuardOfFormFunctionEquality.types b/tests/baselines/reference/typeGuardOfFormFunctionEquality.types new file mode 100644 index 00000000000..55f2e2aac0e --- /dev/null +++ b/tests/baselines/reference/typeGuardOfFormFunctionEquality.types @@ -0,0 +1,54 @@ +=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormFunctionEquality.ts === +declare function isString1(a: number, b: Object): b is string; +>isString1 : (a: number, b: Object) => b is string +>a : number +>b : Object +>Object : Object +>b : any + +declare function isString2(a: Object): a is string; +>isString2 : (a: Object) => a is string +>a : Object +>Object : Object +>a : any + +switch (isString1(0, "")) { +>isString1(0, "") : boolean +>isString1 : (a: number, b: Object) => b is string +>0 : number +>"" : string + + case isString2(""): +>isString2("") : boolean +>isString2 : (a: Object) => a is string +>"" : string + + default: +} + +var x = isString1(0, "") === isString2(""); +>x : boolean +>isString1(0, "") === isString2("") : boolean +>isString1(0, "") : boolean +>isString1 : (a: number, b: Object) => b is string +>0 : number +>"" : string +>isString2("") : boolean +>isString2 : (a: Object) => a is string +>"" : string + +function isString3(a: number, b: number, c: Object): c is string { +>isString3 : (a: number, b: number, c: Object) => c is string +>a : number +>b : number +>c : Object +>Object : Object +>c : any + + return isString1(0, c); +>isString1(0, c) : boolean +>isString1 : (a: number, b: Object) => b is string +>0 : number +>c : Object +} + diff --git a/tests/baselines/reference/typeGuardOfFormIsType.types b/tests/baselines/reference/typeGuardOfFormIsType.types index aa8f8cc7d60..e2059be7b63 100644 --- a/tests/baselines/reference/typeGuardOfFormIsType.types +++ b/tests/baselines/reference/typeGuardOfFormIsType.types @@ -67,7 +67,7 @@ str = isC1(c1Orc2) && c1Orc2.p1; // C1 >str = isC1(c1Orc2) && c1Orc2.p1 : string >str : string >isC1(c1Orc2) && c1Orc2.p1 : string ->isC1(c1Orc2) : x is C1 +>isC1(c1Orc2) : boolean >isC1 : (x: any) => x is C1 >c1Orc2 : C1 | C2 >c1Orc2.p1 : string @@ -78,7 +78,7 @@ num = isC2(c1Orc2) && c1Orc2.p2; // C2 >num = isC2(c1Orc2) && c1Orc2.p2 : number >num : number >isC2(c1Orc2) && c1Orc2.p2 : number ->isC2(c1Orc2) : x is C2 +>isC2(c1Orc2) : boolean >isC2 : (x: any) => x is C2 >c1Orc2 : C1 | C2 >c1Orc2.p2 : number @@ -89,7 +89,7 @@ str = isD1(c1Orc2) && c1Orc2.p1; // D1 >str = isD1(c1Orc2) && c1Orc2.p1 : string >str : string >isD1(c1Orc2) && c1Orc2.p1 : string ->isD1(c1Orc2) : x is D1 +>isD1(c1Orc2) : boolean >isD1 : (x: any) => x is D1 >c1Orc2 : C1 | C2 >c1Orc2.p1 : string @@ -100,7 +100,7 @@ num = isD1(c1Orc2) && c1Orc2.p3; // D1 >num = isD1(c1Orc2) && c1Orc2.p3 : number >num : number >isD1(c1Orc2) && c1Orc2.p3 : number ->isD1(c1Orc2) : x is D1 +>isD1(c1Orc2) : boolean >isD1 : (x: any) => x is D1 >c1Orc2 : C1 | C2 >c1Orc2.p3 : number @@ -116,7 +116,7 @@ num = isC2(c2Ord1) && c2Ord1.p2; // C2 >num = isC2(c2Ord1) && c2Ord1.p2 : number >num : number >isC2(c2Ord1) && c2Ord1.p2 : number ->isC2(c2Ord1) : x is C2 +>isC2(c2Ord1) : boolean >isC2 : (x: any) => x is C2 >c2Ord1 : C2 | D1 >c2Ord1.p2 : number @@ -127,7 +127,7 @@ num = isD1(c2Ord1) && c2Ord1.p3; // D1 >num = isD1(c2Ord1) && c2Ord1.p3 : number >num : number >isD1(c2Ord1) && c2Ord1.p3 : number ->isD1(c2Ord1) : x is D1 +>isD1(c2Ord1) : boolean >isD1 : (x: any) => x is D1 >c2Ord1 : C2 | D1 >c2Ord1.p3 : number @@ -138,7 +138,7 @@ str = isD1(c2Ord1) && c2Ord1.p1; // D1 >str = isD1(c2Ord1) && c2Ord1.p1 : string >str : string >isD1(c2Ord1) && c2Ord1.p1 : string ->isD1(c2Ord1) : x is D1 +>isD1(c2Ord1) : boolean >isD1 : (x: any) => x is D1 >c2Ord1 : C2 | D1 >c2Ord1.p1 : string @@ -150,7 +150,7 @@ var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1 >C2 : C2 >D1 : D1 >isC1(c2Ord1) && c2Ord1 : D1 ->isC1(c2Ord1) : x is C1 +>isC1(c2Ord1) : boolean >isC1 : (x: any) => x is C1 >c2Ord1 : C2 | D1 >c2Ord1 : D1 diff --git a/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types b/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types index 4e28e6a4d38..ea169e95413 100644 --- a/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types +++ b/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types @@ -98,7 +98,7 @@ str = isC1(c1Orc2) && c1Orc2.p1; // C1 >str = isC1(c1Orc2) && c1Orc2.p1 : string >str : string >isC1(c1Orc2) && c1Orc2.p1 : string ->isC1(c1Orc2) : x is C1 +>isC1(c1Orc2) : boolean >isC1 : (x: any) => x is C1 >c1Orc2 : C1 | C2 >c1Orc2.p1 : string @@ -109,7 +109,7 @@ num = isC2(c1Orc2) && c1Orc2.p2; // C2 >num = isC2(c1Orc2) && c1Orc2.p2 : number >num : number >isC2(c1Orc2) && c1Orc2.p2 : number ->isC2(c1Orc2) : x is C2 +>isC2(c1Orc2) : boolean >isC2 : (x: any) => x is C2 >c1Orc2 : C1 | C2 >c1Orc2.p2 : number @@ -120,7 +120,7 @@ str = isD1(c1Orc2) && c1Orc2.p1; // D1 >str = isD1(c1Orc2) && c1Orc2.p1 : string >str : string >isD1(c1Orc2) && c1Orc2.p1 : string ->isD1(c1Orc2) : x is D1 +>isD1(c1Orc2) : boolean >isD1 : (x: any) => x is D1 >c1Orc2 : C1 | C2 >c1Orc2.p1 : string @@ -131,7 +131,7 @@ num = isD1(c1Orc2) && c1Orc2.p3; // D1 >num = isD1(c1Orc2) && c1Orc2.p3 : number >num : number >isD1(c1Orc2) && c1Orc2.p3 : number ->isD1(c1Orc2) : x is D1 +>isD1(c1Orc2) : boolean >isD1 : (x: any) => x is D1 >c1Orc2 : C1 | C2 >c1Orc2.p3 : number @@ -147,7 +147,7 @@ num = isC2(c2Ord1) && c2Ord1.p2; // C2 >num = isC2(c2Ord1) && c2Ord1.p2 : number >num : number >isC2(c2Ord1) && c2Ord1.p2 : number ->isC2(c2Ord1) : x is C2 +>isC2(c2Ord1) : boolean >isC2 : (x: any) => x is C2 >c2Ord1 : C2 | D1 >c2Ord1.p2 : number @@ -158,7 +158,7 @@ num = isD1(c2Ord1) && c2Ord1.p3; // D1 >num = isD1(c2Ord1) && c2Ord1.p3 : number >num : number >isD1(c2Ord1) && c2Ord1.p3 : number ->isD1(c2Ord1) : x is D1 +>isD1(c2Ord1) : boolean >isD1 : (x: any) => x is D1 >c2Ord1 : C2 | D1 >c2Ord1.p3 : number @@ -169,7 +169,7 @@ str = isD1(c2Ord1) && c2Ord1.p1; // D1 >str = isD1(c2Ord1) && c2Ord1.p1 : string >str : string >isD1(c2Ord1) && c2Ord1.p1 : string ->isD1(c2Ord1) : x is D1 +>isD1(c2Ord1) : boolean >isD1 : (x: any) => x is D1 >c2Ord1 : C2 | D1 >c2Ord1.p1 : string @@ -181,7 +181,7 @@ var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1 >C2 : C2 >D1 : D1 >isC1(c2Ord1) && c2Ord1 : D1 ->isC1(c2Ord1) : x is C1 +>isC1(c2Ord1) : boolean >isC1 : (x: any) => x is C1 >c2Ord1 : C2 | D1 >c2Ord1 : D1 diff --git a/tests/baselines/reference/typeGuardOfFormThisMember.errors.txt b/tests/baselines/reference/typeGuardOfFormThisMember.errors.txt new file mode 100644 index 00000000000..21dc896fbd9 --- /dev/null +++ b/tests/baselines/reference/typeGuardOfFormThisMember.errors.txt @@ -0,0 +1,130 @@ +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(4,10): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(5,17): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(11,22): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(14,16): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(34,8): error TS2339: Property 'content' does not exist on type 'FileSystemObject'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(36,9): error TS2339: Property 'host' does not exist on type 'FileSystemObject'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(37,9): error TS2339: Property 'content' does not exist on type 'FileSystemObject'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(41,8): error TS2339: Property 'children' does not exist on type 'FileSystemObject'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(44,8): error TS2339: Property 'host' does not exist on type 'FileSystemObject'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(57,13): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(58,15): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(63,9): error TS2339: Property 'lead' does not exist on type 'GenericGuard'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(66,9): error TS2339: Property 'follow' does not exist on type 'GenericGuard'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(70,19): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(79,11): error TS2339: Property 'do' does not exist on type 'SpecificGuard'. + + +==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts (15 errors) ==== + // There's a 'File' class in the stdlib, wrap with a namespace to avoid collision + namespace Test { + export class FileSystemObject { + isFSO: this is FileSystemObject; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + get isFile(): this is File { + ~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + return this instanceof File; + } + set isFile(param) { + // noop + } + get isDirectory(): this is Directory { + ~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + return this instanceof Directory; + } + isNetworked: this is (Networked & this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + constructor(public path: string) {} + } + + export class File extends FileSystemObject { + constructor(path: string, public content: string) { super(path); } + } + export class Directory extends FileSystemObject { + children: FileSystemObject[]; + } + export interface Networked { + host: string; + } + + let file: FileSystemObject = new File("foo/bar.txt", "foo"); + file.isNetworked = false; + file.isFSO = file.isFile; + file.isFile = true; + let x = file.isFile; + if (file.isFile) { + file.content; + ~~~~~~~ +!!! error TS2339: Property 'content' does not exist on type 'FileSystemObject'. + if (file.isNetworked) { + file.host; + ~~~~ +!!! error TS2339: Property 'host' does not exist on type 'FileSystemObject'. + file.content; + ~~~~~~~ +!!! error TS2339: Property 'content' does not exist on type 'FileSystemObject'. + } + } + else if (file.isDirectory) { + file.children; + ~~~~~~~~ +!!! error TS2339: Property 'children' does not exist on type 'FileSystemObject'. + } + else if (file.isNetworked) { + file.host; + ~~~~ +!!! error TS2339: Property 'host' does not exist on type 'FileSystemObject'. + } + + interface GenericLeadGuard extends GenericGuard { + lead(): void; + } + + interface GenericFollowerGuard extends GenericGuard { + follow(): void; + } + + interface GenericGuard { + target: T; + isLeader: this is (GenericLeadGuard); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + isFollower: this is GenericFollowerGuard; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + } + + let guard: GenericGuard; + if (guard.isLeader) { + guard.lead(); + ~~~~ +!!! error TS2339: Property 'lead' does not exist on type 'GenericGuard'. + } + else if (guard.isFollower) { + guard.follow(); + ~~~~~~ +!!! error TS2339: Property 'follow' does not exist on type 'GenericGuard'. + } + + interface SpecificGuard { + isMoreSpecific: this is MoreSpecificGuard; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. + } + + interface MoreSpecificGuard extends SpecificGuard { + do(): void; + } + + let general: SpecificGuard; + if (general.isMoreSpecific) { + general.do(); + ~~ +!!! error TS2339: Property 'do' does not exist on type 'SpecificGuard'. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardOfFormThisMember.symbols b/tests/baselines/reference/typeGuardOfFormThisMember.symbols deleted file mode 100644 index 50e15b68ca4..00000000000 --- a/tests/baselines/reference/typeGuardOfFormThisMember.symbols +++ /dev/null @@ -1,240 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts === -// There's a 'File' class in the stdlib, wrap with a namespace to avoid collision -namespace Test { ->Test : Symbol(Test, Decl(typeGuardOfFormThisMember.ts, 0, 0)) - - export class FileSystemObject { ->FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16)) - - isFSO: this is FileSystemObject; ->isFSO : Symbol(isFSO, Decl(typeGuardOfFormThisMember.ts, 2, 32)) ->FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16)) - - get isFile(): this is File { ->isFile : Symbol(isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3)) ->File : Symbol(File, Decl(typeGuardOfFormThisMember.ts, 15, 2)) - - return this instanceof File; ->this : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16)) ->File : Symbol(File, Decl(typeGuardOfFormThisMember.ts, 15, 2)) - } - set isFile(param) { ->isFile : Symbol(isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3)) ->param : Symbol(param, Decl(typeGuardOfFormThisMember.ts, 7, 13)) - - // noop - } - get isDirectory(): this is Directory { ->isDirectory : Symbol(isDirectory, Decl(typeGuardOfFormThisMember.ts, 9, 3)) ->Directory : Symbol(Directory, Decl(typeGuardOfFormThisMember.ts, 19, 2)) - - return this instanceof Directory; ->this : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16)) ->Directory : Symbol(Directory, Decl(typeGuardOfFormThisMember.ts, 19, 2)) - } - isNetworked: this is (Networked & this); ->isNetworked : Symbol(isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3)) ->Networked : Symbol(Networked, Decl(typeGuardOfFormThisMember.ts, 22, 2)) - - constructor(public path: string) {} ->path : Symbol(path, Decl(typeGuardOfFormThisMember.ts, 14, 14)) - } - - export class File extends FileSystemObject { ->File : Symbol(File, Decl(typeGuardOfFormThisMember.ts, 15, 2)) ->FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16)) - - constructor(path: string, public content: string) { super(path); } ->path : Symbol(path, Decl(typeGuardOfFormThisMember.ts, 18, 14)) ->content : Symbol(content, Decl(typeGuardOfFormThisMember.ts, 18, 27)) ->super : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16)) ->path : Symbol(path, Decl(typeGuardOfFormThisMember.ts, 18, 14)) - } - export class Directory extends FileSystemObject { ->Directory : Symbol(Directory, Decl(typeGuardOfFormThisMember.ts, 19, 2)) ->FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16)) - - children: FileSystemObject[]; ->children : Symbol(children, Decl(typeGuardOfFormThisMember.ts, 20, 50)) ->FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16)) - } - export interface Networked { ->Networked : Symbol(Networked, Decl(typeGuardOfFormThisMember.ts, 22, 2)) - - host: string; ->host : Symbol(host, Decl(typeGuardOfFormThisMember.ts, 23, 29)) - } - - let file: FileSystemObject = new File("foo/bar.txt", "foo"); ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16)) ->File : Symbol(File, Decl(typeGuardOfFormThisMember.ts, 15, 2)) - - file.isNetworked = false; ->file.isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3)) - - file.isFSO = file.isFile; ->file.isFSO : Symbol(FileSystemObject.isFSO, Decl(typeGuardOfFormThisMember.ts, 2, 32)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->isFSO : Symbol(FileSystemObject.isFSO, Decl(typeGuardOfFormThisMember.ts, 2, 32)) ->file.isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3)) - - file.isFile = true; ->file.isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3)) - - let x = file.isFile; ->x : Symbol(x, Decl(typeGuardOfFormThisMember.ts, 31, 4)) ->file.isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3)) - - if (file.isFile) { ->file.isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3)) - - file.content; ->file.content : Symbol(File.content, Decl(typeGuardOfFormThisMember.ts, 18, 27)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->content : Symbol(File.content, Decl(typeGuardOfFormThisMember.ts, 18, 27)) - - if (file.isNetworked) { ->file.isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3)) - - file.host; ->file.host : Symbol(Networked.host, Decl(typeGuardOfFormThisMember.ts, 23, 29)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->host : Symbol(Networked.host, Decl(typeGuardOfFormThisMember.ts, 23, 29)) - - file.content; ->file.content : Symbol(File.content, Decl(typeGuardOfFormThisMember.ts, 18, 27)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->content : Symbol(File.content, Decl(typeGuardOfFormThisMember.ts, 18, 27)) - } - } - else if (file.isDirectory) { ->file.isDirectory : Symbol(FileSystemObject.isDirectory, Decl(typeGuardOfFormThisMember.ts, 9, 3)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->isDirectory : Symbol(FileSystemObject.isDirectory, Decl(typeGuardOfFormThisMember.ts, 9, 3)) - - file.children; ->file.children : Symbol(Directory.children, Decl(typeGuardOfFormThisMember.ts, 20, 50)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->children : Symbol(Directory.children, Decl(typeGuardOfFormThisMember.ts, 20, 50)) - } - else if (file.isNetworked) { ->file.isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3)) - - file.host; ->file.host : Symbol(Networked.host, Decl(typeGuardOfFormThisMember.ts, 23, 29)) ->file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4)) ->host : Symbol(Networked.host, Decl(typeGuardOfFormThisMember.ts, 23, 29)) - } - - interface GenericLeadGuard extends GenericGuard { ->GenericLeadGuard : Symbol(GenericLeadGuard, Decl(typeGuardOfFormThisMember.ts, 44, 2)) ->T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 46, 28)) ->GenericGuard : Symbol(GenericGuard, Decl(typeGuardOfFormThisMember.ts, 52, 2)) ->T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 46, 28)) - - lead(): void; ->lead : Symbol(lead, Decl(typeGuardOfFormThisMember.ts, 46, 56)) - } - - interface GenericFollowerGuard extends GenericGuard { ->GenericFollowerGuard : Symbol(GenericFollowerGuard, Decl(typeGuardOfFormThisMember.ts, 48, 2)) ->T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 50, 32)) ->GenericGuard : Symbol(GenericGuard, Decl(typeGuardOfFormThisMember.ts, 52, 2)) ->T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 50, 32)) - - follow(): void; ->follow : Symbol(follow, Decl(typeGuardOfFormThisMember.ts, 50, 60)) - } - - interface GenericGuard { ->GenericGuard : Symbol(GenericGuard, Decl(typeGuardOfFormThisMember.ts, 52, 2)) ->T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 54, 24)) - - target: T; ->target : Symbol(target, Decl(typeGuardOfFormThisMember.ts, 54, 28)) ->T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 54, 24)) - - isLeader: this is (GenericLeadGuard); ->isLeader : Symbol(isLeader, Decl(typeGuardOfFormThisMember.ts, 55, 12)) ->GenericLeadGuard : Symbol(GenericLeadGuard, Decl(typeGuardOfFormThisMember.ts, 44, 2)) ->T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 54, 24)) - - isFollower: this is GenericFollowerGuard; ->isFollower : Symbol(isFollower, Decl(typeGuardOfFormThisMember.ts, 56, 42)) ->GenericFollowerGuard : Symbol(GenericFollowerGuard, Decl(typeGuardOfFormThisMember.ts, 48, 2)) ->T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 54, 24)) - } - - let guard: GenericGuard; ->guard : Symbol(guard, Decl(typeGuardOfFormThisMember.ts, 60, 4)) ->GenericGuard : Symbol(GenericGuard, Decl(typeGuardOfFormThisMember.ts, 52, 2)) ->File : Symbol(File, Decl(typeGuardOfFormThisMember.ts, 15, 2)) - - if (guard.isLeader) { ->guard.isLeader : Symbol(GenericGuard.isLeader, Decl(typeGuardOfFormThisMember.ts, 55, 12)) ->guard : Symbol(guard, Decl(typeGuardOfFormThisMember.ts, 60, 4)) ->isLeader : Symbol(GenericGuard.isLeader, Decl(typeGuardOfFormThisMember.ts, 55, 12)) - - guard.lead(); ->guard.lead : Symbol(GenericLeadGuard.lead, Decl(typeGuardOfFormThisMember.ts, 46, 56)) ->guard : Symbol(guard, Decl(typeGuardOfFormThisMember.ts, 60, 4)) ->lead : Symbol(GenericLeadGuard.lead, Decl(typeGuardOfFormThisMember.ts, 46, 56)) - } - else if (guard.isFollower) { ->guard.isFollower : Symbol(GenericGuard.isFollower, Decl(typeGuardOfFormThisMember.ts, 56, 42)) ->guard : Symbol(guard, Decl(typeGuardOfFormThisMember.ts, 60, 4)) ->isFollower : Symbol(GenericGuard.isFollower, Decl(typeGuardOfFormThisMember.ts, 56, 42)) - - guard.follow(); ->guard.follow : Symbol(GenericFollowerGuard.follow, Decl(typeGuardOfFormThisMember.ts, 50, 60)) ->guard : Symbol(guard, Decl(typeGuardOfFormThisMember.ts, 60, 4)) ->follow : Symbol(GenericFollowerGuard.follow, Decl(typeGuardOfFormThisMember.ts, 50, 60)) - } - - interface SpecificGuard { ->SpecificGuard : Symbol(SpecificGuard, Decl(typeGuardOfFormThisMember.ts, 66, 2)) - - isMoreSpecific: this is MoreSpecificGuard; ->isMoreSpecific : Symbol(isMoreSpecific, Decl(typeGuardOfFormThisMember.ts, 68, 26)) ->MoreSpecificGuard : Symbol(MoreSpecificGuard, Decl(typeGuardOfFormThisMember.ts, 70, 2)) - } - - interface MoreSpecificGuard extends SpecificGuard { ->MoreSpecificGuard : Symbol(MoreSpecificGuard, Decl(typeGuardOfFormThisMember.ts, 70, 2)) ->SpecificGuard : Symbol(SpecificGuard, Decl(typeGuardOfFormThisMember.ts, 66, 2)) - - do(): void; ->do : Symbol(do, Decl(typeGuardOfFormThisMember.ts, 72, 52)) - } - - let general: SpecificGuard; ->general : Symbol(general, Decl(typeGuardOfFormThisMember.ts, 76, 4)) ->SpecificGuard : Symbol(SpecificGuard, Decl(typeGuardOfFormThisMember.ts, 66, 2)) - - if (general.isMoreSpecific) { ->general.isMoreSpecific : Symbol(SpecificGuard.isMoreSpecific, Decl(typeGuardOfFormThisMember.ts, 68, 26)) ->general : Symbol(general, Decl(typeGuardOfFormThisMember.ts, 76, 4)) ->isMoreSpecific : Symbol(SpecificGuard.isMoreSpecific, Decl(typeGuardOfFormThisMember.ts, 68, 26)) - - general.do(); ->general.do : Symbol(MoreSpecificGuard.do, Decl(typeGuardOfFormThisMember.ts, 72, 52)) ->general : Symbol(general, Decl(typeGuardOfFormThisMember.ts, 76, 4)) ->do : Symbol(MoreSpecificGuard.do, Decl(typeGuardOfFormThisMember.ts, 72, 52)) - } -} - diff --git a/tests/baselines/reference/typeGuardOfFormThisMember.types b/tests/baselines/reference/typeGuardOfFormThisMember.types deleted file mode 100644 index 68343947fb4..00000000000 --- a/tests/baselines/reference/typeGuardOfFormThisMember.types +++ /dev/null @@ -1,254 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts === -// There's a 'File' class in the stdlib, wrap with a namespace to avoid collision -namespace Test { ->Test : typeof Test - - export class FileSystemObject { ->FileSystemObject : FileSystemObject - - isFSO: this is FileSystemObject; ->isFSO : this is FileSystemObject ->FileSystemObject : FileSystemObject - - get isFile(): this is File { ->isFile : this is File ->File : File - - return this instanceof File; ->this instanceof File : boolean ->this : this ->File : typeof File - } - set isFile(param) { ->isFile : this is File ->param : boolean - - // noop - } - get isDirectory(): this is Directory { ->isDirectory : this is Directory ->Directory : Directory - - return this instanceof Directory; ->this instanceof Directory : boolean ->this : this ->Directory : typeof Directory - } - isNetworked: this is (Networked & this); ->isNetworked : this is Networked & this ->Networked : Networked - - constructor(public path: string) {} ->path : string - } - - export class File extends FileSystemObject { ->File : File ->FileSystemObject : FileSystemObject - - constructor(path: string, public content: string) { super(path); } ->path : string ->content : string ->super(path) : void ->super : typeof FileSystemObject ->path : string - } - export class Directory extends FileSystemObject { ->Directory : Directory ->FileSystemObject : FileSystemObject - - children: FileSystemObject[]; ->children : FileSystemObject[] ->FileSystemObject : FileSystemObject - } - export interface Networked { ->Networked : Networked - - host: string; ->host : string - } - - let file: FileSystemObject = new File("foo/bar.txt", "foo"); ->file : FileSystemObject ->FileSystemObject : FileSystemObject ->new File("foo/bar.txt", "foo") : File ->File : typeof File ->"foo/bar.txt" : string ->"foo" : string - - file.isNetworked = false; ->file.isNetworked = false : boolean ->file.isNetworked : this is Networked & FileSystemObject ->file : FileSystemObject ->isNetworked : this is Networked & FileSystemObject ->false : boolean - - file.isFSO = file.isFile; ->file.isFSO = file.isFile : this is File ->file.isFSO : this is FileSystemObject ->file : FileSystemObject ->isFSO : this is FileSystemObject ->file.isFile : this is File ->file : FileSystemObject ->isFile : this is File - - file.isFile = true; ->file.isFile = true : boolean ->file.isFile : this is File ->file : FileSystemObject ->isFile : this is File ->true : boolean - - let x = file.isFile; ->x : boolean ->file.isFile : this is File ->file : FileSystemObject ->isFile : this is File - - if (file.isFile) { ->file.isFile : this is File ->file : FileSystemObject ->isFile : this is File - - file.content; ->file.content : string ->file : File ->content : string - - if (file.isNetworked) { ->file.isNetworked : this is Networked & File ->file : File ->isNetworked : this is Networked & File - - file.host; ->file.host : string ->file : Networked & File ->host : string - - file.content; ->file.content : string ->file : Networked & File ->content : string - } - } - else if (file.isDirectory) { ->file.isDirectory : this is Directory ->file : FileSystemObject ->isDirectory : this is Directory - - file.children; ->file.children : FileSystemObject[] ->file : Directory ->children : FileSystemObject[] - } - else if (file.isNetworked) { ->file.isNetworked : this is Networked & FileSystemObject ->file : FileSystemObject ->isNetworked : this is Networked & FileSystemObject - - file.host; ->file.host : string ->file : Networked & FileSystemObject ->host : string - } - - interface GenericLeadGuard extends GenericGuard { ->GenericLeadGuard : GenericLeadGuard ->T : T ->GenericGuard : GenericGuard ->T : T - - lead(): void; ->lead : () => void - } - - interface GenericFollowerGuard extends GenericGuard { ->GenericFollowerGuard : GenericFollowerGuard ->T : T ->GenericGuard : GenericGuard ->T : T - - follow(): void; ->follow : () => void - } - - interface GenericGuard { ->GenericGuard : GenericGuard ->T : T - - target: T; ->target : T ->T : T - - isLeader: this is (GenericLeadGuard); ->isLeader : this is GenericLeadGuard ->GenericLeadGuard : GenericLeadGuard ->T : T - - isFollower: this is GenericFollowerGuard; ->isFollower : this is GenericFollowerGuard ->GenericFollowerGuard : GenericFollowerGuard ->T : T - } - - let guard: GenericGuard; ->guard : GenericGuard ->GenericGuard : GenericGuard ->File : File - - if (guard.isLeader) { ->guard.isLeader : this is GenericLeadGuard ->guard : GenericGuard ->isLeader : this is GenericLeadGuard - - guard.lead(); ->guard.lead() : void ->guard.lead : () => void ->guard : GenericLeadGuard ->lead : () => void - } - else if (guard.isFollower) { ->guard.isFollower : this is GenericFollowerGuard ->guard : GenericGuard ->isFollower : this is GenericFollowerGuard - - guard.follow(); ->guard.follow() : void ->guard.follow : () => void ->guard : GenericFollowerGuard ->follow : () => void - } - - interface SpecificGuard { ->SpecificGuard : SpecificGuard - - isMoreSpecific: this is MoreSpecificGuard; ->isMoreSpecific : this is MoreSpecificGuard ->MoreSpecificGuard : MoreSpecificGuard - } - - interface MoreSpecificGuard extends SpecificGuard { ->MoreSpecificGuard : MoreSpecificGuard ->SpecificGuard : SpecificGuard - - do(): void; ->do : () => void - } - - let general: SpecificGuard; ->general : SpecificGuard ->SpecificGuard : SpecificGuard - - if (general.isMoreSpecific) { ->general.isMoreSpecific : this is MoreSpecificGuard ->general : SpecificGuard ->isMoreSpecific : this is MoreSpecificGuard - - general.do(); ->general.do() : void ->general.do : () => void ->general : MoreSpecificGuard ->do : () => void - } -} - diff --git a/tests/baselines/reference/typeGuardOfFormThisMemberErrors.errors.txt b/tests/baselines/reference/typeGuardOfFormThisMemberErrors.errors.txt index 754cbffe6e6..88e9d41cc7b 100644 --- a/tests/baselines/reference/typeGuardOfFormThisMemberErrors.errors.txt +++ b/tests/baselines/reference/typeGuardOfFormThisMemberErrors.errors.txt @@ -1,27 +1,32 @@ -tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(29,2): error TS1226: Type predicate 'this is File' is not assignable to 'this is Networked & FileSystemObject'. - Type 'File' is not assignable to type 'Networked & FileSystemObject'. - Type 'File' is not assignable to type 'Networked'. - Property 'host' is missing in type 'File'. -tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(31,2): error TS1226: Type predicate 'this is FileSystemObject' is not assignable to 'this is File'. - Type 'FileSystemObject' is not assignable to type 'File'. - Property 'content' is missing in type 'FileSystemObject'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(4,10): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(5,17): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(11,22): error TS1228: A type predicate is only allowed in return type position for functions and methods. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(14,16): error TS1228: A type predicate is only allowed in return type position for functions and methods. -==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts (2 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts (4 errors) ==== // There's a 'File' class in the stdlib, wrap with a namespace to avoid collision namespace Test { export class FileSystemObject { isFSO: this is FileSystemObject; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. get isFile(): this is File { + ~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return this instanceof File; } set isFile(param) { // noop } get isDirectory(): this is Directory { + ~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return this instanceof Directory; } isNetworked: this is (Networked & this); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. constructor(public path: string) {} } @@ -37,15 +42,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.t let file: FileSystemObject = new File("foo/bar.txt", "foo"); file.isNetworked = file.isFile; - ~~~~~~~~~~~~~~~~ -!!! error TS1226: Type predicate 'this is File' is not assignable to 'this is Networked & FileSystemObject'. -!!! error TS1226: Type 'File' is not assignable to type 'Networked & FileSystemObject'. -!!! error TS1226: Type 'File' is not assignable to type 'Networked'. -!!! error TS1226: Property 'host' is missing in type 'File'. file.isFSO = file.isNetworked; file.isFile = file.isFSO; - ~~~~~~~~~~~ -!!! error TS1226: Type predicate 'this is FileSystemObject' is not assignable to 'this is File'. -!!! error TS1226: Type 'FileSystemObject' is not assignable to type 'File'. -!!! error TS1226: Property 'content' is missing in type 'FileSystemObject'. } \ No newline at end of file diff --git a/tests/baselines/reference/typePredicateOnVariableDeclaration01.errors.txt b/tests/baselines/reference/typePredicateOnVariableDeclaration01.errors.txt new file mode 100644 index 00000000000..b713dd12ae7 --- /dev/null +++ b/tests/baselines/reference/typePredicateOnVariableDeclaration01.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration01.ts(2,8): error TS1228: A type predicate is only allowed in return type position for functions and methods. + + +==== tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration01.ts (1 errors) ==== + + var x: this is string; + ~~~~~~~~~~~~~~ +!!! error TS1228: A type predicate is only allowed in return type position for functions and methods. \ No newline at end of file diff --git a/tests/baselines/reference/typePredicateOnVariableDeclaration01.js b/tests/baselines/reference/typePredicateOnVariableDeclaration01.js new file mode 100644 index 00000000000..5831142cf5c --- /dev/null +++ b/tests/baselines/reference/typePredicateOnVariableDeclaration01.js @@ -0,0 +1,10 @@ +//// [typePredicateOnVariableDeclaration01.ts] + +var x: this is string; + +//// [typePredicateOnVariableDeclaration01.js] +var x; + + +//// [typePredicateOnVariableDeclaration01.d.ts] +declare var x: this is string; diff --git a/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt b/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt new file mode 100644 index 00000000000..af967b22b79 --- /dev/null +++ b/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(2,8): error TS2304: Cannot find name 'z'. +tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(2,8): error TS4025: Exported variable 'y' has or is using private name 'z'. +tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(2,10): error TS1005: '=' expected. +tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(2,10): error TS2304: Cannot find name 'is'. +tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(2,13): error TS1005: ',' expected. + + +==== tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts (5 errors) ==== + + var y: z is number; + ~ +!!! error TS2304: Cannot find name 'z'. + ~ +!!! error TS4025: Exported variable 'y' has or is using private name 'z'. + ~~ +!!! error TS1005: '=' expected. + ~~ +!!! error TS2304: Cannot find name 'is'. + ~~~~~~ +!!! error TS1005: ',' expected. \ No newline at end of file diff --git a/tests/baselines/reference/typePredicateOnVariableDeclaration02.js b/tests/baselines/reference/typePredicateOnVariableDeclaration02.js new file mode 100644 index 00000000000..b28a89116ba --- /dev/null +++ b/tests/baselines/reference/typePredicateOnVariableDeclaration02.js @@ -0,0 +1,6 @@ +//// [typePredicateOnVariableDeclaration02.ts] + +var y: z is number; + +//// [typePredicateOnVariableDeclaration02.js] +var y = is, number; diff --git a/tests/baselines/reference/unionAndIntersectionInference1.types b/tests/baselines/reference/unionAndIntersectionInference1.types index 073a677b659..5d23688f0b7 100644 --- a/tests/baselines/reference/unionAndIntersectionInference1.types +++ b/tests/baselines/reference/unionAndIntersectionInference1.types @@ -110,7 +110,7 @@ function foo1(value: void|a): void { >a : a if (isVoid(value)) { ->isVoid(value) : value is void +>isVoid(value) : boolean >isVoid : (value: void | a) => value is void >value : void | a @@ -130,7 +130,7 @@ function baz1(value: void|a): void { >a : a if (isNonVoid(value)) { ->isNonVoid(value) : value is a +>isNonVoid(value) : boolean >isNonVoid : (value: void | a) => value is a >value : void | a