diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 8a26ffd28ec1332f66218326a4645396a691d3e1..a613d93a6d41a60aa9355b18afde8c4c0ff2b35a 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -512,7 +512,7 @@ export function mergeRollUpFiles(rollupFileList: IterableIterator, rollu } } -// collect the modulename or pkgname of all local modules. +// collect the modulename or pkgname of all local modules. export function addLocalPackageSet(moduleId: string, rollupObject: Object): void { const moduleInfo: Object = rollupObject.getModuleInfo(moduleId); const metaInfo: Object = moduleInfo.meta; @@ -599,7 +599,7 @@ function collectFileToThrowDiagnostics(file: string, fileToThrowDiagnostics: Set } fileToThrowDiagnostics.add(unixFilePath); - if (path.extname(file) === EXTNAME_JS || + if ((/\.(c|m)?js$/).test(file) || !cache[normalizedFilePath] || cache[normalizedFilePath].children.length === 0) { return; } @@ -613,12 +613,15 @@ export function collectFileToIgnoreDiagnostics(rootFileNames: string[]): void { return; } - // With arkts linter enabled, `allowJs` option is set to true, resulting JavaScript-referenced files are included - // in the program and checking process, potentially introducing new errors. For instance, in scenarios where - // an ets file imports js file imports ts file, it’s necessary to filter out errors from ts files. + // With arkts linter enabled, `allowJs` option is set to true, resulting JavaScript files themselves and + // JavaScript-referenced files are included in the tsc program and checking process, + // potentially introducing new errors. For instance, in scenarios where an ets file imports js file imports ts file, + // it’s necessary to filter out errors from ts files. let fileToThrowDiagnostics: Set = new Set(); rootFileNames.forEach(file => { - collectFileToThrowDiagnostics(file, fileToThrowDiagnostics); + if (!(/\.(c|m)?js$/).test(file)) { + collectFileToThrowDiagnostics(file, fileToThrowDiagnostics); + } }); fileToIgnoreDiagnostics = new Set();