diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index a266e99..8d83973 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -144,7 +144,7 @@ function resolveModuleNames(moduleNames: string[], containingFile: string): ts.R } else { resolvedModules.push(null); } - } else if (/^@(system|ohos)/i.test(moduleName.trim())) { + } else if (/^@(system|ohos)\./i.test(moduleName.trim())) { const modulePath: string = path.resolve(__dirname, '../../../api', moduleName + '.d.ts'); if (systemModules.includes(moduleName + '.d.ts') && ts.sys.fileExists(modulePath)) { resolvedModules.push(getResolveModule(modulePath, '.d.ts')); @@ -169,10 +169,14 @@ function resolveModuleNames(moduleNames: string[], containingFile: string): ts.R const modulePath: string = path.resolve(__dirname, '../../../api', moduleName + '.d.ts'); const suffix: string = /\.js$/.test(moduleName) ? '' : '.js'; const jsModulePath: string = path.resolve(__dirname, '../node_modules', moduleName + suffix); + const fileModulePath: string = + path.resolve(__dirname, '../node_modules', moduleName + '/index.js'); if (ts.sys.fileExists(modulePath)) { resolvedModules.push(getResolveModule(modulePath, '.d.ts')); } else if (ts.sys.fileExists(jsModulePath)) { - resolvedModules.push(getResolveModule(modulePath, '.js')); + resolvedModules.push(getResolveModule(jsModulePath, '.js')); + } else if (ts.sys.fileExists(fileModulePath)) { + resolvedModules.push(getResolveModule(fileModulePath, '.js')); } else { resolvedModules.push(null); }