/* * Copyright (c) 2023-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ class C1 { n: number = 0 s: string = "" } let o1: C1 = {n: 42, s: "foo"} let o2: C1 = {n: 42, s: "foo"} let o3: C1 = {n: 42, s: "foo"} let oo: C1[] = [{n: 1, s: "1"}, {n: 2, s: "2"}] class C2 { s: string constructor(s: string) { this.s = "s =" + s } } let o4 = new C2("foo") class C3 { n: number = 0 s: string = "" } let o5: C3 = {n: 42, s: "foo"} abstract class A {} class C extends A {} let o6: C = {} class C4 { n: number = 0 s: string = "" f() { console.log("Hello") } } let o7 = new C4() o7.n = 42 o7.s = "foo" class Point { x: number = 0 y: number = 0 } function id_x_y(o: Point): Point { return o } let p: Point = {x: 5, y: 10} id_x_y(p) id_x_y({x: 5, y: 10})