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" |
@@ -767,11 +774,17 @@ function getBinderAndCheckerDiagnosticsOfFile(state: BuilderProgramState, source
767774 return ts . filterSemanticDiagnostics ( diagnostics , state . compilerOptions ) ;
768775}
769776
777+ /** @internal */
770778export type ProgramBuildInfoFileId = number & { __programBuildInfoFileIdBrand : any } ;
779+ /** @internal */
771780export type ProgramBuildInfoFileIdListId = number & { __programBuildInfoFileIdListIdBrand : any } ;
781+ /** @internal */
772782export type ProgramBuildInfoDiagnostic = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , diagnostics : readonly ReusableDiagnostic [ ] ] ;
783+ /** @internal */
773784export type ProgramBuilderInfoFilePendingEmit = [ fileId : ProgramBuildInfoFileId , emitKind : BuilderFileEmit ] ;
785+ /** @internal */
774786export type ProgramBuildInfoReferencedMap = [ fileId : ProgramBuildInfoFileId , fileIdListId : ProgramBuildInfoFileIdListId ] [ ] ;
787+ /** @internal */
775788export type ProgramBuildInfoBuilderStateFileInfo = Omit < ts . BuilderState . FileInfo , "signature" > & {
776789 /**
777790 * Signature is
@@ -781,15 +794,18 @@ export type ProgramBuildInfoBuilderStateFileInfo = Omit<ts.BuilderState.FileInfo
781794 */
782795 signature : string | false | undefined ;
783796} ;
797+ /** @internal */
784798/**
785799 * [fileId, signature] if different from file's signature
786800 * fileId if file wasnt emitted
787801 */
788802export type ProgramBuildInfoEmitSignature = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , signature : string ] ;
803+ /** @internal */
789804/**
790805 * ProgramBuildInfoFileInfo is string if FileInfo.version === FileInfo.signature && !FileInfo.affectsGlobalScope otherwise encoded FileInfo
791806 */
792807export type ProgramBuildInfoFileInfo = string | ProgramBuildInfoBuilderStateFileInfo ;
808+ /** @internal */
793809export interface ProgramMultiFileEmitBuildInfo {
794810 fileNames : readonly string [ ] ;
795811 fileInfos : readonly ProgramBuildInfoFileInfo [ ] ;
@@ -805,6 +821,7 @@ export interface ProgramMultiFileEmitBuildInfo {
805821 latestChangedDtsFile ?: string ;
806822}
807823
824+ /** @internal */
808825export interface ProgramBundleEmitBuildInfo {
809826 fileNames : readonly string [ ] ;
810827 fileInfos : readonly string [ ] ;
@@ -813,8 +830,10 @@ export interface ProgramBundleEmitBuildInfo {
813830 latestChangedDtsFile ?: string ;
814831}
815832
833+ /** @internal */
816834export type ProgramBuildInfo = ProgramMultiFileEmitBuildInfo | ProgramBundleEmitBuildInfo ;
817835
836+ /** @internal */
818837export function isProgramBundleEmitBuildInfo ( info : ProgramBuildInfo ) : info is ProgramBundleEmitBuildInfo {
819838 return ! ! ts . outFile ( info . options || { } ) ;
820839}
@@ -1039,18 +1058,21 @@ function convertToReusableDiagnosticRelatedInformation(diagnostic: ts.Diagnostic
10391058 } ;
10401059}
10411060
1061+ /** @internal */
10421062export enum BuilderProgramKind {
10431063 SemanticDiagnosticsBuilderProgram ,
10441064 EmitAndSemanticDiagnosticsBuilderProgram
10451065}
10461066
1067+ /** @internal */
10471068export interface BuilderCreationParameters {
10481069 newProgram : ts . Program ;
10491070 host : ts . BuilderProgramHost ;
10501071 oldProgram : ts . BuilderProgram | undefined ;
10511072 configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ;
10521073}
10531074
1075+ /** @internal */
10541076export 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 {
10551077 let host : ts . BuilderProgramHost ;
10561078 let newProgram : ts . Program ;
@@ -1087,6 +1109,7 @@ function getTextHandlingSourceMapForSignature(text: string, data: ts.WriteFileCa
10871109 return data ?. sourceMapUrlPos !== undefined ? text . substring ( 0 , data . sourceMapUrlPos ) : text ;
10881110}
10891111
1112+ /** @internal */
10901113export function computeSignatureWithDiagnostics (
10911114 sourceFile : ts . SourceFile ,
10921115 text : string ,
@@ -1120,12 +1143,16 @@ export function computeSignatureWithDiagnostics(
11201143 }
11211144}
11221145
1146+ /** @internal */
11231147export function computeSignature ( text : string , computeHash : ts . BuilderState . ComputeHash | undefined , data ?: ts . WriteFileCallbackData ) {
11241148 return ( computeHash ?? ts . generateDjb2Hash ) ( getTextHandlingSourceMapForSignature ( text , data ) ) ;
11251149}
11261150
1151+ /** @internal */
11271152export function createBuilderProgram ( kind : BuilderProgramKind . SemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . SemanticDiagnosticsBuilderProgram ;
1153+ /** @internal */
11281154export function createBuilderProgram ( kind : BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . EmitAndSemanticDiagnosticsBuilderProgram ;
1155+ /** @internal */
11291156export function createBuilderProgram ( kind : BuilderProgramKind , { newProgram, host, oldProgram, configFileParsingDiagnostics } : BuilderCreationParameters ) {
11301157 // Return same program if underlying program doesnt change
11311158 let oldState = oldProgram && oldProgram . getState ( ) ;
@@ -1467,6 +1494,7 @@ function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFileP
14671494 }
14681495}
14691496
1497+ /** @internal */
14701498export function toBuilderStateFileInfo ( fileInfo : ProgramBuildInfoFileInfo ) : ts . BuilderState . FileInfo {
14711499 return ts . isString ( fileInfo ) ?
14721500 { version : fileInfo , signature : fileInfo , affectsGlobalScope : undefined , impliedFormat : undefined } :
@@ -1475,6 +1503,7 @@ export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): ts.B
14751503 { version : fileInfo . version , signature : fileInfo . signature === false ? undefined : fileInfo . version , affectsGlobalScope : fileInfo . affectsGlobalScope , impliedFormat : fileInfo . impliedFormat } ;
14761504}
14771505
1506+ /** @internal */
14781507export function createBuilderProgramUsingProgramBuildInfo ( program : ProgramBuildInfo , buildInfoPath : string , host : ts . ReadBuildProgramHost ) : ts . EmitAndSemanticDiagnosticsBuilderProgram {
14791508 const buildInfoDirectory = ts . getDirectoryPath ( ts . getNormalizedAbsolutePath ( buildInfoPath , host . getCurrentDirectory ( ) ) ) ;
14801509 const getCanonicalFileName = ts . createGetCanonicalFileName ( host . useCaseSensitiveFileNames ( ) ) ;
@@ -1577,6 +1606,7 @@ export function createBuilderProgramUsingProgramBuildInfo(program: ProgramBuildI
15771606 }
15781607}
15791608
1609+ /** @internal */
15801610export function getBuildInfoFileVersionMap (
15811611 program : ProgramBuildInfo ,
15821612 buildInfoPath : string ,
@@ -1593,6 +1623,7 @@ export function getBuildInfoFileVersionMap(
15931623 return fileInfos ;
15941624}
15951625
1626+ /** @internal */
15961627export function createRedirectedBuilderProgram ( getState : ( ) => { program ?: ts . Program | undefined ; compilerOptions : ts . CompilerOptions ; } , configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ) : ts . BuilderProgram {
15971628 return {
15981629 getState : ts . notImplemented ,
@@ -1621,4 +1652,3 @@ export function createRedirectedBuilderProgram(getState: () => { program?: ts.Pr
16211652 return ts . Debug . checkDefined ( getState ( ) . program ) ;
16221653 }
16231654}
1624- }
0 commit comments