1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
tests/cases/conformance/types/rest/objectRest.ts(43,8): error TS2537: Type '{ a: number; b: string; }' has no matching index signature for type 'string'.
tests/cases/conformance/types/rest/objectRest.ts(43,35): error TS2537: Type '{ a: number; b: string; }' has no matching index signature for type 'string'.
tests/cases/conformance/types/rest/objectRest.ts(43,57): error TS2403: Subsequent variable declarations must have the same type. Variable 'o' must be of type '{ a: number; b: string; }', but here has type '{}'.
tests/cases/conformance/types/rest/objectRest.ts(44,5): error TS2537: Type '{ a: number; b: string; }' has no matching index signature for type 'string'.
tests/cases/conformance/types/rest/objectRest.ts(44,32): error TS2537: Type '{ a: number; b: string; }' has no matching index signature for type 'string'.
tests/cases/conformance/types/rest/objectRest.ts(44,53): error TS2739: Type '{}' is missing the following properties from type '{ a: number; b: string; }': a, b
==== tests/cases/conformance/types/rest/objectRest.ts (6 errors) ====
var o = { a: 1, b: 'no' }
var { ...clone } = o;
var { a, ...justB } = o;
var { a, b: renamed, ...empty } = o;
var { ['b']: renamed, ...justA } = o;
var { 'b': renamed, ...justA } = o;
var { b: { '0': n, '1': oooo }, ...justA } = o;
let o2 = { c: 'terrible idea?', d: 'yes' };
var { d: renamed, ...d } = o2;
let nestedrest: { x: number, n1: { y: number, n2: { z: number, n3: { n4: number } } }, rest: number, restrest: number };
var { x, n1: { y, n2: { z, n3: { ...nr } } }, ...restrest } = nestedrest;
let complex: { x: { ka, ki }, y: number };
var { x: { ka, ...nested }, y: other, ...rest } = complex;
({x: { ka, ...nested }, y: other, ...rest} = complex);
var { x, ...fresh } = { x: 1, y: 2 };
({ x, ...fresh } = { x: 1, y: 2 });
class Removable {
private x: number;
protected y: number;
set z(value: number) { }
get both(): number { return 12 }
set both(value: number) { }
m() { }
removed: string;
remainder: string;
}
interface I {
m(): void;
removed: string;
remainder: string;
}
var removable = new Removable();
var { removed, ...removableRest } = removable;
var i: I = removable;
var { removed, ...removableRest2 } = i;
let computed = 'b';
let computed2 = 'a';
var { [computed]: stillNotGreat, [computed2]: soSo, ...o } = o;
~~~~~~~~
!!! error TS2537: Type '{ a: number; b: string; }' has no matching index signature for type 'string'.
~~~~~~~~~
!!! error TS2537: Type '{ a: number; b: string; }' has no matching index signature for type 'string'.
~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'o' must be of type '{ a: number; b: string; }', but here has type '{}'.
!!! related TS6203 tests/cases/conformance/types/rest/objectRest.ts:1:5: 'o' was also declared here.
({ [computed]: stillNotGreat, [computed2]: soSo, ...o } = o);
~~~~~~~~
!!! error TS2537: Type '{ a: number; b: string; }' has no matching index signature for type 'string'.
~~~~~~~~~
!!! error TS2537: Type '{ a: number; b: string; }' has no matching index signature for type 'string'.
~
!!! error TS2739: Type '{}' is missing the following properties from type '{ a: number; b: string; }': a, b
var noContextualType = ({ aNumber = 12, ...notEmptyObject }) => aNumber + notEmptyObject.anythingGoes;
|