1/* 2 * Copyright (c) 2023-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 16var x = {"name": 1, 2: 3} 17 18console.log(x["name"]) 19console.log(x[2]) 20 21class X { 22 public name: number = 0 23} 24let y = {name: 1} 25console.log(x.name) 26 27let z = [1, 2, 3] 28console.log(y[2]) 29 30enum S1 { 31 s1 = "qwqwq", 32} 33 34enum S2 { 35 s2 = 123, 36} 37 38interface A1 { 39 [S1.s1]: string; 40} 41 42interface A2 { 43 [S2.s2]: string; 44} 45 46const a1: A1 = { 47 [S1.s1]: "fld1", 48}; 49 50const a2: A2 = { 51 [S2.s2]: "fld2", 52}; 53 54S1["s1"]; 55S2["s2"]; 56