1/*
2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16
17var array1: number[] = [1, 2, 3, 4];
18array1[3] = 5;
19
20
21interface Interface1 {
22    foo: number,
23    bar: string,
24}
25interface Interface2 {
26    foo: number,
27    bar: string,
28    foobar: Interface1
29}
30var a1: Interface2;
31var b1: Interface1;
32a1.foo = 2;
33a1.bar = "bar";
34b1.foo = a1.foo;
35b1.bar = a1.bar;
36a1.foobar = b1;
37a1.foobar.foo = 3;
38a1.foobar.bar = "foo";
39
40
41
42interface Interface3 {
43    foo: number[]
44}
45var a2: Interface3;
46a2.foo[2] = 5;
47
48
49
50interface Interface4 {
51    foo : {bar: number}
52}
53var a3: Interface4;
54a3.foo.bar = 3;
55
56
57interface Interface5 {
58    foo : {foobar: number}
59}
60interface Interface6 {
61    bar: Interface5[]
62}
63var a4: Interface6;
64a4.bar[0].foo.foobar = 3;
65
66
67interface Interface6 {
68    a: ({bar: string} | {bar: number})
69}
70interface Interface7 {
71    foo : Interface6[]
72}
73interface Interface8 {
74    bar : Interface7;
75}
76var a5: Interface8;
77a5.bar.foo[0].a.bar = 5;
78a5.bar.foo[0].a.bar = "foo";
79var a6: Interface8;
80a6.bar.foo[1].a.bar = a5.bar.foo[0].a.bar;
81
82
83interface Interface9 {
84    a: number,
85    b: string,
86    c: number,
87}
88interface Interface10 extends Interface9 {
89    d: number
90}
91var obj13: Interface10;
92obj13.a = 5;
93obj13.b = "foo";
94obj13.c = 5;
95obj13.d = 5;
96var obj14: { a: number[] | [string, string, string], b(a: number[]): string[] };
97obj14.a = [1, 2, 3];
98obj14.a = ["foo", "bar", "baz"];
99obj14.b = function (a: (number[])) { return ["foo", "bar", "baz"] };
100
101interface Interface11 {
102    a: number,
103}
104
105var obj15: Interface10 | Interface11;
106obj15.a;
107
108var obj16: { readonly a: { b: number } };
109obj16.a.b = 3;