1- /*@internal */
2- namespace ts {
1+ import * as ts from "./_namespaces/ts" ;
2+
3+ /** @internal */
34export interface ReusableDiagnostic extends ReusableDiagnosticRelatedInformation {
45 /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */
56 reportsUnnecessary ?: { } ;
@@ -9,6 +10,7 @@ export interface ReusableDiagnostic extends ReusableDiagnosticRelatedInformation
910 skippedOn ?: keyof ts . CompilerOptions ;
1011}
1112
13+ /** @internal */
1214export interface ReusableDiagnosticRelatedInformation {
1315 category : ts . DiagnosticCategory ;
1416 code : number ;
@@ -18,11 +20,14 @@ export interface ReusableDiagnosticRelatedInformation {
1820 messageText : string | ReusableDiagnosticMessageChain ;
1921}
2022
23+ /** @internal */
2124export type ReusableDiagnosticMessageChain = ts . DiagnosticMessageChain ;
2225
26+ /** @internal */
2327/** Signature (Hash of d.ts emitted), is string if it was emitted using same d.ts.map option as what compilerOptions indicate, otherwise tuple of string */
2428export type EmitSignature = string | [ signature : string ] ;
2529
30+ /** @internal */
2631export interface ReusableBuilderProgramState extends ts . BuilderState {
2732 /**
2833 * Cache of bind and check diagnostics for files with their Path being the key
@@ -70,6 +75,7 @@ export interface ReusableBuilderProgramState extends ts.BuilderState {
7075 bundle ?: ts . BundleBuildInfo ;
7176}
7277
78+ /** @internal */
7379export const enum BuilderFileEmit {
7480 None = 0 ,
7581 Js = 1 << 0 , // emit js file
@@ -83,6 +89,7 @@ export const enum BuilderFileEmit {
8389 All = AllJs | AllDts ,
8490}
8591
92+ /** @internal */
8693/**
8794 * State to store the changed files, affected files and cache semantic diagnostics
8895 */
@@ -140,6 +147,7 @@ export interface BuilderProgramState extends ts.BuilderState, ReusableBuilderPro
140147 filesChangingSignature ?: ts . Set < ts . Path > ;
141148}
142149
150+ /** @internal */
143151export type SavedBuildProgramEmitState = Pick < BuilderProgramState ,
144152 "affectedFilesPendingEmit" |
145153 "seenEmittedFiles" |
@@ -150,6 +158,7 @@ export type SavedBuildProgramEmitState = Pick<BuilderProgramState,
150158 "hasChangedEmitSignature"
151159> & { changedFilesSet : BuilderProgramState [ "changedFilesSet" ] | undefined } ;
152160
161+ /** @internal */
153162/** Get flags determining what all needs to be emitted */
154163export function getBuilderFileEmit ( options : ts . CompilerOptions ) {
155164 let result = BuilderFileEmit . Js ;
@@ -161,6 +170,7 @@ export function getBuilderFileEmit(options: ts.CompilerOptions) {
161170 return result ;
162171}
163172
173+ /** @internal */
164174/** Determing what all is pending to be emitted based on previous options or previous file emit flags */
165175export function getPendingEmitKind ( optionsOrEmitKind : ts . CompilerOptions | BuilderFileEmit , oldOptionsOrEmitKind : ts . CompilerOptions | BuilderFileEmit | undefined ) : BuilderFileEmit {
166176 const oldEmitKind = oldOptionsOrEmitKind && ( ts . isNumber ( oldOptionsOrEmitKind ) ? oldOptionsOrEmitKind : getBuilderFileEmit ( oldOptionsOrEmitKind ) ) ;
@@ -789,16 +799,22 @@ function getBinderAndCheckerDiagnosticsOfFile(state: BuilderProgramState, source
789799 return ts . filterSemanticDiagnostics ( diagnostics , state . compilerOptions ) ;
790800}
791801
802+ /** @internal */
792803export type ProgramBuildInfoFileId = number & { __programBuildInfoFileIdBrand : any } ;
804+ /** @internal */
793805export type ProgramBuildInfoFileIdListId = number & { __programBuildInfoFileIdListIdBrand : any } ;
806+ /** @internal */
794807export type ProgramBuildInfoDiagnostic = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , diagnostics : readonly ReusableDiagnostic [ ] ] ;
808+ /** @internal */
795809/**
796810 * fileId if pending emit is same as what compilerOptions suggest
797811 * [fileId] if pending emit is only dts file emit
798812 * [fileId, emitKind] if any other type emit is pending
799813 */
800814export type ProgramBuilderInfoFilePendingEmit = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId ] | [ fileId : ProgramBuildInfoFileId , emitKind : BuilderFileEmit ] ;
815+ /** @internal */
801816export type ProgramBuildInfoReferencedMap = [ fileId : ProgramBuildInfoFileId , fileIdListId : ProgramBuildInfoFileIdListId ] [ ] ;
817+ /** @internal */
802818export type ProgramMultiFileEmitBuildInfoBuilderStateFileInfo = Omit < ts . BuilderState . FileInfo , "signature" > & {
803819 /**
804820 * Signature is
@@ -808,15 +824,18 @@ export type ProgramMultiFileEmitBuildInfoBuilderStateFileInfo = Omit<ts.BuilderS
808824 */
809825 signature : string | false | undefined ;
810826} ;
827+ /** @internal */
811828/**
812829 * [fileId, signature] if different from file's signature
813830 * fileId if file wasnt emitted
814831 */
815832export type ProgramBuildInfoEmitSignature = ProgramBuildInfoFileId | [ fileId : ProgramBuildInfoFileId , signature : EmitSignature | [ ] ] ;
833+ /** @internal */
816834/**
817835 * ProgramMultiFileEmitBuildInfoFileInfo is string if FileInfo.version === FileInfo.signature && !FileInfo.affectsGlobalScope otherwise encoded FileInfo
818836 */
819837export type ProgramMultiFileEmitBuildInfoFileInfo = string | ProgramMultiFileEmitBuildInfoBuilderStateFileInfo ;
838+ /** @internal */
820839export interface ProgramMultiFileEmitBuildInfo {
821840 fileNames : readonly string [ ] ;
822841 fileInfos : readonly ProgramMultiFileEmitBuildInfoFileInfo [ ] ;
@@ -831,15 +850,18 @@ export interface ProgramMultiFileEmitBuildInfo {
831850 // Because this is only output file in the program, we dont need fileId to deduplicate name
832851 latestChangedDtsFile ?: string | undefined ;
833852}
853+ /** @internal */
834854/**
835855 * ProgramBundleEmitBuildInfoFileInfo is string if !FileInfo.impliedFormat otherwise encoded FileInfo
836856 */
837857export type ProgramBundleEmitBuildInfoFileInfo = string | ts . BuilderState . FileInfo ;
858+ /** @internal */
838859/**
839860 * false if it is the emit corresponding to compilerOptions
840861 * value otherwise
841862 */
842863export type ProgramBuildInfoBundlePendingEmit = BuilderFileEmit | false ;
864+ /** @internal */
843865export interface ProgramBundleEmitBuildInfo {
844866 fileNames : readonly string [ ] ;
845867 fileInfos : readonly ProgramBundleEmitBuildInfoFileInfo [ ] ;
@@ -849,8 +871,10 @@ export interface ProgramBundleEmitBuildInfo {
849871 pendingEmit : ProgramBuildInfoBundlePendingEmit | undefined ;
850872}
851873
874+ /** @internal */
852875export type ProgramBuildInfo = ProgramMultiFileEmitBuildInfo | ProgramBundleEmitBuildInfo ;
853876
877+ /** @internal */
854878export function isProgramBundleEmitBuildInfo ( info : ProgramBuildInfo ) : info is ProgramBundleEmitBuildInfo {
855879 return ! ! ts . outFile ( info . options || { } ) ;
856880}
@@ -1100,18 +1124,21 @@ function convertToReusableDiagnosticRelatedInformation(diagnostic: ts.Diagnostic
11001124 } ;
11011125}
11021126
1127+ /** @internal */
11031128export enum BuilderProgramKind {
11041129 SemanticDiagnosticsBuilderProgram ,
11051130 EmitAndSemanticDiagnosticsBuilderProgram
11061131}
11071132
1133+ /** @internal */
11081134export interface BuilderCreationParameters {
11091135 newProgram : ts . Program ;
11101136 host : ts . BuilderProgramHost ;
11111137 oldProgram : ts . BuilderProgram | undefined ;
11121138 configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ;
11131139}
11141140
1141+ /** @internal */
11151142export 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 {
11161143 let host : ts . BuilderProgramHost ;
11171144 let newProgram : ts . Program ;
@@ -1148,6 +1175,7 @@ function getTextHandlingSourceMapForSignature(text: string, data: ts.WriteFileCa
11481175 return data ?. sourceMapUrlPos !== undefined ? text . substring ( 0 , data . sourceMapUrlPos ) : text ;
11491176}
11501177
1178+ /** @internal */
11511179export function computeSignatureWithDiagnostics (
11521180 sourceFile : ts . SourceFile ,
11531181 text : string ,
@@ -1181,12 +1209,16 @@ export function computeSignatureWithDiagnostics(
11811209 }
11821210}
11831211
1212+ /** @internal */
11841213export function computeSignature ( text : string , computeHash : ts . BuilderState . ComputeHash | undefined , data ?: ts . WriteFileCallbackData ) {
11851214 return ( computeHash ?? ts . generateDjb2Hash ) ( getTextHandlingSourceMapForSignature ( text , data ) ) ;
11861215}
11871216
1217+ /** @internal */
11881218export function createBuilderProgram ( kind : BuilderProgramKind . SemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . SemanticDiagnosticsBuilderProgram ;
1219+ /** @internal */
11891220export function createBuilderProgram ( kind : BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram , builderCreationParameters : BuilderCreationParameters ) : ts . EmitAndSemanticDiagnosticsBuilderProgram ;
1221+ /** @internal */
11901222export function createBuilderProgram ( kind : BuilderProgramKind , { newProgram, host, oldProgram, configFileParsingDiagnostics } : BuilderCreationParameters ) {
11911223 // Return same program if underlying program doesnt change
11921224 let oldState = oldProgram && oldProgram . getState ( ) ;
@@ -1530,6 +1562,7 @@ function addToAffectedFilesPendingEmit(state: BuilderProgramState, affectedFileP
15301562 ( state . affectedFilesPendingEmit ??= new ts . Map ( ) ) . set ( affectedFilePendingEmit , existingKind | kind ) ;
15311563}
15321564
1565+ /** @internal */
15331566export function toBuilderStateFileInfoForMultiEmit ( fileInfo : ProgramMultiFileEmitBuildInfoFileInfo ) : ts . BuilderState . FileInfo {
15341567 return ts . isString ( fileInfo ) ?
15351568 { version : fileInfo , signature : fileInfo , affectsGlobalScope : undefined , impliedFormat : undefined } :
@@ -1538,14 +1571,17 @@ export function toBuilderStateFileInfoForMultiEmit(fileInfo: ProgramMultiFileEmi
15381571 { version : fileInfo . version , signature : fileInfo . signature === false ? undefined : fileInfo . version , affectsGlobalScope : fileInfo . affectsGlobalScope , impliedFormat : fileInfo . impliedFormat } ;
15391572}
15401573
1574+ /** @internal */
15411575export function toBuilderFileEmit ( value : ProgramBuilderInfoFilePendingEmit , fullEmitForOptions : BuilderFileEmit ) : BuilderFileEmit {
15421576 return ts . isNumber ( value ) ? fullEmitForOptions : value [ 1 ] || BuilderFileEmit . Dts ;
15431577}
15441578
1579+ /** @internal */
15451580export function toProgramEmitPending ( value : ProgramBuildInfoBundlePendingEmit , options : ts . CompilerOptions | undefined ) : BuilderFileEmit | undefined {
15461581 return ! value ? getBuilderFileEmit ( options || { } ) : value ;
15471582}
15481583
1584+ /** @internal */
15491585export function createBuilderProgramUsingProgramBuildInfo ( buildInfo : ts . BuildInfo , buildInfoPath : string , host : ts . ReadBuildProgramHost ) : ts . EmitAndSemanticDiagnosticsBuilderProgram {
15501586 const program = buildInfo . program ! ;
15511587 const buildInfoDirectory = ts . getDirectoryPath ( ts . getNormalizedAbsolutePath ( buildInfoPath , host . getCurrentDirectory ( ) ) ) ;
@@ -1661,6 +1697,7 @@ export function createBuilderProgramUsingProgramBuildInfo(buildInfo: ts.BuildInf
16611697 }
16621698}
16631699
1700+ /** @internal */
16641701export function getBuildInfoFileVersionMap (
16651702 program : ProgramBuildInfo ,
16661703 buildInfoPath : string ,
@@ -1677,6 +1714,7 @@ export function getBuildInfoFileVersionMap(
16771714 return fileInfos ;
16781715}
16791716
1717+ /** @internal */
16801718export function createRedirectedBuilderProgram ( getState : ( ) => { program ?: ts . Program | undefined ; compilerOptions : ts . CompilerOptions ; } , configFileParsingDiagnostics : readonly ts . Diagnostic [ ] ) : ts . BuilderProgram {
16811719 return {
16821720 getState : ts . notImplemented ,
@@ -1705,4 +1743,3 @@ export function createRedirectedBuilderProgram(getState: () => { program?: ts.Pr
17051743 return ts . Debug . checkDefined ( getState ( ) . program ) ;
17061744 }
17071745}
1708- }
0 commit comments