|
| 1 | +tests/cases/compiler/restInvalidArgumentType.ts(31,13): error TS2700: Rest types may only be created from object types. |
| 2 | +tests/cases/compiler/restInvalidArgumentType.ts(33,13): error TS2700: Rest types may only be created from object types. |
| 3 | +tests/cases/compiler/restInvalidArgumentType.ts(35,13): error TS2700: Rest types may only be created from object types. |
| 4 | +tests/cases/compiler/restInvalidArgumentType.ts(36,13): error TS2700: Rest types may only be created from object types. |
| 5 | +tests/cases/compiler/restInvalidArgumentType.ts(38,13): error TS2700: Rest types may only be created from object types. |
| 6 | +tests/cases/compiler/restInvalidArgumentType.ts(41,13): error TS2700: Rest types may only be created from object types. |
| 7 | +tests/cases/compiler/restInvalidArgumentType.ts(42,13): error TS2700: Rest types may only be created from object types. |
| 8 | +tests/cases/compiler/restInvalidArgumentType.ts(44,13): error TS2700: Rest types may only be created from object types. |
| 9 | +tests/cases/compiler/restInvalidArgumentType.ts(45,13): error TS2700: Rest types may only be created from object types. |
| 10 | +tests/cases/compiler/restInvalidArgumentType.ts(47,13): error TS2700: Rest types may only be created from object types. |
| 11 | +tests/cases/compiler/restInvalidArgumentType.ts(48,13): error TS2700: Rest types may only be created from object types. |
| 12 | +tests/cases/compiler/restInvalidArgumentType.ts(50,13): error TS2700: Rest types may only be created from object types. |
| 13 | +tests/cases/compiler/restInvalidArgumentType.ts(51,13): error TS2700: Rest types may only be created from object types. |
| 14 | +tests/cases/compiler/restInvalidArgumentType.ts(55,13): error TS2700: Rest types may only be created from object types. |
| 15 | +tests/cases/compiler/restInvalidArgumentType.ts(56,13): error TS2700: Rest types may only be created from object types. |
| 16 | +tests/cases/compiler/restInvalidArgumentType.ts(58,13): error TS2700: Rest types may only be created from object types. |
| 17 | + |
| 18 | + |
| 19 | +==== tests/cases/compiler/restInvalidArgumentType.ts (16 errors) ==== |
| 20 | + enum E { v1, v2 }; |
| 21 | + |
| 22 | + function f<T extends { b: string }>(p1: T, p2: T[]) { |
| 23 | + var t: T; |
| 24 | + |
| 25 | + var i: T["b"]; |
| 26 | + var k: keyof T; |
| 27 | + |
| 28 | + var mapped_generic: {[P in keyof T]: T[P]}; |
| 29 | + var mapped: {[P in "b"]: T[P]}; |
| 30 | + |
| 31 | + var union_generic: T | { a: number }; |
| 32 | + var union_primitive: { a: number } | number; |
| 33 | + |
| 34 | + var intersection_generic: T & { a: number }; |
| 35 | + var intersection_premitive: { a: number } | string; |
| 36 | + |
| 37 | + var num: number; |
| 38 | + var str: number; |
| 39 | + |
| 40 | + var u: undefined; |
| 41 | + var n: null; |
| 42 | + |
| 43 | + var a: any; |
| 44 | + |
| 45 | + var literal_string: "string"; |
| 46 | + var literal_number: 42; |
| 47 | + |
| 48 | + var e: E; |
| 49 | + |
| 50 | + var {...r1} = p1; // Error, generic type paramterre |
| 51 | + ~~ |
| 52 | +!!! error TS2700: Rest types may only be created from object types. |
| 53 | + var {...r2} = p2; // OK |
| 54 | + var {...r3} = t; // Error, generic type paramter |
| 55 | + ~~ |
| 56 | +!!! error TS2700: Rest types may only be created from object types. |
| 57 | + |
| 58 | + var {...r4} = i; // Error, index access |
| 59 | + ~~ |
| 60 | +!!! error TS2700: Rest types may only be created from object types. |
| 61 | + var {...r5} = k; // Error, index |
| 62 | + ~~ |
| 63 | +!!! error TS2700: Rest types may only be created from object types. |
| 64 | + |
| 65 | + var {...r6} = mapped_generic; // Error, generic mapped object type |
| 66 | + ~~ |
| 67 | +!!! error TS2700: Rest types may only be created from object types. |
| 68 | + var {...r7} = mapped; // OK, non-generic mapped type |
| 69 | + |
| 70 | + var {...r8} = union_generic; // Error, union with generic type parameter |
| 71 | + ~~ |
| 72 | +!!! error TS2700: Rest types may only be created from object types. |
| 73 | + var {...r9} = union_primitive; // Error, union with generic type parameter |
| 74 | + ~~ |
| 75 | +!!! error TS2700: Rest types may only be created from object types. |
| 76 | + |
| 77 | + var {...r10} = intersection_generic; // Error, intersection with generic type parameter |
| 78 | + ~~~ |
| 79 | +!!! error TS2700: Rest types may only be created from object types. |
| 80 | + var {...r11} = intersection_premitive; // Error, intersection with generic type parameter |
| 81 | + ~~~ |
| 82 | +!!! error TS2700: Rest types may only be created from object types. |
| 83 | + |
| 84 | + var {...r12} = num; // Error |
| 85 | + ~~~ |
| 86 | +!!! error TS2700: Rest types may only be created from object types. |
| 87 | + var {...r13} = str; // Error |
| 88 | + ~~~ |
| 89 | +!!! error TS2700: Rest types may only be created from object types. |
| 90 | + |
| 91 | + var {...r14} = u; // Error |
| 92 | + ~~~ |
| 93 | +!!! error TS2700: Rest types may only be created from object types. |
| 94 | + var {...r15} = n; // Error |
| 95 | + ~~~ |
| 96 | +!!! error TS2700: Rest types may only be created from object types. |
| 97 | + |
| 98 | + var {...r16} = a; // OK |
| 99 | + |
| 100 | + var {...r17} = literal_string; // Error |
| 101 | + ~~~ |
| 102 | +!!! error TS2700: Rest types may only be created from object types. |
| 103 | + var {...r18} = literal_number; // Error |
| 104 | + ~~~ |
| 105 | +!!! error TS2700: Rest types may only be created from object types. |
| 106 | + |
| 107 | + var {...r19} = e; // Error, enum |
| 108 | + ~~~ |
| 109 | +!!! error TS2700: Rest types may only be created from object types. |
| 110 | + } |
0 commit comments