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