1/* 2 * Copyright (c) 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 16/*--- 17 desc: 10.04.Interface_Members 18 name: 10.Interfaces/10.04.Interface_Members/interface_with_optional_attributes_0005.sts 19 tags: 20 ---*/ 21 22interface IStudent { 23 name?: string | undefined; 24 age?: int | undefined; 25 desc?: string | undefined; 26 teacher?: Teacher | undefined 27} 28 29class Teacher { 30 name: string; 31} 32 33class Student implements IStudent { 34 name?: string | undefined; 35 age?: int | undefined; 36 desc?: string | undefined; 37 teacher?: Teacher | undefined 38} 39 40function main() : void { 41 let s0 : Student = new Student(); 42 43 assert s0.name == undefined 44 assert s0.age == undefined 45 assert s0.desc == undefined 46 assert s0.teacher == undefined 47} 48