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 16import { ExportLitAsPropName } from './ignore_files/good'; 17 18class LiteralAsPropertyName { 19 public one: string = "1111111111"; 20 private 2: string; 21 'Two': number; 22} 23 24const litAsPropName: LiteralAsPropertyName = { 25 one: "1", 26 2: 'two', 27 'Two': 2, 28}; 29 30console.log(litAsPropName["one"]); 31console.log(litAsPropName[2]); 32console.log(litAsPropName["Two"]); 33 34class LiteralAsPropertyName_fix { 35 public one: string = "1111111111"; 36 private _2: string; 37 Two: number; 38} 39 40const litAsPropName_fix: LiteralAsPropertyName_fix = { 41 one: "1111111111", 42 _2: 'two', 43 Two: 2, 44}; 45 46console.log("Fixed listAsPropName:"); 47console.log(litAsPropName_fix.one); 48console.log(litAsPropName_fix._2); 49console.log(litAsPropName_fix.Two); 50 51let x = {"name": 20, 2: 30} 52 53console.log(x["name"]); 54console.log(x[2]); 55 56class X_class { 57 public name: number; 58 public _2: number; 59} 60 61let x_fix = {name: 20, _2: 20}; 62 63console.log("Fixed x object literal:"); 64console.log(x_fix.name); 65console.log(x_fix._2); 66 67interface litAsPropNameIface { 68 one: string; 69 2: string; 70 '__2': number; 71} 72const int: litAsPropNameIface = { 73 one: '12321', 74 2: 'weqwewq', 75 '__2': 123 76}; 77 78const imp: ExportLitAsPropName = { 1: 234 }; 79