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'use static' 16 17@Entry 18@Component 19struct Index { 20 fontStyleAttr1: TextStyle = new TextStyle({fontColor: Color.Blue}); // Error(2) 21 fontStyleAttr2: TextStyle; // Error 22 @State styleList: Array<TextStyle> = new Array(); // Error 23 aboutToAppear() { 24 for (let i = 15; i < 50; i++) 25 this.styleList.push(new TextStyle({})); // Error 26 } 27 28 build() { 29 List() { 30 ForEach(this.styleList, (item: TextStyle) => { // Error 31 ListItem() { 32 Text("Hello World") 33 .fontSize(item.fontSize) 34 } 35 }) 36 } 37 } 38} 39 40class TextStyleDemo2 extends TextStyle { // Error 41 constructor() { 42 super(); 43 } 44} 45 46let hyperlinkAttr1: HyperlinkAttribute = HyperlinkInterface; // Error 47let hyperlinkAttr2: HyperlinkAttribute = HyperlinkInterface.color(''); // Error 48class HyperlinkTest { 49 prop1: HyperlinkAttribute = HyperlinkInterface; // Error 50 prop2: HyperlinkAttribute = HyperlinkInterface.color(''); // Error 51} 52let hyperlinkAttr3: HyperlinkAttribute; 53hyperlinkAttr3 = HyperlinkInterface; // Error 54function func(x = HyperlinkInterface) { // Error 55 56} 57 58class A { 59 onBackPress: Function; 60 TextStyle: Function; 61 constructor(onBackPress: Function, TextStyle: Function) { 62 this.onBackPress = onBackPress; // no Error 63 this.TextStyle = TextStyle; // no Error 64 } 65} 66function tt(a: A) { 67 a.onBackPress(); 68} 69