/
readonlyTupleAndArrayElaboration.errors.txt
58 lines (48 loc) · 3.41 KB
/
readonlyTupleAndArrayElaboration.errors.txt
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
tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(10,20): error TS2345: Argument of type 'readonly [3, 4]' is not assignable to parameter of type '[number, number]'.
A 'readonly' tuple cannot be assigned to a mutable array-like type.
tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(13,8): error TS2345: Argument of type 'readonly [3, 4]' is not assignable to parameter of type 'number[]'.
A 'readonly' tuple cannot be assigned to a mutable array-like type.
tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(16,9): error TS2345: Argument of type 'readonly [3, 4]' is not assignable to parameter of type 'number[]'.
A 'readonly' tuple cannot be assigned to a mutable array-like type.
tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(22,9): error TS2345: Argument of type 'readonly number[]' is not assignable to parameter of type 'number[]'.
A 'ReadonlyArray' cannot be assigned to an 'Array' because 'Array's can be mutated.
tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(23,9): error TS2345: Argument of type 'readonly number[]' is not assignable to parameter of type 'number[]'.
A 'ReadonlyArray' cannot be assigned to an 'Array' because 'Array's can be mutated.
tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(24,9): error TS2345: Argument of type 'readonly number[]' is not assignable to parameter of type 'number[]'.
A 'ReadonlyArray' cannot be assigned to an 'Array' because 'Array's can be mutated.
==== tests/cases/compiler/readonlyTupleAndArrayElaboration.ts (6 errors) ====
// @strict
// #Repro from #30839
let point = [3, 4] as const;
function distanceFromOrigin([x, y]: [number, number]) {
return Math.sqrt(x ** 2 + y ** 2);
}
distanceFromOrigin(point);
~~~~~
!!! error TS2345: Argument of type 'readonly [3, 4]' is not assignable to parameter of type '[number, number]'.
!!! error TS2345: A 'readonly' tuple cannot be assigned to a mutable array-like type.
declare function arryFn(x: number[]): void;
arryFn(point);
~~~~~
!!! error TS2345: Argument of type 'readonly [3, 4]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: A 'readonly' tuple cannot be assigned to a mutable array-like type.
declare function arryFn2(x: Array<number>): void;
arryFn2(point);
~~~~~
!!! error TS2345: Argument of type 'readonly [3, 4]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: A 'readonly' tuple cannot be assigned to a mutable array-like type.
declare const a: readonly number[];
declare const b: Readonly<number[]>;
declare const c: ReadonlyArray<number>;
arryFn2(a);
~
!!! error TS2345: Argument of type 'readonly number[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: A 'ReadonlyArray' cannot be assigned to an 'Array' because 'Array's can be mutated.
arryFn2(b);
~
!!! error TS2345: Argument of type 'readonly number[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: A 'ReadonlyArray' cannot be assigned to an 'Array' because 'Array's can be mutated.
arryFn2(c);
~
!!! error TS2345: Argument of type 'readonly number[]' is not assignable to parameter of type 'number[]'.
!!! error TS2345: A 'ReadonlyArray' cannot be assigned to an 'Array' because 'Array's can be mutated.