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 = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId ] ;
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 | undefined ;
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 | undefined ;
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}
@@ -1044,18 +1063,21 @@ function convertToReusableDiagnosticRelatedInformation(diagnostic: ts.Diagnostic
10441063 } ;
10451064}
10461065
1066+ /** @internal */
10471067export enum BuilderProgramKind {
10481068 SemanticDiagnosticsBuilderProgram ,
10491069 EmitAndSemanticDiagnosticsBuilderProgram
10501070}
10511071
1072+ /** @internal */
10521073export interface BuilderCreationParameters {
10531074 newProgram : ts . Program ;
10541075 host : ts . BuilderProgramHost ;
10551076 oldProgram : ts . BuilderProgram | undefined ;
10561077 configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ;
10571078}
10581079
1080+ /** @internal */
10591081export 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 {
10601082 let host : ts . BuilderProgramHost ;
10611083 let newProgram : ts . Program ;
@@ -1092,6 +1114,7 @@ function getTextHandlingSourceMapForSignature(text: string, data: ts.WriteFileCa
10921114 return data ?. sourceMapUrlPos !== undefined ? text . substring ( 0 , data . sourceMapUrlPos ) : text ;
10931115}
10941116
1117+ /** @internal */
10951118export function computeSignatureWithDiagnostics (
10961119 sourceFile : ts . SourceFile ,
10971120 text : string ,
@@ -1125,12 +1148,16 @@ export function computeSignatureWithDiagnostics(
11251148 }
11261149}
11271150
1151+ /** @internal */
11281152export function computeSignature ( text : string , computeHash : ts . BuilderState . ComputeHash | undefined , data ?: ts . WriteFileCallbackData ) {
11291153 return ( computeHash ?? ts . generateDjb2Hash ) ( getTextHandlingSourceMapForSignature ( text , data ) ) ;
11301154}
11311155
1156+ /** @internal */
11321157export function createBuilderProgram ( kind : BuilderProgramKind . SemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . SemanticDiagnosticsBuilderProgram ;
1158+ /** @internal */
11331159export function createBuilderProgram ( kind : BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . EmitAndSemanticDiagnosticsBuilderProgram ;
1160+ /** @internal */
11341161export function createBuilderProgram ( kind : BuilderProgramKind , { newProgram, host, oldProgram, configFileParsingDiagnostics } : BuilderCreationParameters ) {
11351162 // Return same program if underlying program doesnt change
11361163 let oldState = oldProgram && oldProgram . getState ( ) ;
@@ -1472,6 +1499,7 @@ function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFileP
14721499 }
14731500}
14741501
1502+ /** @internal */
14751503export function toBuilderStateFileInfo ( fileInfo : ProgramBuildInfoFileInfo ) : ts . BuilderState . FileInfo {
14761504 return ts . isString ( fileInfo ) ?
14771505 { version : fileInfo , signature : fileInfo , affectsGlobalScope : undefined , impliedFormat : undefined } :
@@ -1480,10 +1508,12 @@ export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): ts.B
14801508 { version : fileInfo . version , signature : fileInfo . signature === false ? undefined : fileInfo . version , affectsGlobalScope : fileInfo . affectsGlobalScope , impliedFormat : fileInfo . impliedFormat } ;
14811509}
14821510
1511+ /** @internal */
14831512export function toBuilderFileEmit ( value : ProgramBuilderInfoFilePendingEmit ) : BuilderFileEmit {
14841513 return ts . isNumber ( value ) ? BuilderFileEmit . Full : BuilderFileEmit . DtsOnly ;
14851514}
14861515
1516+ /** @internal */
14871517export function createBuilderProgramUsingProgramBuildInfo ( program : ProgramBuildInfo , buildInfoPath : string , host : ts . ReadBuildProgramHost ) : ts . EmitAndSemanticDiagnosticsBuilderProgram {
14881518 const buildInfoDirectory = ts . getDirectoryPath ( ts . getNormalizedAbsolutePath ( buildInfoPath , host . getCurrentDirectory ( ) ) ) ;
14891519 const getCanonicalFileName = ts . createGetCanonicalFileName ( host . useCaseSensitiveFileNames ( ) ) ;
@@ -1586,6 +1616,7 @@ export function createBuilderProgramUsingProgramBuildInfo(program: ProgramBuildI
15861616 }
15871617}
15881618
1619+ /** @internal */
15891620export function getBuildInfoFileVersionMap (
15901621 program : ProgramBuildInfo ,
15911622 buildInfoPath : string ,
@@ -1602,6 +1633,7 @@ export function getBuildInfoFileVersionMap(
16021633 return fileInfos ;
16031634}
16041635
1636+ /** @internal */
16051637export function createRedirectedBuilderProgram ( getState : ( ) => { program ?: ts . Program | undefined ; compilerOptions : ts . CompilerOptions ; } , configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ) : ts . BuilderProgram {
16061638 return {
16071639 getState : ts . notImplemented ,
@@ -1630,4 +1662,3 @@ export function createRedirectedBuilderProgram(getState: () => { program?: ts.Pr
16301662 return ts . Debug . checkDefined ( getState ( ) . program ) ;
16311663 }
16321664}
1633- }
0 commit comments