1/* 2 * Copyright (c) 2023-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// We don't report errors that originated from *.d.ts files (i.e. from any external library) 17 18import { 19 InsightIntent, 20 margin, 21 WindowsStage, 22 Indexed, 23 TypeLiteral 24} from "./d_ts.lib"; 25 26// issue 13041: Object literal 27let intent: InsightIntent = { // OK 28 intentEntityInfo: { 29 entityId: '1', 30 entityName: '2', 31 prop1: '3', 32 prop2: '4' 33 } 34} 35 36// issue 13043: Object literal 37margin<string>({ top: 24, bottom: 16 }); // OK 38 39// issue 13048: Lambda parameter's omitted types 40let windowStage: WindowsStage = new WindowsStage(); 41windowStage.loadContent('page/1', (err, data) => {}); // OK, lambda instantiates functional interface from the library, so parameter types may be omitted. 42windowStage.loadContent2('page/1', (err, data) => {}); // OK, same as above 43 44// Property indexed access 45let idx1: Indexed = { 46 a: 1, 47 b: 2 48} 49idx1[1]; // OK 50idx1['2']; // OK 51 52interface Indexed2 { 53 [x: string]: number; 54} 55let idx2: Indexed2 = { // CTE in ArkTS 56 a: 1, 57 b: 2 58} 59idx2[1]; // CTE in ArkTS 60idx2['2']; // CTE in ArkTS 61 62// initializing Type literal 63let typeLiteral: TypeLiteral = { // OK 64 a: 1, 65 b: '2' 66}; 67 68// Standard Library cases 69let aescbc: AesCbcParams = { // OK, object literal conforms the interface 70 name: 'A', 71 iv: { 72 buffer: new ArrayBuffer(0), 73 byteLength: 1, 74 byteOffset: 2 75 } 76}; 77 78let iterRes: IteratorResult<number> = { // OK, object literal conforms the interface 79 value: 5 80}; 81 82let obj: Object = { // CTE in ArkTS, Object can not be initialized with object literal 83 a: 0 84};