1/* 2 * Copyright (c) 2025 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 16export function foo(prx: Object) { 17 Reflect.get(prx, 'a') // 'hello' 18 Reflect.set(prx, 'a', 'world') // true 19 Reflect.ownKeys(prx) // ['a'] 20} 21 22export function bar(obj: Object) { 23 return Reflect.has(obj, 'prop'); 24} 25 26export class X { 27 a: string = 'hello' 28 getName() { return this.a } 29} 30 31export class Reflect1 { 32 a: string = 'hello' 33 getName() { return this.a } 34} 35export let obj_Reflect1 = new Reflect1(); 36 37interface Iface { 38 a:number 39} 40export let objInter:Iface = {a:1} 41 42export function reflect_method1(prx: ESObject) { 43 Reflect.ownKeys(prx) // ['a'] 44 Reflect.set(prx, 'a', 7) // true 45 Reflect.get(prx, 'a') // true 46 Reflect.has(prx, 'a') // true 47} 48 49export function reflect_method1_set(prx: ESObject) { 50 Reflect.set(prx, 'a', 7) // true 51} 52 53export function reflect_method1_get(prx: ESObject) { 54 Reflect.get(prx, 'a') // true 55} 56 57export function reflect_method1_ownKeys(prx: ESObject) { 58 Reflect.ownKeys(prx) // ['a'] 59} 60 61export function reflect_method1_has(prx: ESObject) { 62 Reflect.has(prx, 'a') // true 63} 64