From d282522c7ac2e59db43966f409c79502e93cbba0 Mon Sep 17 00:00:00 2001 From: maslow Date: Tue, 10 Aug 2021 15:35:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(devops-admin):=20=E6=96=B0=E5=A2=9E=20@type?= =?UTF-8?q?s/node=20=E4=B8=BA=E9=BB=98=E8=AE=A4=E5=8A=A0=E8=BD=BD=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=8C=85=E4=BB=A5=E5=A2=9E=E5=BC=BA=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/FunctionEditor/types/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/devops-admin/src/components/FunctionEditor/types/index.js b/packages/devops-admin/src/components/FunctionEditor/types/index.js index e05116bbba..6e6a156284 100644 --- a/packages/devops-admin/src/components/FunctionEditor/types/index.js +++ b/packages/devops-admin/src/components/FunctionEditor/types/index.js @@ -61,6 +61,7 @@ export class AutoImportTypings { if (!this.isLoaded('axios')) { this.loadDeclaration('axios') } if (!this.isLoaded('cloud-function-engine')) { this.loadDeclaration('cloud-function-engine') } if (!this.isLoaded('mongodb')) { this.loadDeclaration('mongodb') } + if (!this.isLoaded('@types/node')) { this.loadDeclaration('@types/node') } } /** @@ -79,13 +80,19 @@ export class AutoImportTypings { */ async loadDeclaration(packageName) { try { - const r = await loadPackageTypings(packageName) - if (r.code) { + const r = await loadPackageTypings(packageName).catch(err => console.error(err)) + if (r?.code) { return } const rets = r.data || [] for (const lib of rets) { + // 修复包的类型入口文件不为 index.d.ts 的情况 + if (packageName === lib.packageName && lib.path !== `${packageName}/index.d.ts`) { + const _lib = { ...lib } + _lib.path = `${packageName}/index.d.ts` + this.addExtraLib(_lib) + } this.addExtraLib(lib) }