@@ -30,6 +30,9 @@ import {
3030 Version ,
3131 versionMajorMinor ,
3232} from "./_namespaces/ts" ;
33+ import {
34+ stringifyIndented ,
35+ } from "./_namespaces/ts.server" ;
3336
3437export interface TypingResolutionHost {
3538 directoryExists ( path : string ) : boolean ;
@@ -174,7 +177,7 @@ export function discoverTypings(
174177 }
175178
176179 // A typing name to typing file path mapping
177- const inferredTypings = new Map < string , string > ( ) ;
180+ const inferredTypings = new Map < string , string | false > ( ) ;
178181
179182 // Only infer typings for .js and .jsx files
180183 fileNames = mapDefined ( fileNames , fileName => {
@@ -211,37 +214,37 @@ export function discoverTypings(
211214 ) ;
212215 addInferredTypings ( module , "Inferred typings from unresolved imports" ) ;
213216 }
217+ // Remove typings that the user has added to the exclude list
218+ for ( const excludeTypingName of exclude ) {
219+ const didDelete = inferredTypings . delete ( excludeTypingName ) ;
220+ if ( didDelete && log ) log ( `Typing for ${ excludeTypingName } is in exclude list, will be ignored.` ) ;
221+ }
222+
214223 // Add the cached typing locations for inferred typings that are already installed
215224 packageNameToTypingLocation . forEach ( ( typing , name ) => {
216225 const registryEntry = typesRegistry . get ( name ) ;
217- if ( inferredTypings . has ( name ) && inferredTypings . get ( name ) === undefined && registryEntry !== undefined && isTypingUpToDate ( typing , registryEntry ) ) {
226+ if ( inferredTypings . get ( name ) === false && registryEntry !== undefined && isTypingUpToDate ( typing , registryEntry ) ) {
218227 inferredTypings . set ( name , typing . typingLocation ) ;
219228 }
220229 } ) ;
221230
222- // Remove typings that the user has added to the exclude list
223- for ( const excludeTypingName of exclude ) {
224- const didDelete = inferredTypings . delete ( excludeTypingName ) ;
225- if ( didDelete && log ) log ( `Typing for ${ excludeTypingName } is in exclude list, will be ignored.` ) ;
226- }
227-
228231 const newTypingNames : string [ ] = [ ] ;
229232 const cachedTypingPaths : string [ ] = [ ] ;
230233 inferredTypings . forEach ( ( inferred , typing ) => {
231- if ( inferred !== undefined ) {
234+ if ( inferred ) {
232235 cachedTypingPaths . push ( inferred ) ;
233236 }
234237 else {
235238 newTypingNames . push ( typing ) ;
236239 }
237240 } ) ;
238241 const result = { cachedTypingPaths, newTypingNames, filesToWatch } ;
239- if ( log ) log ( `Result: ${ JSON . stringify ( result ) } ` ) ;
242+ if ( log ) log ( `Finished typings discovery: ${ stringifyIndented ( result ) } ` ) ;
240243 return result ;
241244
242245 function addInferredTyping ( typingName : string ) {
243246 if ( ! inferredTypings . has ( typingName ) ) {
244- inferredTypings . set ( typingName , undefined ! ) ; // TODO: GH#18217
247+ inferredTypings . set ( typingName , false ) ;
245248 }
246249 }
247250 function addInferredTypings ( typingNames : readonly string [ ] , message : string ) {
0 commit comments