diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 97422740d670db7013dea0bea1427fe7eee5fb85..56a9aefc58e06c4c3dca1b3a1603010835019035 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -105,6 +105,7 @@ import { import { ErrorCodeModule } from './hvigor_error_code/const/error_code_module'; import { buildErrorInfoFromDiagnostic } from './hvigor_error_code/utils'; import { concatenateEtsOptions, getExternalComponentPaths } from './external_component_map'; +import { ATOMICSERVICE_BUNDLE_TYPE } from './fast_build/system_api/api_check_define'; export interface LanguageServiceCache { service?: ts.LanguageService; @@ -849,6 +850,11 @@ function containFormError(message: string): boolean { return false; } +function matchJSGrammarErrorMessage(message: string): boolean { + const regex = /^'.*?' can't support atomicservice application\.$/; + return regex.test(message); +} + let fileToIgnoreDiagnostics: Set | undefined = undefined; function collectFileToThrowDiagnostics(file: string, fileToThrowDiagnostics: Set): void { @@ -928,12 +934,27 @@ export function printDiagnostic(diagnostic: ts.Diagnostic, flag?: ErrorCodeModul return; } + if (fileToIgnoreDiagnostics) { + fileToIgnoreDiagnostics.forEach(fileName => { + if (!isInSDK(fileName) && projectConfig.bundleType === ATOMICSERVICE_BUNDLE_TYPE && + (/\.(c|m)?js$/).test(fileName) && + (fileName.replace(/\\/g, '/').startsWith(projectConfig.projectPath.replace(/\\/g, '/')))) { + fileToIgnoreDiagnostics.delete(fileName); + } + }); + } + if (fileToIgnoreDiagnostics && diagnostic.file && diagnostic.file.fileName && fileToIgnoreDiagnostics.has(toUnixPath(diagnostic.file.fileName))) { return; } const message: string = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + + if (!matchJSGrammarErrorMessage(message)) { + return; + } + if (validateError(message)) { if (process.env.watchMode !== 'true' && !projectConfig.xtsMode) { updateErrorFileCache(diagnostic);