diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 716d75244c5fed4ebfac63401cfc2f77aa6daec1..95f1fa1032ebce8d0f2c5617186d8d0c60a97621 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -113,6 +113,7 @@ export interface LanguageServiceCache { maxFlowDepth?: number; preTsImportSendable?: boolean; preSkipOhModulesLint?: boolean; + preEnableStrictCheckOHModule?: boolean; preMixCompile?: boolean; } @@ -210,6 +211,7 @@ function setCompilerOptions(resolveModulePaths: string[]): void { 'compatibleSdkVersionStage': projectConfig.compatibleSdkVersionStage, 'compatibleSdkVersion': projectConfig.compatibleSdkVersion, 'skipOhModulesLint': skipOhModulesLint, + 'enableStrictCheckOHModule': enableStrictCheckOHModule, 'mixCompile': mixCompile }); if (projectConfig.compileMode === ESMODULE) { @@ -451,16 +453,18 @@ function getOrCreateLanguageService(servicesHost: ts.LanguageServiceHost, rootFi cache?.preTsImportSendable !== tsImportSendable; const skipOhModulesLintDiff: boolean = (cache?.preSkipOhModulesLint === undefined && !skipOhModulesLint) ? false : cache?.preSkipOhModulesLint !== skipOhModulesLint; + const enableStrictCheckOHModuleDiff: boolean = (cache?.preEnableStrictCheckOHModule === undefined && !enableStrictCheckOHModule) ? + false : cache?.preEnableStrictCheckOHModule !== enableStrictCheckOHModule; const mixCompileDiff: boolean = (cache?.preMixCompile === undefined && !mixCompile) ? false : cache?.preMixCompile !== mixCompile; const shouldRebuild: boolean | undefined = shouldRebuildForDepDiffers || targetESVersionDiffers || - tsImportSendableDiff || maxFlowDepthDiffers || skipOhModulesLintDiff || mixCompileDiff; + tsImportSendableDiff || maxFlowDepthDiffers || skipOhModulesLintDiff || enableStrictCheckOHModuleDiff || mixCompileDiff; if (reuseLanguageServiceForDepChange && hashDiffers && rollupShareObject?.depInfo?.enableIncre) { needReCheckForChangedDepUsers = true; } if (!service || shouldRebuild) { - rebuildProgram(targetESVersionDiffers, tsImportSendableDiff, maxFlowDepthDiffers, skipOhModulesLintDiff, mixCompileDiff); + rebuildProgram(targetESVersionDiffers, tsImportSendableDiff, maxFlowDepthDiffers, skipOhModulesLintDiff, enableStrictCheckOHModuleDiff, mixCompileDiff); service = ts.createLanguageService(servicesHost, ts.createDocumentRegistry()); } else { // Found language service from cache, update root files @@ -475,6 +479,7 @@ function getOrCreateLanguageService(servicesHost: ts.LanguageServiceHost, rootFi maxFlowDepth: currentMaxFlowDepth, preTsImportSendable: tsImportSendable, preSkipOhModulesLint: skipOhModulesLint, + preEnableStrictCheckOHModule: enableStrictCheckOHModule, preMixCompile: mixCompile }; setRollupCache(rollupShareObject, projectConfig, cacheKey, newCache); @@ -482,12 +487,12 @@ function getOrCreateLanguageService(servicesHost: ts.LanguageServiceHost, rootFi } function rebuildProgram(targetESVersionDiffers: boolean | undefined, tsImportSendableDiff: boolean, - maxFlowDepthDiffers: boolean | undefined, skipOhModulesLintDiff: boolean, mixCompileDiff: boolean): void { + maxFlowDepthDiffers: boolean | undefined, skipOhModulesLintDiff: boolean, enableStrictCheckOHModuleDiff: boolean, mixCompileDiff: boolean): void { if (targetESVersionDiffers) { // If the targetESVersion is changed, we need to delete the build info cahce files deleteBuildInfoCache(compilerOptions.tsBuildInfoFile); targetESVersionChanged = true; - } else if (tsImportSendableDiff || maxFlowDepthDiffers || skipOhModulesLintDiff || mixCompileDiff) { + } else if (tsImportSendableDiff || maxFlowDepthDiffers || skipOhModulesLintDiff || enableStrictCheckOHModuleDiff || mixCompileDiff) { // When tsImportSendable or maxFlowDepth is changed, we need to delete the build info cahce files deleteBuildInfoCache(compilerOptions.tsBuildInfoFile); } @@ -548,6 +553,7 @@ export const warnCheckerResult: WarnCheckerResult = { count: 0 }; export let languageService: ts.LanguageService = null; let tsImportSendable: boolean = false; let skipOhModulesLint: boolean = false; +let enableStrictCheckOHModule: boolean = false; let mixCompile: boolean = false; export let maxMemoryInServiceChecker: number = 0; export function serviceChecker(rootFileNames: string[], newLogger: Object = null, resolveModulePaths: string[] = null, @@ -556,6 +562,7 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null let cacheFile: string = null; tsImportSendable = rollupShareObject?.projectConfig.tsImportSendable; skipOhModulesLint = rollupShareObject?.projectConfig.skipOhModulesLint; + enableStrictCheckOHModule = rollupShareObject?.projectConfig.enableStrictCheckOHModule; mixCompile = rollupShareObject?.projectConfig.mixCompile; if (projectConfig.xtsMode || process.env.watchMode === 'true') { if (projectConfig.hotReload) {