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 = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId ] ;
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 | undefined ;
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 | undefined ;
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
}
@@ -1044,18 +1063,21 @@ function convertToReusableDiagnosticRelatedInformation(diagnostic: ts.Diagnostic
1044
1063
} ;
1045
1064
}
1046
1065
1066
+ /** @internal */
1047
1067
export enum BuilderProgramKind {
1048
1068
SemanticDiagnosticsBuilderProgram ,
1049
1069
EmitAndSemanticDiagnosticsBuilderProgram
1050
1070
}
1051
1071
1072
+ /** @internal */
1052
1073
export interface BuilderCreationParameters {
1053
1074
newProgram : ts . Program ;
1054
1075
host : ts . BuilderProgramHost ;
1055
1076
oldProgram : ts . BuilderProgram | undefined ;
1056
1077
configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ;
1057
1078
}
1058
1079
1080
+ /** @internal */
1059
1081
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 {
1060
1082
let host : ts . BuilderProgramHost ;
1061
1083
let newProgram : ts . Program ;
@@ -1092,6 +1114,7 @@ function getTextHandlingSourceMapForSignature(text: string, data: ts.WriteFileCa
1092
1114
return data ?. sourceMapUrlPos !== undefined ? text . substring ( 0 , data . sourceMapUrlPos ) : text ;
1093
1115
}
1094
1116
1117
+ /** @internal */
1095
1118
export function computeSignatureWithDiagnostics (
1096
1119
sourceFile : ts . SourceFile ,
1097
1120
text : string ,
@@ -1125,12 +1148,16 @@ export function computeSignatureWithDiagnostics(
1125
1148
}
1126
1149
}
1127
1150
1151
+ /** @internal */
1128
1152
export function computeSignature ( text : string , computeHash : ts . BuilderState . ComputeHash | undefined , data ?: ts . WriteFileCallbackData ) {
1129
1153
return ( computeHash ?? ts . generateDjb2Hash ) ( getTextHandlingSourceMapForSignature ( text , data ) ) ;
1130
1154
}
1131
1155
1156
+ /** @internal */
1132
1157
export function createBuilderProgram ( kind : BuilderProgramKind . SemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . SemanticDiagnosticsBuilderProgram ;
1158
+ /** @internal */
1133
1159
export function createBuilderProgram ( kind : BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . EmitAndSemanticDiagnosticsBuilderProgram ;
1160
+ /** @internal */
1134
1161
export function createBuilderProgram ( kind : BuilderProgramKind , { newProgram, host, oldProgram, configFileParsingDiagnostics } : BuilderCreationParameters ) {
1135
1162
// Return same program if underlying program doesnt change
1136
1163
let oldState = oldProgram && oldProgram . getState ( ) ;
@@ -1472,6 +1499,7 @@ function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFileP
1472
1499
}
1473
1500
}
1474
1501
1502
+ /** @internal */
1475
1503
export function toBuilderStateFileInfo ( fileInfo : ProgramBuildInfoFileInfo ) : ts . BuilderState . FileInfo {
1476
1504
return ts . isString ( fileInfo ) ?
1477
1505
{ version : fileInfo , signature : fileInfo , affectsGlobalScope : undefined , impliedFormat : undefined } :
@@ -1480,10 +1508,12 @@ export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): ts.B
1480
1508
{ version : fileInfo . version , signature : fileInfo . signature === false ? undefined : fileInfo . version , affectsGlobalScope : fileInfo . affectsGlobalScope , impliedFormat : fileInfo . impliedFormat } ;
1481
1509
}
1482
1510
1511
+ /** @internal */
1483
1512
export function toBuilderFileEmit ( value : ProgramBuilderInfoFilePendingEmit ) : BuilderFileEmit {
1484
1513
return ts . isNumber ( value ) ? BuilderFileEmit . Full : BuilderFileEmit . DtsOnly ;
1485
1514
}
1486
1515
1516
+ /** @internal */
1487
1517
export function createBuilderProgramUsingProgramBuildInfo ( program : ProgramBuildInfo , buildInfoPath : string , host : ts . ReadBuildProgramHost ) : ts . EmitAndSemanticDiagnosticsBuilderProgram {
1488
1518
const buildInfoDirectory = ts . getDirectoryPath ( ts . getNormalizedAbsolutePath ( buildInfoPath , host . getCurrentDirectory ( ) ) ) ;
1489
1519
const getCanonicalFileName = ts . createGetCanonicalFileName ( host . useCaseSensitiveFileNames ( ) ) ;
@@ -1586,6 +1616,7 @@ export function createBuilderProgramUsingProgramBuildInfo(program: ProgramBuildI
1586
1616
}
1587
1617
}
1588
1618
1619
+ /** @internal */
1589
1620
export function getBuildInfoFileVersionMap (
1590
1621
program : ProgramBuildInfo ,
1591
1622
buildInfoPath : string ,
@@ -1602,6 +1633,7 @@ export function getBuildInfoFileVersionMap(
1602
1633
return fileInfos ;
1603
1634
}
1604
1635
1636
+ /** @internal */
1605
1637
export function createRedirectedBuilderProgram ( getState : ( ) => { program ?: ts . Program | undefined ; compilerOptions : ts . CompilerOptions ; } , configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ) : ts . BuilderProgram {
1606
1638
return {
1607
1639
getState : ts . notImplemented ,
@@ -1630,4 +1662,3 @@ export function createRedirectedBuilderProgram(getState: () => { program?: ts.Pr
1630
1662
return ts . Debug . checkDefined ( getState ( ) . program ) ;
1631
1663
}
1632
1664
}
1633
- }
0 commit comments