1- /*@internal */
2- namespace ts {
1+ import * as ts from "./_namespaces/ts" ;
2+
3+ /* @internal */
34export interface ReusableDiagnostic extends ReusableDiagnosticRelatedInformation {
45 /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */
56 reportsUnnecessary ?: { } ;
@@ -9,6 +10,7 @@ export interface ReusableDiagnostic extends ReusableDiagnosticRelatedInformation
910 skippedOn ?: keyof ts . CompilerOptions ;
1011}
1112
13+ /* @internal */
1214export interface ReusableDiagnosticRelatedInformation {
1315 category : ts . DiagnosticCategory ;
1416 code : number ;
@@ -18,8 +20,10 @@ export interface ReusableDiagnosticRelatedInformation {
1820 messageText : string | ReusableDiagnosticMessageChain ;
1921}
2022
23+ /* @internal */
2124export type ReusableDiagnosticMessageChain = ts . DiagnosticMessageChain ;
2225
26+ /* @internal */
2327export interface ReusableBuilderProgramState extends ts . BuilderState {
2428 /**
2529 * Cache of bind and check diagnostics for files with their Path being the key
@@ -67,11 +71,13 @@ export interface ReusableBuilderProgramState extends ts.BuilderState {
6771 latestChangedDtsFile : string | undefined ;
6872}
6973
74+ /* @internal */
7075export const enum BuilderFileEmit {
7176 DtsOnly ,
7277 Full
7378}
7479
80+ /* @internal */
7581/**
7682 * State to store the changed files, affected files and cache semantic diagnostics
7783 */
@@ -133,6 +139,7 @@ export interface BuilderProgramState extends ts.BuilderState, ReusableBuilderPro
133139 filesChangingSignature ?: ts . Set < ts . Path > ;
134140}
135141
142+ /* @internal */
136143export type SavedBuildProgramEmitState = Pick < BuilderProgramState ,
137144 "affectedFilesPendingEmit" |
138145 "affectedFilesPendingEmitIndex" |
@@ -761,11 +768,17 @@ function getBinderAndCheckerDiagnosticsOfFile(state: BuilderProgramState, source
761768 return ts . filterSemanticDiagnostics ( diagnostics , state . compilerOptions ) ;
762769}
763770
771+ /* @internal */
764772export type ProgramBuildInfoFileId = number & { __programBuildInfoFileIdBrand : any } ;
773+ /* @internal */
765774export type ProgramBuildInfoFileIdListId = number & { __programBuildInfoFileIdListIdBrand : any } ;
775+ /* @internal */
766776export type ProgramBuildInfoDiagnostic = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , diagnostics : readonly ReusableDiagnostic [ ] ] ;
777+ /* @internal */
767778export type ProgramBuilderInfoFilePendingEmit = [ fileId : ProgramBuildInfoFileId , emitKind : BuilderFileEmit ] ;
779+ /* @internal */
768780export type ProgramBuildInfoReferencedMap = [ fileId : ProgramBuildInfoFileId , fileIdListId : ProgramBuildInfoFileIdListId ] [ ] ;
781+ /* @internal */
769782export type ProgramBuildInfoBuilderStateFileInfo = Omit < ts . BuilderState . FileInfo , "signature" > & {
770783 /**
771784 * Signature is
@@ -775,15 +788,18 @@ export type ProgramBuildInfoBuilderStateFileInfo = Omit<ts.BuilderState.FileInfo
775788 */
776789 signature : string | false | undefined ;
777790} ;
791+ /* @internal */
778792/**
779793 * [fileId, signature] if different from file's signature
780794 * fileId if file wasnt emitted
781795 */
782796export type ProgramBuildInfoEmitSignature = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , signature : string ] ;
797+ /* @internal */
783798/**
784799 * ProgramBuildInfoFileInfo is string if FileInfo.version === FileInfo.signature && !FileInfo.affectsGlobalScope otherwise encoded FileInfo
785800 */
786801export type ProgramBuildInfoFileInfo = string | ProgramBuildInfoBuilderStateFileInfo ;
802+ /* @internal */
787803export interface ProgramMultiFileEmitBuildInfo {
788804 fileNames : readonly string [ ] ;
789805 fileInfos : readonly ProgramBuildInfoFileInfo [ ] ;
@@ -799,6 +815,7 @@ export interface ProgramMultiFileEmitBuildInfo {
799815 latestChangedDtsFile ?: string ;
800816}
801817
818+ /* @internal */
802819export interface ProgramBundleEmitBuildInfo {
803820 fileNames : readonly string [ ] ;
804821 fileInfos : readonly string [ ] ;
@@ -807,8 +824,10 @@ export interface ProgramBundleEmitBuildInfo {
807824 latestChangedDtsFile ?: string ;
808825}
809826
827+ /* @internal */
810828export type ProgramBuildInfo = ProgramMultiFileEmitBuildInfo | ProgramBundleEmitBuildInfo ;
811829
830+ /* @internal */
812831export function isProgramBundleEmitBuildInfo ( info : ProgramBuildInfo ) : info is ProgramBundleEmitBuildInfo {
813832 return ! ! ts . outFile ( info . options || { } ) ;
814833}
@@ -1033,18 +1052,21 @@ function convertToReusableDiagnosticRelatedInformation(diagnostic: ts.Diagnostic
10331052 } ;
10341053}
10351054
1055+ /* @internal */
10361056export enum BuilderProgramKind {
10371057 SemanticDiagnosticsBuilderProgram ,
10381058 EmitAndSemanticDiagnosticsBuilderProgram
10391059}
10401060
1061+ /* @internal */
10411062export interface BuilderCreationParameters {
10421063 newProgram : ts . Program ;
10431064 host : ts . BuilderProgramHost ;
10441065 oldProgram : ts . BuilderProgram | undefined ;
10451066 configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ;
10461067}
10471068
1069+ /* @internal */
10481070export function getBuilderCreationParameters ( newProgramOrRootNames : ts . Program | readonly string [ ] | undefined , hostOrOptions : ts . BuilderProgramHost | ts . CompilerOptions | undefined , oldProgramOrHost ?: ts . BuilderProgram | ts . CompilerHost , configFileParsingDiagnosticsOrOldProgram ?: readonly ts . Diagnostic [ ] | ts . BuilderProgram , configFileParsingDiagnostics ?: readonly ts . Diagnostic [ ] , projectReferences ?: readonly ts . ProjectReference [ ] ) : BuilderCreationParameters {
10491071 let host : ts . BuilderProgramHost ;
10501072 let newProgram : ts . Program ;
@@ -1081,6 +1103,7 @@ function getTextHandlingSourceMapForSignature(text: string, data: ts.WriteFileCa
10811103 return data ?. sourceMapUrlPos !== undefined ? text . substring ( 0 , data . sourceMapUrlPos ) : text ;
10821104}
10831105
1106+ /* @internal */
10841107export function computeSignatureWithDiagnostics (
10851108 sourceFile : ts . SourceFile ,
10861109 text : string ,
@@ -1114,12 +1137,16 @@ export function computeSignatureWithDiagnostics(
11141137 }
11151138}
11161139
1140+ /* @internal */
11171141export function computeSignature ( text : string , computeHash : ts . BuilderState . ComputeHash | undefined , data ?: ts . WriteFileCallbackData ) {
11181142 return ( computeHash ?? ts . generateDjb2Hash ) ( getTextHandlingSourceMapForSignature ( text , data ) ) ;
11191143}
11201144
1145+ /* @internal */
11211146export function createBuilderProgram ( kind : BuilderProgramKind . SemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . SemanticDiagnosticsBuilderProgram ;
1147+ /* @internal */
11221148export function createBuilderProgram ( kind : BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . EmitAndSemanticDiagnosticsBuilderProgram ;
1149+ /* @internal */
11231150export function createBuilderProgram ( kind : BuilderProgramKind , { newProgram, host, oldProgram, configFileParsingDiagnostics } : BuilderCreationParameters ) {
11241151 // Return same program if underlying program doesnt change
11251152 let oldState = oldProgram && oldProgram . getState ( ) ;
@@ -1461,6 +1488,7 @@ function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFileP
14611488 }
14621489}
14631490
1491+ /* @internal */
14641492export function toBuilderStateFileInfo ( fileInfo : ProgramBuildInfoFileInfo ) : ts . BuilderState . FileInfo {
14651493 return ts . isString ( fileInfo ) ?
14661494 { version : fileInfo , signature : fileInfo , affectsGlobalScope : undefined , impliedFormat : undefined } :
@@ -1469,6 +1497,7 @@ export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): ts.B
14691497 { version : fileInfo . version , signature : fileInfo . signature === false ? undefined : fileInfo . version , affectsGlobalScope : fileInfo . affectsGlobalScope , impliedFormat : fileInfo . impliedFormat } ;
14701498}
14711499
1500+ /* @internal */
14721501export function createBuilderProgramUsingProgramBuildInfo ( program : ProgramBuildInfo , buildInfoPath : string , host : ts . ReadBuildProgramHost ) : ts . EmitAndSemanticDiagnosticsBuilderProgram {
14731502 const buildInfoDirectory = ts . getDirectoryPath ( ts . getNormalizedAbsolutePath ( buildInfoPath , host . getCurrentDirectory ( ) ) ) ;
14741503 const getCanonicalFileName = ts . createGetCanonicalFileName ( host . useCaseSensitiveFileNames ( ) ) ;
@@ -1571,6 +1600,7 @@ export function createBuilderProgramUsingProgramBuildInfo(program: ProgramBuildI
15711600 }
15721601}
15731602
1603+ /* @internal */
15741604export function getBuildInfoFileVersionMap (
15751605 program : ProgramBuildInfo ,
15761606 buildInfoPath : string ,
@@ -1587,6 +1617,7 @@ export function getBuildInfoFileVersionMap(
15871617 return fileInfos ;
15881618}
15891619
1620+ /* @internal */
15901621export function createRedirectedBuilderProgram ( getState : ( ) => { program ?: ts . Program | undefined ; compilerOptions : ts . CompilerOptions ; } , configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ) : ts . BuilderProgram {
15911622 return {
15921623 getState : ts . notImplemented ,
@@ -1615,4 +1646,3 @@ export function createRedirectedBuilderProgram(getState: () => { program?: ts.Pr
16151646 return ts . Debug . checkDefined ( getState ( ) . program ) ;
16161647 }
16171648}
1618- }
0 commit comments