File: intersectionTypeReadonly.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (71 lines) | stat: -rw-r--r-- 1,590 bytes parent folder | download | duplicates (3)
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
70
71
=== tests/cases/conformance/types/intersection/intersectionTypeReadonly.ts ===
interface Base {
    readonly value: number;
>value : number
}
interface Identical {
    readonly value: number;
>value : number
}
interface Mutable {
    value: number;
>value : number
}
interface DifferentType {
    readonly value: string;
>value : string
}
interface DifferentName {
    readonly other: number;
>other : number
}
let base: Base;
>base : Base

base.value = 12 // error, lhs can't be a readonly property
>base.value = 12 : 12
>base.value : any
>base : Base
>value : any
>12 : 12

let identical: Base & Identical;
>identical : Base & Identical

identical.value = 12; // error, lhs can't be a readonly property
>identical.value = 12 : 12
>identical.value : any
>identical : Base & Identical
>value : any
>12 : 12

let mutable: Base & Mutable;
>mutable : Base & Mutable

mutable.value = 12;
>mutable.value = 12 : 12
>mutable.value : number
>mutable : Base & Mutable
>value : number
>12 : 12

let differentType: Base & DifferentType;
>differentType : Base & DifferentType

differentType.value = 12; // error, lhs can't be a readonly property
>differentType.value = 12 : 12
>differentType.value : any
>differentType : Base & DifferentType
>value : any
>12 : 12

let differentName: Base & DifferentName;
>differentName : Base & DifferentName

differentName.value = 12; // error, property 'value' doesn't exist
>differentName.value = 12 : 12
>differentName.value : any
>differentName : Base & DifferentName
>value : any
>12 : 12