Skip to content

Commit

Permalink
Test all different possibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Dec 9, 2021
1 parent d45768e commit f2bb9b7
Show file tree
Hide file tree
Showing 5 changed files with 446 additions and 190 deletions.
157 changes: 105 additions & 52 deletions tests/baselines/reference/destructuringUnspreadableIntoRest.errors.txt
Original file line number Diff line number Diff line change
@@ -1,60 +1,91 @@
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(4,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(16,15): error TS2339: Property 'getter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(17,15): error TS2339: Property 'getter' does not exist on type '{ normal: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(18,15): error TS2339: Property 'getter' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(19,15): error TS2339: Property 'getter' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(21,15): error TS2339: Property 'setter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(22,15): error TS2339: Property 'setter' does not exist on type '{ normal: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(23,15): error TS2339: Property 'setter' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(24,15): error TS2339: Property 'setter' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(26,15): error TS2339: Property 'method' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(27,15): error TS2339: Property 'method' does not exist on type '{ normal: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(28,15): error TS2339: Property 'method' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(29,15): error TS2339: Property 'method' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(39,11): error TS2339: Property 'getter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(40,11): error TS2339: Property 'getter' does not exist on type '{ normal: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(41,11): error TS2339: Property 'getter' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(42,11): error TS2339: Property 'getter' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(44,11): error TS2339: Property 'setter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(45,11): error TS2339: Property 'setter' does not exist on type '{ normal: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(46,11): error TS2339: Property 'setter' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(47,11): error TS2339: Property 'setter' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(49,11): error TS2339: Property 'method' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(50,11): error TS2339: Property 'method' does not exist on type '{ normal: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(51,11): error TS2339: Property 'method' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(52,11): error TS2339: Property 'method' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(21,15): error TS2339: Property 'publicProp' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(22,15): error TS2339: Property 'publicProp' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(24,15): error TS2339: Property 'privateProp' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(25,15): error TS2339: Property 'privateProp' does not exist on type '{ publicProp: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(26,15): error TS2339: Property 'privateProp' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(27,15): error TS2339: Property 'privateProp' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(29,15): error TS2339: Property 'getter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(30,15): error TS2339: Property 'getter' does not exist on type '{ publicProp: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(31,15): error TS2339: Property 'getter' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(32,15): error TS2339: Property 'getter' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(34,15): error TS2339: Property 'setter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(35,15): error TS2339: Property 'setter' does not exist on type '{ publicProp: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(36,15): error TS2339: Property 'setter' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(37,15): error TS2339: Property 'setter' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(39,15): error TS2339: Property 'method' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(40,15): error TS2339: Property 'method' does not exist on type '{ publicProp: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(41,15): error TS2339: Property 'method' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(42,15): error TS2339: Property 'method' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(54,11): error TS2339: Property 'publicProp' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(55,11): error TS2339: Property 'publicProp' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(57,11): error TS2339: Property 'privateProp' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(58,11): error TS2339: Property 'privateProp' does not exist on type '{ publicProp: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(59,11): error TS2339: Property 'privateProp' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(60,11): error TS2339: Property 'privateProp' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(62,11): error TS2339: Property 'getter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(63,11): error TS2339: Property 'getter' does not exist on type '{ publicProp: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(64,11): error TS2339: Property 'getter' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(65,11): error TS2339: Property 'getter' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(67,11): error TS2339: Property 'setter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(68,11): error TS2339: Property 'setter' does not exist on type '{ publicProp: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(69,11): error TS2339: Property 'setter' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(70,11): error TS2339: Property 'setter' does not exist on type '{}'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(72,11): error TS2339: Property 'method' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(73,11): error TS2339: Property 'method' does not exist on type '{ publicProp: string; }'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(74,11): error TS2339: Property 'method' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
tests/cases/compiler/destructuringUnspreadableIntoRest.ts(75,11): error TS2339: Property 'method' does not exist on type '{}'.


==== tests/cases/compiler/destructuringUnspreadableIntoRest.ts (26 errors) ====
==== tests/cases/compiler/destructuringUnspreadableIntoRest.ts (36 errors) ====
class A {
constructor(public normal: string) {}
constructor(
public publicProp: string,
private privateProp: string,
) {}

get getter(): number {
~~~~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return 1;
}

set setter(_v: number) {}
~~~~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.

method() {
const { ...rest1 } = this;
const { ...rest2 } = this as A;
const { normal: _1, ...rest3 } = this;
const { normal: _2, ...rest4 } = this as A;
const { ...rest1 } = this;
const { ...rest2 } = this as A;
const { publicProp: _1, ...rest3 } = this;
const { publicProp: _2, ...rest4 } = this as A;

rest1.publicProp;
rest2.publicProp;
rest3.publicProp;
~~~~~~~~~~
!!! error TS2339: Property 'publicProp' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
rest4.publicProp;
~~~~~~~~~~
!!! error TS2339: Property 'publicProp' does not exist on type '{}'.

rest1.privateProp;
~~~~~~~~~~~
!!! error TS2339: Property 'privateProp' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
rest2.privateProp;
~~~~~~~~~~~
!!! error TS2339: Property 'privateProp' does not exist on type '{ publicProp: string; }'.
rest3.privateProp;
~~~~~~~~~~~
!!! error TS2339: Property 'privateProp' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
rest4.privateProp;
~~~~~~~~~~~
!!! error TS2339: Property 'privateProp' does not exist on type '{}'.

rest1.getter;
~~~~~~
!!! error TS2339: Property 'getter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
rest2.getter;
~~~~~~
!!! error TS2339: Property 'getter' does not exist on type '{ normal: string; }'.
!!! error TS2339: Property 'getter' does not exist on type '{ publicProp: string; }'.
rest3.getter;
~~~~~~
!!! error TS2339: Property 'getter' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
!!! error TS2339: Property 'getter' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
rest4.getter;
~~~~~~
!!! error TS2339: Property 'getter' does not exist on type '{}'.
Expand All @@ -64,10 +95,10 @@ tests/cases/compiler/destructuringUnspreadableIntoRest.ts(52,11): error TS2339:
!!! error TS2339: Property 'setter' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
rest2.setter;
~~~~~~
!!! error TS2339: Property 'setter' does not exist on type '{ normal: string; }'.
!!! error TS2339: Property 'setter' does not exist on type '{ publicProp: string; }'.
rest3.setter;
~~~~~~
!!! error TS2339: Property 'setter' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
!!! error TS2339: Property 'setter' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
rest4.setter;
~~~~~~
!!! error TS2339: Property 'setter' does not exist on type '{}'.
Expand All @@ -77,31 +108,53 @@ tests/cases/compiler/destructuringUnspreadableIntoRest.ts(52,11): error TS2339:
!!! error TS2339: Property 'method' does not exist on type 'Omit<this, "getter" | "setter" | "method">'.
rest2.method;
~~~~~~
!!! error TS2339: Property 'method' does not exist on type '{ normal: string; }'.
!!! error TS2339: Property 'method' does not exist on type '{ publicProp: string; }'.
rest3.method;
~~~~~~
!!! error TS2339: Property 'method' does not exist on type 'Omit<this, "normal" | "getter" | "setter" | "method">'.
!!! error TS2339: Property 'method' does not exist on type 'Omit<this, "publicProp" | "getter" | "setter" | "method">'.
rest4.method;
~~~~~~
!!! error TS2339: Property 'method' does not exist on type '{}'.
}
}

function destructure<T extends A>(x: T) {
const { ...rest1 } = x;
const { ...rest2 } = x as A;
const { normal: _1, ...rest3 } = x;
const { normal: _2, ...rest4 } = x as A;
const { ...rest1 } = x;
const { ...rest2 } = x as A;
const { publicProp: _1, ...rest3 } = x;
const { publicProp: _2, ...rest4 } = x as A;

rest1.publicProp;
rest2.publicProp;
rest3.publicProp;
~~~~~~~~~~
!!! error TS2339: Property 'publicProp' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
rest4.publicProp;
~~~~~~~~~~
!!! error TS2339: Property 'publicProp' does not exist on type '{}'.

rest1.privateProp;
~~~~~~~~~~~
!!! error TS2339: Property 'privateProp' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
rest2.privateProp;
~~~~~~~~~~~
!!! error TS2339: Property 'privateProp' does not exist on type '{ publicProp: string; }'.
rest3.privateProp;
~~~~~~~~~~~
!!! error TS2339: Property 'privateProp' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
rest4.privateProp;
~~~~~~~~~~~
!!! error TS2339: Property 'privateProp' does not exist on type '{}'.

rest1.getter;
~~~~~~
!!! error TS2339: Property 'getter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
rest2.getter;
~~~~~~
!!! error TS2339: Property 'getter' does not exist on type '{ normal: string; }'.
!!! error TS2339: Property 'getter' does not exist on type '{ publicProp: string; }'.
rest3.getter;
~~~~~~
!!! error TS2339: Property 'getter' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
!!! error TS2339: Property 'getter' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
rest4.getter;
~~~~~~
!!! error TS2339: Property 'getter' does not exist on type '{}'.
Expand All @@ -111,10 +164,10 @@ tests/cases/compiler/destructuringUnspreadableIntoRest.ts(52,11): error TS2339:
!!! error TS2339: Property 'setter' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
rest2.setter;
~~~~~~
!!! error TS2339: Property 'setter' does not exist on type '{ normal: string; }'.
!!! error TS2339: Property 'setter' does not exist on type '{ publicProp: string; }'.
rest3.setter;
~~~~~~
!!! error TS2339: Property 'setter' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
!!! error TS2339: Property 'setter' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
rest4.setter;
~~~~~~
!!! error TS2339: Property 'setter' does not exist on type '{}'.
Expand All @@ -124,10 +177,10 @@ tests/cases/compiler/destructuringUnspreadableIntoRest.ts(52,11): error TS2339:
!!! error TS2339: Property 'method' does not exist on type 'Omit<T, "getter" | "setter" | "method">'.
rest2.method;
~~~~~~
!!! error TS2339: Property 'method' does not exist on type '{ normal: string; }'.
!!! error TS2339: Property 'method' does not exist on type '{ publicProp: string; }'.
rest3.method;
~~~~~~
!!! error TS2339: Property 'method' does not exist on type 'Omit<T, "normal" | "getter" | "setter" | "method">'.
!!! error TS2339: Property 'method' does not exist on type 'Omit<T, "publicProp" | "getter" | "setter" | "method">'.
rest4.method;
~~~~~~
!!! error TS2339: Property 'method' does not exist on type '{}'.
Expand Down
Loading

0 comments on commit f2bb9b7

Please sign in to comment.