File: objectFreeze.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (22 lines) | stat: -rw-r--r-- 892 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
tests/cases/compiler/objectFreeze.ts(9,1): error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
tests/cases/compiler/objectFreeze.ts(12,3): error TS2540: Cannot assign to 'b' because it is a constant or a read-only property.


==== tests/cases/compiler/objectFreeze.ts (2 errors) ====
    const f = Object.freeze(function foo(a: number, b: string) { return false; });
    f(1, "") === false;
    
    class C { constructor(a: number) { } }
    const c = Object.freeze(C);
    new c(1);
    
    const a = Object.freeze([1, 2, 3]);
    a[0] = a[2].toString();
    ~~~~
!!! error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
    
    const o = Object.freeze({ a: 1, b: "string" });
    o.b = o.a.toString();
      ~
!!! error TS2540: Cannot assign to 'b' because it is a constant or a read-only property.