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 . ReusableBuilderState {
24
28
/**
25
29
* Cache of bind and check diagnostics for files with their Path being the key
@@ -76,11 +80,13 @@ export interface ReusableBuilderProgramState extends ts.ReusableBuilderState {
76
80
hasReusableDiagnostic ?: true ;
77
81
}
78
82
83
+ /* @internal */
79
84
export const enum BuilderFileEmit {
80
85
DtsOnly ,
81
86
Full
82
87
}
83
88
89
+ /* @internal */
84
90
/**
85
91
* State to store the changed files, affected files and cache semantic diagnostics
86
92
*/
@@ -773,11 +779,17 @@ function getBinderAndCheckerDiagnosticsOfFile(state: BuilderProgramState, source
773
779
return ts . filterSemanticDiagnostics ( diagnostics , state . compilerOptions ) ;
774
780
}
775
781
782
+ /* @internal */
776
783
export type ProgramBuildInfoFileId = number & { __programBuildInfoFileIdBrand : any } ;
784
+ /* @internal */
777
785
export type ProgramBuildInfoFileIdListId = number & { __programBuildInfoFileIdListIdBrand : any } ;
786
+ /* @internal */
778
787
export type ProgramBuildInfoDiagnostic = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , diagnostics : readonly ReusableDiagnostic [ ] ] ;
788
+ /* @internal */
779
789
export type ProgramBuilderInfoFilePendingEmit = [ fileId : ProgramBuildInfoFileId , emitKind : BuilderFileEmit ] ;
790
+ /* @internal */
780
791
export type ProgramBuildInfoReferencedMap = [ fileId : ProgramBuildInfoFileId , fileIdListId : ProgramBuildInfoFileIdListId ] [ ] ;
792
+ /* @internal */
781
793
export type ProgramBuildInfoBuilderStateFileInfo = Omit < ts . BuilderState . FileInfo , "signature" > & {
782
794
/**
783
795
* Signature is
@@ -787,10 +799,12 @@ export type ProgramBuildInfoBuilderStateFileInfo = Omit<ts.BuilderState.FileInfo
787
799
*/
788
800
signature : string | false | undefined ;
789
801
} ;
802
+ /* @internal */
790
803
/**
791
804
* ProgramBuildInfoFileInfo is string if FileInfo.version === FileInfo.signature && !FileInfo.affectsGlobalScope otherwise encoded FileInfo
792
805
*/
793
806
export type ProgramBuildInfoFileInfo = string | ProgramBuildInfoBuilderStateFileInfo ;
807
+ /* @internal */
794
808
export interface ProgramBuildInfo {
795
809
fileNames : readonly string [ ] ;
796
810
fileInfos : readonly ProgramBuildInfoFileInfo [ ] ;
@@ -993,18 +1007,21 @@ function convertToReusableDiagnosticRelatedInformation(diagnostic: ts.Diagnostic
993
1007
} ;
994
1008
}
995
1009
1010
+ /* @internal */
996
1011
export enum BuilderProgramKind {
997
1012
SemanticDiagnosticsBuilderProgram ,
998
1013
EmitAndSemanticDiagnosticsBuilderProgram
999
1014
}
1000
1015
1016
+ /* @internal */
1001
1017
export interface BuilderCreationParameters {
1002
1018
newProgram : ts . Program ;
1003
1019
host : ts . BuilderProgramHost ;
1004
1020
oldProgram : ts . BuilderProgram | undefined ;
1005
1021
configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ;
1006
1022
}
1007
1023
1024
+ /* @internal */
1008
1025
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 {
1009
1026
let host : ts . BuilderProgramHost ;
1010
1027
let newProgram : ts . Program ;
@@ -1037,8 +1054,11 @@ export function getBuilderCreationParameters(newProgramOrRootNames: ts.Program |
1037
1054
return { host, newProgram, oldProgram, configFileParsingDiagnostics : configFileParsingDiagnostics || ts . emptyArray } ;
1038
1055
}
1039
1056
1057
+ /* @internal */
1040
1058
export function createBuilderProgram ( kind : BuilderProgramKind . SemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . SemanticDiagnosticsBuilderProgram ;
1059
+ /* @internal */
1041
1060
export function createBuilderProgram ( kind : BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . EmitAndSemanticDiagnosticsBuilderProgram ;
1061
+ /* @internal */
1042
1062
export function createBuilderProgram ( kind : BuilderProgramKind , { newProgram, host, oldProgram, configFileParsingDiagnostics } : BuilderCreationParameters ) {
1043
1063
// Return same program if underlying program doesnt change
1044
1064
let oldState = oldProgram && oldProgram . getState ( ) ;
@@ -1351,6 +1371,7 @@ function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFileP
1351
1371
}
1352
1372
}
1353
1373
1374
+ /* @internal */
1354
1375
export function toBuilderStateFileInfo ( fileInfo : ProgramBuildInfoFileInfo ) : ts . BuilderState . FileInfo {
1355
1376
return ts . isString ( fileInfo ) ?
1356
1377
{ version : fileInfo , signature : fileInfo , affectsGlobalScope : undefined , impliedFormat : undefined } :
@@ -1359,6 +1380,7 @@ export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): ts.B
1359
1380
{ version : fileInfo . version , signature : fileInfo . signature === false ? undefined : fileInfo . version , affectsGlobalScope : fileInfo . affectsGlobalScope , impliedFormat : fileInfo . impliedFormat } ;
1360
1381
}
1361
1382
1383
+ /* @internal */
1362
1384
export function createBuildProgramUsingProgramBuildInfo ( program : ProgramBuildInfo , buildInfoPath : string , host : ts . ReadBuildProgramHost ) : ts . EmitAndSemanticDiagnosticsBuilderProgram {
1363
1385
const buildInfoDirectory = ts . getDirectoryPath ( ts . getNormalizedAbsolutePath ( buildInfoPath , host . getCurrentDirectory ( ) ) ) ;
1364
1386
const getCanonicalFileName = ts . createGetCanonicalFileName ( host . useCaseSensitiveFileNames ( ) ) ;
@@ -1432,6 +1454,7 @@ export function createBuildProgramUsingProgramBuildInfo(program: ProgramBuildInf
1432
1454
}
1433
1455
}
1434
1456
1457
+ /* @internal */
1435
1458
export function createRedirectedBuilderProgram ( getState : ( ) => { program : ts . Program | undefined ; compilerOptions : ts . CompilerOptions ; } , configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ) : ts . BuilderProgram {
1436
1459
return {
1437
1460
getState : ts . notImplemented ,
@@ -1460,4 +1483,3 @@ export function createRedirectedBuilderProgram(getState: () => { program: ts.Pro
1460
1483
return ts . Debug . checkDefined ( getState ( ) . program ) ;
1461
1484
}
1462
1485
}
1463
- }
0 commit comments