@@ -68,7 +68,15 @@ export const setupTypeAcquisition = (config: ATABootstrapConfig) => {
6868
6969 // Grab the module trees which gives us a list of files to download
7070 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+ } ) ;
7280
7381 // These are the modules which we can grab directly
7482 const hasDTS = treesOnly . filter ( t => t . files . find ( f => isDtsFile ( f . name ) ) )
@@ -81,7 +89,16 @@ export const setupTypeAcquisition = (config: ATABootstrapConfig) => {
8189 mightBeOnDT . map ( f => getFileTreeForModuleWithTag ( config , `@types/${ getDTName ( f . moduleName ) } ` , "latest" ) )
8290 )
8391
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+
85102 const dtsFilesFromDT = dtTreesOnly . map ( t => treeToDTSFiles ( t , `/node_modules/@types/${ getDTName ( t . moduleName ) . replace ( "types__" , "" ) } ` ) )
86103
87104 // Collect all the npm and DT DTS requests and flatten their arrays
@@ -102,7 +119,9 @@ export const setupTypeAcquisition = (config: ATABootstrapConfig) => {
102119 fsMap . set ( path , pkgJSON )
103120 config . delegate . receivedFile ?.( pkgJSON , path )
104121 } 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 )
106125 }
107126 }
108127
@@ -112,8 +131,9 @@ export const setupTypeAcquisition = (config: ATABootstrapConfig) => {
112131 const dtsCode = await getDTSFileForModuleWithVersion ( config , dts . moduleName , dts . moduleVersion , dts . path )
113132 estimatedDownloaded ++
114133 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 )
117137 } else {
118138 fsMap . set ( dts . vfsPath , dtsCode )
119139 config . delegate . receivedFile ?.( dtsCode , dts . vfsPath )
@@ -226,7 +246,7 @@ export const getFileTreeForModuleWithTag = async (
226246 const versions = await getNPMVersionsForModule ( config , moduleName )
227247 if ( versions instanceof Error ) {
228248 return {
229- error : response ,
249+ error : versions ,
230250 userFacingMessage : `Could not get versions on npm for ${ moduleName } - possible typo?` ,
231251 }
232252 }
0 commit comments