1/* 2 * Copyright (c) 2023 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 description: > 17 A dynamic property declaration does not introduce a property in the class type or constructor function type. 18 The property name expression of a dynamic property assignment must be of type Any or the String, Number, or Symbol primitive type. 19 The name associated with a dynamic property declarations is considered to be a numeric property name if the property name expression is of type Any or the Number primitive type. 20 module: ESNext 21 isCurrent: true 22 ---*/ 23 24 25import { Assert } from '../../../../../suite/assert.js' 26 27class computer { 28 [compute:string]:any 29 constructor( 30 public name:string, 31 public age:number 32 ){} 33 sayOne(){return "one"} 34} 35let uce = new computer("aa",22); 36uce.pid = "223"; 37uce.id=1; 38Assert.equal(uce.name,"aa"); 39Assert.equal(typeof uce,"object"); 40Assert.equal(uce.id+uce.pid,"1223"); 41Assert.equal(uce.sayOne(),"one");