From 8bbfeb5016b76d82eeab229c66e60b8c7fcb997e Mon Sep 17 00:00:00 2001 From: xucheng46 Date: Sun, 20 Aug 2023 21:36:45 +0800 Subject: [PATCH] Enabel Standard mode for ArkTS Module Issue: https://gitee.com/openharmony/third_party_typescript/issues/I7WOT3 Test: tsc test Signed-off-by: xucheng46 Change-Id: Ia47337087a21ee3c9c04d3fb0b7963b350c7c736 --- compiler/package-lock.json | 2 +- compiler/src/ets_checker.ts | 11 +++++++---- .../fast_build/ark_compiler/check_import_module.ts | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler/package-lock.json b/compiler/package-lock.json index 647d80027..6ce814faa 100644 --- a/compiler/package-lock.json +++ b/compiler/package-lock.json @@ -4148,7 +4148,7 @@ }, "typescript": { "version": "file:deps/ohos-typescript-4.2.3-r2.tgz", - "integrity": "sha512-bctLs0Jeb2po1894s30Jn+0gkwmp/d4l8iyKwQNAV8hkdPZKSkOF9YzaaoJJ69xuRiehvSDVB0k0PYBnQrZ65A==", + "integrity": "sha512-M4Axyf//rIMZSLliu1L9VCnv6G7w8zHvas/LVym78MKDtxPohezZ5mJ93RplXmPC/+0xgHTGqexnbuGmegViOg==", "requires": { "json5": "^2.2.3" } diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index f53efcff7..50c99a7b5 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -945,7 +945,7 @@ function runArkTSLinter(): void { } function printArkTSLinterDiagnostic(diagnostic: ts.Diagnostic): void { - if (diagnostic.category === ts.DiagnosticCategory.Error && (isInOhModuleFile(diagnostic) || isInSDK(diagnostic))) { + if (diagnostic.category === ts.DiagnosticCategory.Error && (isInOhModuleFile(diagnostic) || isInSDK(diagnostic) || isInApplicationsStandard(diagnostic))) { const originalCategory = diagnostic.category; diagnostic.category = ts.DiagnosticCategory.Warning; printDiagnostic(diagnostic); @@ -956,7 +956,11 @@ function printArkTSLinterDiagnostic(diagnostic: ts.Diagnostic): void { } function isInOhModuleFile(diagnostics: ts.Diagnostic): boolean { - return !!(diagnostics.file?.fileName.indexOf('/oh_modules/') !== -1); + return (diagnostics.file !== undefined) && (diagnostics.file.fileName.indexOf('/oh_modules/') !== -1); +} + +function isInApplicationsStandard(diagnostics: ts.Diagnostic): boolean { + return (diagnostics.file !== undefined) && (diagnostics.file.fileName.indexOf('/applications/standard/') !== -1); } function isInSDK(diagnostics: ts.Diagnostic): boolean { @@ -974,8 +978,7 @@ export function getArkTSLinterMode(): ArkTSLinterMode { } if (isStandardMode()) { - // change to STANDARD_MODE when we block the compilation - return ArkTSLinterMode.COMPATIBLE_MODE; + return ArkTSLinterMode.STANDARD_MODE; } return ArkTSLinterMode.COMPATIBLE_MODE; } diff --git a/compiler/src/fast_build/ark_compiler/check_import_module.ts b/compiler/src/fast_build/ark_compiler/check_import_module.ts index f7256d688..1cba038ce 100644 --- a/compiler/src/fast_build/ark_compiler/check_import_module.ts +++ b/compiler/src/fast_build/ark_compiler/check_import_module.ts @@ -27,7 +27,7 @@ import { export function checkIfJsImportingArkts(rollupObject: any): void { ModuleSourceFile.getSourceFiles().forEach((sourceFile: ModuleSourceFile) => { const id: string = sourceFile.getModuleId(); - if (isJsSourceFile(id) && id.indexOf('/oh_modules/') === -1) { + if (isJsSourceFile(id) && id.indexOf('/oh_modules/') === -1 && id.indexOf('/applications/standard/') === -1) { const importMap = rollupObject.getModuleInfo(id).importedIdMaps; Object.values(importMap).forEach((requestFile: string) => { if (requestFile.endsWith(EXTNAME_ETS) || requestFile.endsWith(EXTNAME_D_ETS)) { -- Gitee