Skip to content

Commit

Permalink
fix(devops-admin): 新增 @types/node 为默认加载类型包以增强提示;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Aug 10, 2021
1 parent 96f952d commit d282522
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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') }
}

/**
Expand All @@ -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)
}

Expand Down

0 comments on commit d282522

Please sign in to comment.