13af6ab5fSopenharmony_ci/* 23af6ab5fSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 33af6ab5fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 43af6ab5fSopenharmony_ci * you may not use this file except in compliance with the License. 53af6ab5fSopenharmony_ci * You may obtain a copy of the License at 63af6ab5fSopenharmony_ci * 73af6ab5fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 83af6ab5fSopenharmony_ci * 93af6ab5fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 103af6ab5fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 113af6ab5fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 123af6ab5fSopenharmony_ci * See the License for the specific language governing permissions and 133af6ab5fSopenharmony_ci * limitations under the License. 143af6ab5fSopenharmony_ci */ 153af6ab5fSopenharmony_ci 163af6ab5fSopenharmony_ci// We don't report errors that originated from *.d.ts files (i.e. from any external library) 173af6ab5fSopenharmony_ci 183af6ab5fSopenharmony_ciimport { 193af6ab5fSopenharmony_ci InsightIntent, 203af6ab5fSopenharmony_ci margin, 213af6ab5fSopenharmony_ci WindowsStage, 223af6ab5fSopenharmony_ci Indexed, 233af6ab5fSopenharmony_ci TypeLiteral 243af6ab5fSopenharmony_ci} from "./d_ts.lib"; 253af6ab5fSopenharmony_ci 263af6ab5fSopenharmony_ci// issue 13041: Object literal 273af6ab5fSopenharmony_cilet intent: InsightIntent = { // OK 283af6ab5fSopenharmony_ci intentEntityInfo: { 293af6ab5fSopenharmony_ci entityId: '1', 303af6ab5fSopenharmony_ci entityName: '2', 313af6ab5fSopenharmony_ci prop1: '3', 323af6ab5fSopenharmony_ci prop2: '4' 333af6ab5fSopenharmony_ci } 343af6ab5fSopenharmony_ci} 353af6ab5fSopenharmony_ci 363af6ab5fSopenharmony_ci// issue 13043: Object literal 373af6ab5fSopenharmony_cimargin<string>({ top: 24, bottom: 16 }); // OK 383af6ab5fSopenharmony_ci 393af6ab5fSopenharmony_ci// issue 13048: Lambda parameter's omitted types 403af6ab5fSopenharmony_cilet windowStage: WindowsStage = new WindowsStage(); 413af6ab5fSopenharmony_ciwindowStage.loadContent('page/1', (err, data) => {}); // OK, lambda instantiates functional interface from the library, so parameter types may be omitted. 423af6ab5fSopenharmony_ciwindowStage.loadContent2('page/1', (err, data) => {}); // OK, same as above 433af6ab5fSopenharmony_ci 443af6ab5fSopenharmony_ci// Property indexed access 453af6ab5fSopenharmony_cilet idx1: Indexed = { 463af6ab5fSopenharmony_ci a: 1, 473af6ab5fSopenharmony_ci b: 2 483af6ab5fSopenharmony_ci} 493af6ab5fSopenharmony_ciidx1[1]; // OK 503af6ab5fSopenharmony_ciidx1['2']; // OK 513af6ab5fSopenharmony_ci 523af6ab5fSopenharmony_ciinterface Indexed2 { 533af6ab5fSopenharmony_ci [x: string]: number; 543af6ab5fSopenharmony_ci} 553af6ab5fSopenharmony_cilet idx2: Indexed2 = { // CTE in ArkTS 563af6ab5fSopenharmony_ci a: 1, 573af6ab5fSopenharmony_ci b: 2 583af6ab5fSopenharmony_ci} 593af6ab5fSopenharmony_ciidx2[1]; // CTE in ArkTS 603af6ab5fSopenharmony_ciidx2['2']; // CTE in ArkTS 613af6ab5fSopenharmony_ci 623af6ab5fSopenharmony_ci// initializing Type literal 633af6ab5fSopenharmony_cilet typeLiteral: TypeLiteral = { // OK 643af6ab5fSopenharmony_ci a: 1, 653af6ab5fSopenharmony_ci b: '2' 663af6ab5fSopenharmony_ci}; 673af6ab5fSopenharmony_ci 683af6ab5fSopenharmony_ci// Standard Library cases 693af6ab5fSopenharmony_cilet aescbc: AesCbcParams = { // OK, object literal conforms the interface 703af6ab5fSopenharmony_ci name: 'A', 713af6ab5fSopenharmony_ci iv: { 723af6ab5fSopenharmony_ci buffer: new ArrayBuffer(0), 733af6ab5fSopenharmony_ci byteLength: 1, 743af6ab5fSopenharmony_ci byteOffset: 2 753af6ab5fSopenharmony_ci } 763af6ab5fSopenharmony_ci}; 773af6ab5fSopenharmony_ci 783af6ab5fSopenharmony_cilet iterRes: IteratorResult<number> = { // OK, object literal conforms the interface 793af6ab5fSopenharmony_ci value: 5 803af6ab5fSopenharmony_ci}; 813af6ab5fSopenharmony_ci 823af6ab5fSopenharmony_cilet obj: Object = { // CTE in ArkTS, Object can not be initialized with object literal 833af6ab5fSopenharmony_ci a: 0 843af6ab5fSopenharmony_ci};