@@ -366,7 +366,7 @@ namespace ts {
366366
367367 // With --out or --outFile all outputs go into single file
368368 // so operations are performed directly on program, return program
369- const program = Debug . assertDefined ( state . program ) ;
369+ const program = Debug . checkDefined ( state . program ) ;
370370 const compilerOptions = program . getCompilerOptions ( ) ;
371371 if ( compilerOptions . outFile || compilerOptions . out ) {
372372 Debug . assert ( ! state . semanticDiagnosticsPerFile ) ;
@@ -393,10 +393,10 @@ namespace ts {
393393 if ( affectedFilesPendingEmit ) {
394394 const seenEmittedFiles = state . seenEmittedFiles || ( state . seenEmittedFiles = createMap ( ) ) ;
395395 for ( let i = state . affectedFilesPendingEmitIndex ! ; i < affectedFilesPendingEmit . length ; i ++ ) {
396- const affectedFile = Debug . assertDefined ( state . program ) . getSourceFileByPath ( affectedFilesPendingEmit [ i ] ) ;
396+ const affectedFile = Debug . checkDefined ( state . program ) . getSourceFileByPath ( affectedFilesPendingEmit [ i ] ) ;
397397 if ( affectedFile ) {
398398 const seenKind = seenEmittedFiles . get ( affectedFile . resolvedPath ) ;
399- const emitKind = Debug . assertDefined ( Debug . assertDefined ( state . affectedFilesPendingEmitKind ) . get ( affectedFile . resolvedPath ) ) ;
399+ const emitKind = Debug . checkDefined ( Debug . checkDefined ( state . affectedFilesPendingEmitKind ) . get ( affectedFile . resolvedPath ) ) ;
400400 if ( seenKind === undefined || seenKind < emitKind ) {
401401 // emit this file
402402 state . affectedFilesPendingEmitIndex = i ;
@@ -422,7 +422,7 @@ namespace ts {
422422 if ( state . allFilesExcludingDefaultLibraryFile === state . affectedFiles ) {
423423 if ( ! state . cleanedDiagnosticsOfLibFiles ) {
424424 state . cleanedDiagnosticsOfLibFiles = true ;
425- const program = Debug . assertDefined ( state . program ) ;
425+ const program = Debug . checkDefined ( state . program ) ;
426426 const options = program . getCompilerOptions ( ) ;
427427 forEach ( program . getSourceFiles ( ) , f =>
428428 program . isSourceFileDefaultLibrary ( f ) &&
@@ -446,7 +446,7 @@ namespace ts {
446446 removeSemanticDiagnosticsOf ( state , path ) ;
447447
448448 if ( ! state . changedFilesSet . has ( path ) ) {
449- const program = Debug . assertDefined ( state . program ) ;
449+ const program = Debug . checkDefined ( state . program ) ;
450450 const sourceFile = program . getSourceFileByPath ( path ) ;
451451 if ( sourceFile ) {
452452 // Even though the js emit doesnt change and we are already handling dts emit and semantic diagnostics
@@ -457,7 +457,7 @@ namespace ts {
457457 state ,
458458 program ,
459459 sourceFile ,
460- Debug . assertDefined ( state . currentAffectedFilesSignatures ) ,
460+ Debug . checkDefined ( state . currentAffectedFilesSignatures ) ,
461461 cancellationToken ,
462462 computeHash ,
463463 state . currentAffectedFilesExportedModulesMap
@@ -486,8 +486,8 @@ namespace ts {
486486 }
487487
488488 function isChangedSignagure ( state : BuilderProgramState , path : Path ) {
489- const newSignature = Debug . assertDefined ( state . currentAffectedFilesSignatures ) . get ( path ) ;
490- const oldSignagure = Debug . assertDefined ( state . fileInfos . get ( path ) ) . signature ;
489+ const newSignature = Debug . checkDefined ( state . currentAffectedFilesSignatures ) . get ( path ) ;
490+ const oldSignagure = Debug . checkDefined ( state . fileInfos . get ( path ) ) . signature ;
491491 return newSignature !== oldSignagure ;
492492 }
493493
@@ -515,7 +515,7 @@ namespace ts {
515515 seenFileNamesMap . set ( currentPath , true ) ;
516516 const result = fn ( state , currentPath ) ;
517517 if ( result && isChangedSignagure ( state , currentPath ) ) {
518- const currentSourceFile = Debug . assertDefined ( state . program ) . getSourceFileByPath ( currentPath ) ! ;
518+ const currentSourceFile = Debug . checkDefined ( state . program ) . getSourceFileByPath ( currentPath ) ! ;
519519 queue . push ( ...BuilderState . getReferencedByPaths ( state , currentSourceFile . resolvedPath ) ) ;
520520 }
521521 }
@@ -526,7 +526,7 @@ namespace ts {
526526 const seenFileAndExportsOfFile = createMap < true > ( ) ;
527527 // Go through exported modules from cache first
528528 // If exported modules has path, all files referencing file exported from are affected
529- if ( forEachEntry ( state . currentAffectedFilesExportedModulesMap ! , ( exportedModules , exportedFromPath ) =>
529+ if ( forEachEntry ( state . currentAffectedFilesExportedModulesMap , ( exportedModules , exportedFromPath ) =>
530530 exportedModules &&
531531 exportedModules . has ( affectedFile . resolvedPath ) &&
532532 forEachFilesReferencingPath ( state , exportedFromPath as Path , seenFileAndExportsOfFile , fn )
@@ -567,7 +567,7 @@ namespace ts {
567567 Debug . assert ( ! ! state . currentAffectedFilesExportedModulesMap ) ;
568568 // Go through exported modules from cache first
569569 // If exported modules has path, all files referencing file exported from are affected
570- if ( forEachEntry ( state . currentAffectedFilesExportedModulesMap ! , ( exportedModules , exportedFromPath ) =>
570+ if ( forEachEntry ( state . currentAffectedFilesExportedModulesMap , ( exportedModules , exportedFromPath ) =>
571571 exportedModules &&
572572 exportedModules . has ( filePath ) &&
573573 forEachFileAndExportsOfFile ( state , exportedFromPath as Path , seenFileAndExportsOfFile , fn )
@@ -655,7 +655,7 @@ namespace ts {
655655 function getSemanticDiagnosticsOfFile ( state : BuilderProgramState , sourceFile : SourceFile , cancellationToken ?: CancellationToken ) : readonly Diagnostic [ ] {
656656 return concatenate (
657657 getBinderAndCheckerDiagnosticsOfFile ( state , sourceFile , cancellationToken ) ,
658- Debug . assertDefined ( state . program ) . getProgramDiagnostics ( sourceFile )
658+ Debug . checkDefined ( state . program ) . getProgramDiagnostics ( sourceFile )
659659 ) ;
660660 }
661661
@@ -674,7 +674,7 @@ namespace ts {
674674 }
675675
676676 // Diagnostics werent cached, get them from program, and cache the result
677- const diagnostics = Debug . assertDefined ( state . program ) . getBindAndCheckDiagnostics ( sourceFile , cancellationToken ) ;
677+ const diagnostics = Debug . checkDefined ( state . program ) . getBindAndCheckDiagnostics ( sourceFile , cancellationToken ) ;
678678 if ( state . semanticDiagnosticsPerFile ) {
679679 state . semanticDiagnosticsPerFile . set ( path , diagnostics ) ;
680680 }
@@ -695,7 +695,7 @@ namespace ts {
695695 */
696696 function getProgramBuildInfo ( state : Readonly < ReusableBuilderProgramState > , getCanonicalFileName : GetCanonicalFileName ) : ProgramBuildInfo | undefined {
697697 if ( state . compilerOptions . outFile || state . compilerOptions . out ) return undefined ;
698- const currentDirectory = Debug . assertDefined ( state . program ) . getCurrentDirectory ( ) ;
698+ const currentDirectory = Debug . checkDefined ( state . program ) . getCurrentDirectory ( ) ;
699699 const buildInfoDirectory = getDirectoryPath ( getNormalizedAbsolutePath ( getTsBuildInfoEmitOutputFilePath ( state . compilerOptions ) ! , currentDirectory ) ) ;
700700 const fileInfos : MapLike < BuilderState . FileInfo > = { } ;
701701 state . fileInfos . forEach ( ( value , key ) => {
@@ -891,10 +891,10 @@ namespace ts {
891891 backupState = cloneBuilderProgramState ( state ) ;
892892 } ;
893893 builderProgram . restoreState = ( ) => {
894- state = Debug . assertDefined ( backupState ) ;
894+ state = Debug . checkDefined ( backupState ) ;
895895 backupState = undefined ;
896896 } ;
897- builderProgram . getAllDependencies = sourceFile => BuilderState . getAllDependencies ( state , Debug . assertDefined ( state . program ) , sourceFile ) ;
897+ builderProgram . getAllDependencies = sourceFile => BuilderState . getAllDependencies ( state , Debug . checkDefined ( state . program ) , sourceFile ) ;
898898 builderProgram . getSemanticDiagnostics = getSemanticDiagnostics ;
899899 builderProgram . emit = emit ;
900900 builderProgram . releaseProgram = ( ) => {
@@ -932,7 +932,7 @@ namespace ts {
932932 return undefined ;
933933 }
934934
935- const affected = Debug . assertDefined ( state . program ) ;
935+ const affected = Debug . checkDefined ( state . program ) ;
936936 return toAffectedFileEmitResult (
937937 state ,
938938 // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
@@ -948,7 +948,7 @@ namespace ts {
948948 isPendingEmitFile = true ;
949949 }
950950 else {
951- const program = Debug . assertDefined ( state . program ) ;
951+ const program = Debug . checkDefined ( state . program ) ;
952952 if ( state . programEmitComplete ) return undefined ;
953953 affected = program ;
954954 }
@@ -958,7 +958,7 @@ namespace ts {
958958 state ,
959959 // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
960960 // Otherwise just affected file
961- Debug . assertDefined ( state . program ) . emit (
961+ Debug . checkDefined ( state . program ) . emit (
962962 affected === state . program ? undefined : affected as SourceFile ,
963963 writeFile || maybeBind ( host , host . writeFile ) ,
964964 cancellationToken ,
@@ -1009,7 +1009,7 @@ namespace ts {
10091009 } ;
10101010 }
10111011 }
1012- return Debug . assertDefined ( state . program ) . emit ( targetSourceFile , writeFile || maybeBind ( host , host . writeFile ) , cancellationToken , emitOnlyDtsFiles , customTransformers ) ;
1012+ return Debug . checkDefined ( state . program ) . emit ( targetSourceFile , writeFile || maybeBind ( host , host . writeFile ) , cancellationToken , emitOnlyDtsFiles , customTransformers ) ;
10131013 }
10141014
10151015 /**
@@ -1062,11 +1062,11 @@ namespace ts {
10621062 */
10631063 function getSemanticDiagnostics ( sourceFile ?: SourceFile , cancellationToken ?: CancellationToken ) : readonly Diagnostic [ ] {
10641064 assertSourceFileOkWithoutNextAffectedCall ( state , sourceFile ) ;
1065- const compilerOptions = Debug . assertDefined ( state . program ) . getCompilerOptions ( ) ;
1065+ const compilerOptions = Debug . checkDefined ( state . program ) . getCompilerOptions ( ) ;
10661066 if ( compilerOptions . outFile || compilerOptions . out ) {
10671067 Debug . assert ( ! state . semanticDiagnosticsPerFile ) ;
10681068 // We dont need to cache the diagnostics just return them from program
1069- return Debug . assertDefined ( state . program ) . getSemanticDiagnostics ( sourceFile , cancellationToken ) ;
1069+ return Debug . checkDefined ( state . program ) . getSemanticDiagnostics ( sourceFile , cancellationToken ) ;
10701070 }
10711071
10721072 if ( sourceFile ) {
@@ -1080,7 +1080,7 @@ namespace ts {
10801080 }
10811081
10821082 let diagnostics : Diagnostic [ ] | undefined ;
1083- for ( const sourceFile of Debug . assertDefined ( state . program ) . getSourceFiles ( ) ) {
1083+ for ( const sourceFile of Debug . checkDefined ( state . program ) . getSourceFiles ( ) ) {
10841084 diagnostics = addRange ( diagnostics , getSemanticDiagnosticsOfFile ( state , sourceFile , cancellationToken ) ) ;
10851085 }
10861086 return diagnostics || emptyArray ;
@@ -1193,7 +1193,7 @@ namespace ts {
11931193 } ;
11941194
11951195 function getProgram ( ) {
1196- return Debug . assertDefined ( state . program ) ;
1196+ return Debug . checkDefined ( state . program ) ;
11971197 }
11981198 }
11991199}
0 commit comments