• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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
17interface A {
18    a: number,
19    b: string,
20    c: boolean,
21}
22
23var a: A = { a: 1, b: "foo", c: true };
24
25interface B extends A {
26    d(a: number, b: string): number[];
27}
28
29var b: B = {
30    a: 2, b: "bar", c: false, d: function (a: number, b: string) {
31        return [1, 2];
32    }
33}
34
35
36interface C1 {
37    (a: number, b: number): string,
38}
39
40interface C2 {
41    (a: number, b: number): string,
42    (a: number, b: number): string,
43    (a: number, b: number): string,
44}
45
46interface C3 extends C1 {
47    (a: number, b: number): string,
48    (a: number, b: number): string,
49}
50
51var c: C2;
52var c: C3;
53
54interface D4 extends D3, D2 {
55    d: string[]
56}
57
58interface D1 {
59    a: number
60}
61
62interface D3 {
63    c: string,
64}
65
66interface D2 extends D1 {
67    b: number,
68}
69
70interface D5 extends D4, D1, D3 {
71    e: [number, string];
72}
73
74var d: D5 = { a: 2, b: 3, c: "bar", d: ["foo", "bar", "baz"], e: [1, "foo"] }
75
76interface E {
77    a: number,
78}
79
80interface E {
81    b: string,
82}
83
84interface E {
85    d: (a: number, b: string) => {}
86}
87
88var e: E = { a: 1, b: "foo", d: function (a: number, b: string) { return {} } }
89
90interface F {
91    [x: number]: string,
92    [x: string]: number | string
93}
94
95var f: F = { 5: "foo", 6: "bar", a: 1, b: "baz" };
96
97