@@ -241,7 +241,7 @@ export class CompilationResult {
241241 }
242242}
243243
244- export function compileFiles ( host : fakes . CompilerHost , rootFiles : string [ ] | undefined , compilerOptions : ts . CompilerOptions , typeScriptVersion ?: string ) : CompilationResult {
244+ export function compileFiles ( host : fakes . CompilerHost , rootFiles : string [ ] | undefined , compilerOptions : ts . CompilerOptions , typeScriptVersion ?: string , captureSuggestions ?: boolean ) : CompilationResult {
245245 if ( compilerOptions . project || ! rootFiles || rootFiles . length === 0 ) {
246246 const project = readProject ( host . parseConfigHost , compilerOptions . project , compilerOptions ) ;
247247 if ( project ) {
@@ -265,11 +265,17 @@ export function compileFiles(host: fakes.CompilerHost, rootFiles: string[] | und
265265 // and if the test is running `skipLibCheck` - an indicator that we want the tets to run quickly - skip the before/after error comparison, too
266266 const skipErrorComparison = ts . length ( rootFiles ) >= 100 || ( ! ! compilerOptions . skipLibCheck && ! ! compilerOptions . declaration ) ;
267267 const preProgram = ! skipErrorComparison ? ts . createProgram ( { rootNames : rootFiles || [ ] , options : { ...compilerOptions , configFile : compilerOptions . configFile , traceResolution : false } , host, typeScriptVersion } ) : undefined ;
268- const preErrors = preProgram && ts . getPreEmitDiagnostics ( preProgram ) ;
268+ let preErrors = preProgram && ts . getPreEmitDiagnostics ( preProgram ) ;
269+ if ( preProgram && captureSuggestions ) {
270+ preErrors = ts . concatenate ( preErrors , ts . flatMap ( preProgram . getSourceFiles ( ) , f => preProgram . getSuggestionDiagnostics ( f ) ) ) ;
271+ }
269272
270273 const program = ts . createProgram ( { rootNames : rootFiles || [ ] , options : compilerOptions , host, typeScriptVersion } ) ;
271274 const emitResult = program . emit ( ) ;
272- const postErrors = ts . getPreEmitDiagnostics ( program ) ;
275+ let postErrors = ts . getPreEmitDiagnostics ( program ) ;
276+ if ( captureSuggestions ) {
277+ postErrors = ts . concatenate ( postErrors , ts . flatMap ( program . getSourceFiles ( ) , f => program . getSuggestionDiagnostics ( f ) ) ) ;
278+ }
273279 const longerErrors = ts . length ( preErrors ) > postErrors . length ? preErrors : postErrors ;
274280 const shorterErrors = longerErrors === preErrors ? postErrors : preErrors ;
275281 const errors = preErrors && ( preErrors . length !== postErrors . length ) ? [
0 commit comments