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" |
@@ -761,11 +768,17 @@ function getBinderAndCheckerDiagnosticsOfFile(state: BuilderProgramState, source
761
768
return ts . filterSemanticDiagnostics ( diagnostics , state . compilerOptions ) ;
762
769
}
763
770
771
+ /** @internal */
764
772
export type ProgramBuildInfoFileId = number & { __programBuildInfoFileIdBrand : any } ;
773
+ /** @internal */
765
774
export type ProgramBuildInfoFileIdListId = number & { __programBuildInfoFileIdListIdBrand : any } ;
775
+ /** @internal */
766
776
export type ProgramBuildInfoDiagnostic = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , diagnostics : readonly ReusableDiagnostic [ ] ] ;
777
+ /** @internal */
767
778
export type ProgramBuilderInfoFilePendingEmit = [ fileId : ProgramBuildInfoFileId , emitKind : BuilderFileEmit ] ;
779
+ /** @internal */
768
780
export type ProgramBuildInfoReferencedMap = [ fileId : ProgramBuildInfoFileId , fileIdListId : ProgramBuildInfoFileIdListId ] [ ] ;
781
+ /** @internal */
769
782
export type ProgramBuildInfoBuilderStateFileInfo = Omit < ts . BuilderState . FileInfo , "signature" > & {
770
783
/**
771
784
* Signature is
@@ -775,15 +788,18 @@ export type ProgramBuildInfoBuilderStateFileInfo = Omit<ts.BuilderState.FileInfo
775
788
*/
776
789
signature : string | false | undefined ;
777
790
} ;
791
+ /** @internal */
778
792
/**
779
793
* [fileId, signature] if different from file's signature
780
794
* fileId if file wasnt emitted
781
795
*/
782
796
export type ProgramBuildInfoEmitSignature = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , signature : string ] ;
797
+ /** @internal */
783
798
/**
784
799
* ProgramBuildInfoFileInfo is string if FileInfo.version === FileInfo.signature && !FileInfo.affectsGlobalScope otherwise encoded FileInfo
785
800
*/
786
801
export type ProgramBuildInfoFileInfo = string | ProgramBuildInfoBuilderStateFileInfo ;
802
+ /** @internal */
787
803
export interface ProgramMultiFileEmitBuildInfo {
788
804
fileNames : readonly string [ ] ;
789
805
fileInfos : readonly ProgramBuildInfoFileInfo [ ] ;
@@ -799,6 +815,7 @@ export interface ProgramMultiFileEmitBuildInfo {
799
815
latestChangedDtsFile ?: string ;
800
816
}
801
817
818
+ /** @internal */
802
819
export interface ProgramBundleEmitBuildInfo {
803
820
fileNames : readonly string [ ] ;
804
821
fileInfos : readonly string [ ] ;
@@ -807,8 +824,10 @@ export interface ProgramBundleEmitBuildInfo {
807
824
latestChangedDtsFile ?: string ;
808
825
}
809
826
827
+ /** @internal */
810
828
export type ProgramBuildInfo = ProgramMultiFileEmitBuildInfo | ProgramBundleEmitBuildInfo ;
811
829
830
+ /** @internal */
812
831
export function isProgramBundleEmitBuildInfo ( info : ProgramBuildInfo ) : info is ProgramBundleEmitBuildInfo {
813
832
return ! ! ts . outFile ( info . options || { } ) ;
814
833
}
@@ -1033,18 +1052,21 @@ function convertToReusableDiagnosticRelatedInformation(diagnostic: ts.Diagnostic
1033
1052
} ;
1034
1053
}
1035
1054
1055
+ /** @internal */
1036
1056
export enum BuilderProgramKind {
1037
1057
SemanticDiagnosticsBuilderProgram ,
1038
1058
EmitAndSemanticDiagnosticsBuilderProgram
1039
1059
}
1040
1060
1061
+ /** @internal */
1041
1062
export interface BuilderCreationParameters {
1042
1063
newProgram : ts . Program ;
1043
1064
host : ts . BuilderProgramHost ;
1044
1065
oldProgram : ts . BuilderProgram | undefined ;
1045
1066
configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ;
1046
1067
}
1047
1068
1069
+ /** @internal */
1048
1070
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 {
1049
1071
let host : ts . BuilderProgramHost ;
1050
1072
let newProgram : ts . Program ;
@@ -1081,6 +1103,7 @@ function getTextHandlingSourceMapForSignature(text: string, data: ts.WriteFileCa
1081
1103
return data ?. sourceMapUrlPos !== undefined ? text . substring ( 0 , data . sourceMapUrlPos ) : text ;
1082
1104
}
1083
1105
1106
+ /** @internal */
1084
1107
export function computeSignatureWithDiagnostics (
1085
1108
sourceFile : ts . SourceFile ,
1086
1109
text : string ,
@@ -1114,12 +1137,16 @@ export function computeSignatureWithDiagnostics(
1114
1137
}
1115
1138
}
1116
1139
1140
+ /** @internal */
1117
1141
export function computeSignature ( text : string , computeHash : ts . BuilderState . ComputeHash | undefined , data ?: ts . WriteFileCallbackData ) {
1118
1142
return ( computeHash ?? ts . generateDjb2Hash ) ( getTextHandlingSourceMapForSignature ( text , data ) ) ;
1119
1143
}
1120
1144
1145
+ /** @internal */
1121
1146
export function createBuilderProgram ( kind : BuilderProgramKind . SemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . SemanticDiagnosticsBuilderProgram ;
1147
+ /** @internal */
1122
1148
export function createBuilderProgram ( kind : BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . EmitAndSemanticDiagnosticsBuilderProgram ;
1149
+ /** @internal */
1123
1150
export function createBuilderProgram ( kind : BuilderProgramKind , { newProgram, host, oldProgram, configFileParsingDiagnostics } : BuilderCreationParameters ) {
1124
1151
// Return same program if underlying program doesnt change
1125
1152
let oldState = oldProgram && oldProgram . getState ( ) ;
@@ -1461,6 +1488,7 @@ function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFileP
1461
1488
}
1462
1489
}
1463
1490
1491
+ /** @internal */
1464
1492
export function toBuilderStateFileInfo ( fileInfo : ProgramBuildInfoFileInfo ) : ts . BuilderState . FileInfo {
1465
1493
return ts . isString ( fileInfo ) ?
1466
1494
{ version : fileInfo , signature : fileInfo , affectsGlobalScope : undefined , impliedFormat : undefined } :
@@ -1469,6 +1497,7 @@ export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): ts.B
1469
1497
{ version : fileInfo . version , signature : fileInfo . signature === false ? undefined : fileInfo . version , affectsGlobalScope : fileInfo . affectsGlobalScope , impliedFormat : fileInfo . impliedFormat } ;
1470
1498
}
1471
1499
1500
+ /** @internal */
1472
1501
export function createBuilderProgramUsingProgramBuildInfo ( program : ProgramBuildInfo , buildInfoPath : string , host : ts . ReadBuildProgramHost ) : ts . EmitAndSemanticDiagnosticsBuilderProgram {
1473
1502
const buildInfoDirectory = ts . getDirectoryPath ( ts . getNormalizedAbsolutePath ( buildInfoPath , host . getCurrentDirectory ( ) ) ) ;
1474
1503
const getCanonicalFileName = ts . createGetCanonicalFileName ( host . useCaseSensitiveFileNames ( ) ) ;
@@ -1571,6 +1600,7 @@ export function createBuilderProgramUsingProgramBuildInfo(program: ProgramBuildI
1571
1600
}
1572
1601
}
1573
1602
1603
+ /** @internal */
1574
1604
export function getBuildInfoFileVersionMap (
1575
1605
program : ProgramBuildInfo ,
1576
1606
buildInfoPath : string ,
@@ -1587,6 +1617,7 @@ export function getBuildInfoFileVersionMap(
1587
1617
return fileInfos ;
1588
1618
}
1589
1619
1620
+ /** @internal */
1590
1621
export function createRedirectedBuilderProgram ( getState : ( ) => { program ?: ts . Program | undefined ; compilerOptions : ts . CompilerOptions ; } , configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ) : ts . BuilderProgram {
1591
1622
return {
1592
1623
getState : ts . notImplemented ,
@@ -1615,4 +1646,3 @@ export function createRedirectedBuilderProgram(getState: () => { program?: ts.Pr
1615
1646
return ts . Debug . checkDefined ( getState ( ) . program ) ;
1616
1647
}
1617
1648
}
1618
- }
0 commit comments