@@ -174,7 +174,11 @@ function buildProjects(
174174
175175 const host = ts . createSolutionBuilderHost (
176176 fsSystem ,
177- createProgramWithPatchedCompilerOptions ,
177+ createProgramWithPatchedCompilerOptions ( {
178+ force,
179+ sourcemap,
180+ tsconfigPath : tsconfig ,
181+ } ) ,
178182 )
179183 const builder = ts . createSolutionBuilder ( host , [ tsconfig ] , {
180184 force,
@@ -229,7 +233,11 @@ function collectProjectGraph(
229233 parsedConfig . options = patchCompilerOptions ( parsedConfig . options , {
230234 tsconfigPath,
231235 force,
232- sourcemap,
236+ // For a project that has no source files (e.g., a tsconfig.json file
237+ // that only contains references), we don't need to generate a sourcemap
238+ // and we don't need to print the warning about the missing
239+ // `declaration`, `declarationMap` in the tsconfig.json file.
240+ sourcemap : sourcemap && parsedConfig . fileNames . length > 0 ,
233241 } )
234242
235243 projects . push ( { tsconfigPath, parsedConfig } )
@@ -267,18 +275,20 @@ function parseTsconfig(
267275 return parsedConfig
268276}
269277
278+ interface CompilerPatchOptions {
279+ tsconfigPath : string
280+ force : boolean
281+ sourcemap : boolean
282+ }
283+
270284// To ensure we can get `.d.ts` and `.d.ts.map` files from `tsc --build` mode,
271285// we need to enforce certain compiler options. Notice that changing compiler
272286// options will invalidate the cache, so it's better to set the correct value in
273287// tsconfig files in the first place. Therefore, we print some warnings if the
274288// values are not set correctly.
275289function patchCompilerOptions (
276290 options : CompilerOptions ,
277- extraOptions : {
278- tsconfigPath : string
279- force : boolean
280- sourcemap : boolean
281- } | null ,
291+ extraOptions : CompilerPatchOptions ,
282292) : CompilerOptions {
283293 const noEmit : boolean = options . noEmit ?? false
284294 const declaration : boolean =
@@ -315,12 +325,14 @@ function patchCompilerOptions(
315325 return options
316326}
317327
318- const createProgramWithPatchedCompilerOptions : CreateProgram <
319- EmitAndSemanticDiagnosticsBuilderProgram
320- > = ( rootNames , options , ...args ) => {
321- return ts . createEmitAndSemanticDiagnosticsBuilderProgram (
322- rootNames ,
323- patchCompilerOptions ( options ?? { } , null ) ,
324- ...args ,
325- )
328+ function createProgramWithPatchedCompilerOptions (
329+ patchOptions : CompilerPatchOptions ,
330+ ) : CreateProgram < EmitAndSemanticDiagnosticsBuilderProgram > {
331+ return ( rootNames , options , ...args ) => {
332+ return ts . createEmitAndSemanticDiagnosticsBuilderProgram (
333+ rootNames ,
334+ patchCompilerOptions ( options ?? { } , patchOptions ) ,
335+ ...args ,
336+ )
337+ }
326338}
0 commit comments