@@ -241,7 +241,7 @@ export class CompilationResult {
241
241
}
242
242
}
243
243
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 {
245
245
if ( compilerOptions . project || ! rootFiles || rootFiles . length === 0 ) {
246
246
const project = readProject ( host . parseConfigHost , compilerOptions . project , compilerOptions ) ;
247
247
if ( project ) {
@@ -265,11 +265,17 @@ export function compileFiles(host: fakes.CompilerHost, rootFiles: string[] | und
265
265
// and if the test is running `skipLibCheck` - an indicator that we want the tets to run quickly - skip the before/after error comparison, too
266
266
const skipErrorComparison = ts . length ( rootFiles ) >= 100 || ( ! ! compilerOptions . skipLibCheck && ! ! compilerOptions . declaration ) ;
267
267
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
+ }
269
272
270
273
const program = ts . createProgram ( { rootNames : rootFiles || [ ] , options : compilerOptions , host, typeScriptVersion } ) ;
271
274
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
+ }
273
279
const longerErrors = ts . length ( preErrors ) > postErrors . length ? preErrors : postErrors ;
274
280
const shorterErrors = longerErrors === preErrors ? postErrors : preErrors ;
275
281
const errors = preErrors && ( preErrors . length !== postErrors . length ) ? [
0 commit comments