1
- /*@internal */
2
- namespace ts {
1
+ import * as ts from "./_namespaces/ts" ;
2
+
3
+ /** @internal */
3
4
export interface ReusableDiagnostic extends ReusableDiagnosticRelatedInformation {
4
5
/** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */
5
6
reportsUnnecessary ?: { } ;
@@ -9,6 +10,7 @@ export interface ReusableDiagnostic extends ReusableDiagnosticRelatedInformation
9
10
skippedOn ?: keyof ts . CompilerOptions ;
10
11
}
11
12
13
+ /** @internal */
12
14
export interface ReusableDiagnosticRelatedInformation {
13
15
category : ts . DiagnosticCategory ;
14
16
code : number ;
@@ -18,8 +20,10 @@ export interface ReusableDiagnosticRelatedInformation {
18
20
messageText : string | ReusableDiagnosticMessageChain ;
19
21
}
20
22
23
+ /** @internal */
21
24
export type ReusableDiagnosticMessageChain = ts . DiagnosticMessageChain ;
22
25
26
+ /** @internal */
23
27
export interface ReusableBuilderProgramState extends ts . BuilderState {
24
28
/**
25
29
* Cache of bind and check diagnostics for files with their Path being the key
@@ -67,11 +71,13 @@ export interface ReusableBuilderProgramState extends ts.BuilderState {
67
71
latestChangedDtsFile : string | undefined ;
68
72
}
69
73
74
+ /** @internal */
70
75
export const enum BuilderFileEmit {
71
76
DtsOnly ,
72
77
Full
73
78
}
74
79
80
+ /** @internal */
75
81
/**
76
82
* State to store the changed files, affected files and cache semantic diagnostics
77
83
*/
@@ -133,6 +139,7 @@ export interface BuilderProgramState extends ts.BuilderState, ReusableBuilderPro
133
139
filesChangingSignature ?: ts . Set < ts . Path > ;
134
140
}
135
141
142
+ /** @internal */
136
143
export type SavedBuildProgramEmitState = Pick < BuilderProgramState ,
137
144
"affectedFilesPendingEmit" |
138
145
"affectedFilesPendingEmitIndex" |
@@ -767,11 +774,17 @@ function getBinderAndCheckerDiagnosticsOfFile(state: BuilderProgramState, source
767
774
return ts . filterSemanticDiagnostics ( diagnostics , state . compilerOptions ) ;
768
775
}
769
776
777
+ /** @internal */
770
778
export type ProgramBuildInfoFileId = number & { __programBuildInfoFileIdBrand : any } ;
779
+ /** @internal */
771
780
export type ProgramBuildInfoFileIdListId = number & { __programBuildInfoFileIdListIdBrand : any } ;
781
+ /** @internal */
772
782
export type ProgramBuildInfoDiagnostic = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , diagnostics : readonly ReusableDiagnostic [ ] ] ;
783
+ /** @internal */
773
784
export type ProgramBuilderInfoFilePendingEmit = [ fileId : ProgramBuildInfoFileId , emitKind : BuilderFileEmit ] ;
785
+ /** @internal */
774
786
export type ProgramBuildInfoReferencedMap = [ fileId : ProgramBuildInfoFileId , fileIdListId : ProgramBuildInfoFileIdListId ] [ ] ;
787
+ /** @internal */
775
788
export type ProgramBuildInfoBuilderStateFileInfo = Omit < ts . BuilderState . FileInfo , "signature" > & {
776
789
/**
777
790
* Signature is
@@ -781,15 +794,18 @@ export type ProgramBuildInfoBuilderStateFileInfo = Omit<ts.BuilderState.FileInfo
781
794
*/
782
795
signature : string | false | undefined ;
783
796
} ;
797
+ /** @internal */
784
798
/**
785
799
* [fileId, signature] if different from file's signature
786
800
* fileId if file wasnt emitted
787
801
*/
788
802
export type ProgramBuildInfoEmitSignature = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , signature : string ] ;
803
+ /** @internal */
789
804
/**
790
805
* ProgramBuildInfoFileInfo is string if FileInfo.version === FileInfo.signature && !FileInfo.affectsGlobalScope otherwise encoded FileInfo
791
806
*/
792
807
export type ProgramBuildInfoFileInfo = string | ProgramBuildInfoBuilderStateFileInfo ;
808
+ /** @internal */
793
809
export interface ProgramMultiFileEmitBuildInfo {
794
810
fileNames : readonly string [ ] ;
795
811
fileInfos : readonly ProgramBuildInfoFileInfo [ ] ;
@@ -805,6 +821,7 @@ export interface ProgramMultiFileEmitBuildInfo {
805
821
latestChangedDtsFile ?: string ;
806
822
}
807
823
824
+ /** @internal */
808
825
export interface ProgramBundleEmitBuildInfo {
809
826
fileNames : readonly string [ ] ;
810
827
fileInfos : readonly string [ ] ;
@@ -813,8 +830,10 @@ export interface ProgramBundleEmitBuildInfo {
813
830
latestChangedDtsFile ?: string ;
814
831
}
815
832
833
+ /** @internal */
816
834
export type ProgramBuildInfo = ProgramMultiFileEmitBuildInfo | ProgramBundleEmitBuildInfo ;
817
835
836
+ /** @internal */
818
837
export function isProgramBundleEmitBuildInfo ( info : ProgramBuildInfo ) : info is ProgramBundleEmitBuildInfo {
819
838
return ! ! ts . outFile ( info . options || { } ) ;
820
839
}
@@ -1039,18 +1058,21 @@ function convertToReusableDiagnosticRelatedInformation(diagnostic: ts.Diagnostic
1039
1058
} ;
1040
1059
}
1041
1060
1061
+ /** @internal */
1042
1062
export enum BuilderProgramKind {
1043
1063
SemanticDiagnosticsBuilderProgram ,
1044
1064
EmitAndSemanticDiagnosticsBuilderProgram
1045
1065
}
1046
1066
1067
+ /** @internal */
1047
1068
export interface BuilderCreationParameters {
1048
1069
newProgram : ts . Program ;
1049
1070
host : ts . BuilderProgramHost ;
1050
1071
oldProgram : ts . BuilderProgram | undefined ;
1051
1072
configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ;
1052
1073
}
1053
1074
1075
+ /** @internal */
1054
1076
export 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 {
1055
1077
let host : ts . BuilderProgramHost ;
1056
1078
let newProgram : ts . Program ;
@@ -1087,6 +1109,7 @@ function getTextHandlingSourceMapForSignature(text: string, data: ts.WriteFileCa
1087
1109
return data ?. sourceMapUrlPos !== undefined ? text . substring ( 0 , data . sourceMapUrlPos ) : text ;
1088
1110
}
1089
1111
1112
+ /** @internal */
1090
1113
export function computeSignatureWithDiagnostics (
1091
1114
sourceFile : ts . SourceFile ,
1092
1115
text : string ,
@@ -1120,12 +1143,16 @@ export function computeSignatureWithDiagnostics(
1120
1143
}
1121
1144
}
1122
1145
1146
+ /** @internal */
1123
1147
export function computeSignature ( text : string , computeHash : ts . BuilderState . ComputeHash | undefined , data ?: ts . WriteFileCallbackData ) {
1124
1148
return ( computeHash ?? ts . generateDjb2Hash ) ( getTextHandlingSourceMapForSignature ( text , data ) ) ;
1125
1149
}
1126
1150
1151
+ /** @internal */
1127
1152
export function createBuilderProgram ( kind : BuilderProgramKind . SemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . SemanticDiagnosticsBuilderProgram ;
1153
+ /** @internal */
1128
1154
export function createBuilderProgram ( kind : BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . EmitAndSemanticDiagnosticsBuilderProgram ;
1155
+ /** @internal */
1129
1156
export function createBuilderProgram ( kind : BuilderProgramKind , { newProgram, host, oldProgram, configFileParsingDiagnostics } : BuilderCreationParameters ) {
1130
1157
// Return same program if underlying program doesnt change
1131
1158
let oldState = oldProgram && oldProgram . getState ( ) ;
@@ -1467,6 +1494,7 @@ function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFileP
1467
1494
}
1468
1495
}
1469
1496
1497
+ /** @internal */
1470
1498
export function toBuilderStateFileInfo ( fileInfo : ProgramBuildInfoFileInfo ) : ts . BuilderState . FileInfo {
1471
1499
return ts . isString ( fileInfo ) ?
1472
1500
{ version : fileInfo , signature : fileInfo , affectsGlobalScope : undefined , impliedFormat : undefined } :
@@ -1475,6 +1503,7 @@ export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): ts.B
1475
1503
{ version : fileInfo . version , signature : fileInfo . signature === false ? undefined : fileInfo . version , affectsGlobalScope : fileInfo . affectsGlobalScope , impliedFormat : fileInfo . impliedFormat } ;
1476
1504
}
1477
1505
1506
+ /** @internal */
1478
1507
export function createBuilderProgramUsingProgramBuildInfo ( program : ProgramBuildInfo , buildInfoPath : string , host : ts . ReadBuildProgramHost ) : ts . EmitAndSemanticDiagnosticsBuilderProgram {
1479
1508
const buildInfoDirectory = ts . getDirectoryPath ( ts . getNormalizedAbsolutePath ( buildInfoPath , host . getCurrentDirectory ( ) ) ) ;
1480
1509
const getCanonicalFileName = ts . createGetCanonicalFileName ( host . useCaseSensitiveFileNames ( ) ) ;
@@ -1577,6 +1606,7 @@ export function createBuilderProgramUsingProgramBuildInfo(program: ProgramBuildI
1577
1606
}
1578
1607
}
1579
1608
1609
+ /** @internal */
1580
1610
export function getBuildInfoFileVersionMap (
1581
1611
program : ProgramBuildInfo ,
1582
1612
buildInfoPath : string ,
@@ -1593,6 +1623,7 @@ export function getBuildInfoFileVersionMap(
1593
1623
return fileInfos ;
1594
1624
}
1595
1625
1626
+ /** @internal */
1596
1627
export function createRedirectedBuilderProgram ( getState : ( ) => { program ?: ts . Program | undefined ; compilerOptions : ts . CompilerOptions ; } , configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ) : ts . BuilderProgram {
1597
1628
return {
1598
1629
getState : ts . notImplemented ,
@@ -1621,4 +1652,3 @@ export function createRedirectedBuilderProgram(getState: () => { program?: ts.Pr
1621
1652
return ts . Debug . checkDefined ( getState ( ) . program ) ;
1622
1653
}
1623
1654
}
1624
- }
0 commit comments