From 3e80bee2d2571e65adfa69b01949282866f433ae Mon Sep 17 00:00:00 2001 From: lizhouze Date: Wed, 3 Aug 2022 17:38:07 +0800 Subject: [PATCH] lizhouze@huawei.com Signed-off-by: lizhouze --- compiler/src/ets_checker.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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); }