@@ -68,7 +68,15 @@ export const setupTypeAcquisition = (config: ATABootstrapConfig) => {
68
68
69
69
// Grab the module trees which gives us a list of files to download
70
70
const trees = await Promise . all ( depsToGet . map ( f => getFileTreeForModuleWithTag ( config , f . module , f . version ) ) )
71
- const treesOnly = trees . filter ( t => ! ( "error" in t ) ) as NPMTreeMeta [ ]
71
+ const treesOnly : NPMTreeMeta [ ] = [ ]
72
+
73
+ trees . forEach ( t => {
74
+ if ( "error" in t ) {
75
+ config . delegate . errorMessage ?.( t . userFacingMessage , t . error )
76
+ } else {
77
+ treesOnly . push ( t )
78
+ }
79
+ } ) ;
72
80
73
81
// These are the modules which we can grab directly
74
82
const hasDTS = treesOnly . filter ( t => t . files . find ( f => isDtsFile ( f . name ) ) )
@@ -81,7 +89,16 @@ export const setupTypeAcquisition = (config: ATABootstrapConfig) => {
81
89
mightBeOnDT . map ( f => getFileTreeForModuleWithTag ( config , `@types/${ getDTName ( f . moduleName ) } ` , "latest" ) )
82
90
)
83
91
84
- const dtTreesOnly = dtTrees . filter ( t => ! ( "error" in t ) ) as NPMTreeMeta [ ]
92
+ const dtTreesOnly : NPMTreeMeta [ ] = [ ]
93
+
94
+ dtTrees . forEach ( t => {
95
+ if ( "error" in t ) {
96
+ config . delegate . errorMessage ?.( t . userFacingMessage , t . error )
97
+ } else {
98
+ dtTreesOnly . push ( t )
99
+ }
100
+ } ) ;
101
+
85
102
const dtsFilesFromDT = dtTreesOnly . map ( t => treeToDTSFiles ( t , `/node_modules/@types/${ getDTName ( t . moduleName ) . replace ( "types__" , "" ) } ` ) )
86
103
87
104
// Collect all the npm and DT DTS requests and flatten their arrays
@@ -102,7 +119,9 @@ export const setupTypeAcquisition = (config: ATABootstrapConfig) => {
102
119
fsMap . set ( path , pkgJSON )
103
120
config . delegate . receivedFile ?.( pkgJSON , path )
104
121
} else {
105
- config . logger ?. error ( `Could not download package.json for ${ tree . moduleName } ` )
122
+ const userFacingMessage = `Could not download package.json for ${ tree . moduleName } ` ;
123
+ config . logger ?. error ( userFacingMessage )
124
+ config . delegate . errorMessage ?.( userFacingMessage , pkgJSON )
106
125
}
107
126
}
108
127
@@ -112,8 +131,9 @@ export const setupTypeAcquisition = (config: ATABootstrapConfig) => {
112
131
const dtsCode = await getDTSFileForModuleWithVersion ( config , dts . moduleName , dts . moduleVersion , dts . path )
113
132
estimatedDownloaded ++
114
133
if ( dtsCode instanceof Error ) {
115
- // TODO?
116
- config . logger ?. error ( `Had an issue getting ${ dts . path } for ${ dts . moduleName } ` )
134
+ const userFacingMessage = `Had an issue getting ${ dts . path } for ${ dts . moduleName } ` ;
135
+ config . logger ?. error ( userFacingMessage )
136
+ config . delegate . errorMessage ?.( userFacingMessage , dtsCode )
117
137
} else {
118
138
fsMap . set ( dts . vfsPath , dtsCode )
119
139
config . delegate . receivedFile ?.( dtsCode , dts . vfsPath )
@@ -226,7 +246,7 @@ export const getFileTreeForModuleWithTag = async (
226
246
const versions = await getNPMVersionsForModule ( config , moduleName )
227
247
if ( versions instanceof Error ) {
228
248
return {
229
- error : response ,
249
+ error : versions ,
230
250
userFacingMessage : `Could not get versions on npm for ${ moduleName } - possible typo?` ,
231
251
}
232
252
}
0 commit comments