Skip to content

Commit

Permalink
Adding comments and refactoring some of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Nov 3, 2022
1 parent cdcae30 commit 34e5ec2
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 217 deletions.
350 changes: 149 additions & 201 deletions src/compiler/builder.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/compiler/builderState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ namespace ts {
fileInfos.set(sourceFile.resolvedPath, {
version,
signature,
// No need to calculate affectsGlobalScope with --out since its not used at all
affectsGlobalScope: !isOutFile ? isFileAffectingGlobalScope(sourceFile) || undefined : undefined,
impliedFormat: sourceFile.impliedNodeFormat
});
Expand Down
1 change: 1 addition & 0 deletions src/compiler/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ namespace ts {
}

export function getSourceFileVersionAsHashFromText(host: Pick<CompilerHost, "createHash">, text: string) {
// If text can contain the sourceMapUrl ignore sourceMapUrl for calcualting hash
if (text.match(sourceMapCommentRegExpDontCareLineStart)) {
let lineEnd = text.length;
let lineStart = lineEnd;
Expand Down
6 changes: 2 additions & 4 deletions src/testRunner/unittests/tsbuild/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ interface Symbol {
type ReadableProgramBuildInfoDiagnostic = string | [string, readonly ReusableDiagnostic[]];
type ReadableBuilderFileEmit = string & { __readableBuilderFileEmit: any; };
type ReadableProgramBuilderInfoFilePendingEmit = [original: string | [string], emitKind: ReadableBuilderFileEmit];
type ReadableProgramBuildInfoEmitSignature = string | [string, string];
type ReadableProgramBuildInfoEmitSignature = string | [string, EmitSignature | []];
type ReadableProgramBuildInfoFileInfo<T> = Omit<BuilderState.FileInfo, "impliedFormat"> & {
impliedFormat: string | undefined;
original: T | undefined;
};
type ReadableProgramMultiFileEmitBuildInfo = Omit<ProgramMultiFileEmitBuildInfo,
"fileIdsList" | "fileInfos" |
"referencedMap" | "exportedModulesMap" | "semanticDiagnosticsPerFile" |
"affectedFilesPendingEmit" | "changeFileSet" | "emitSignatures" | "emitSignatureDtsMapDiffers"
"affectedFilesPendingEmit" | "changeFileSet" | "emitSignatures"
> & {
fileNamesList: readonly (readonly string[])[] | undefined;
fileInfos: MapLike<ReadableProgramBuildInfoFileInfo<ProgramMultiFileEmitBuildInfoFileInfo>>;
Expand All @@ -218,7 +218,6 @@ interface Symbol {
affectedFilesPendingEmit: readonly ReadableProgramBuilderInfoFilePendingEmit[] | undefined;
changeFileSet: readonly string[] | undefined;
emitSignatures: readonly ReadableProgramBuildInfoEmitSignature[] | undefined;
emitSignatureDtsMapDiffers: readonly string[] | undefined;
};
type ReadableProgramBuildInfoBundlePendingEmit = [emitKind: ReadableBuilderFileEmit, original: ProgramBuildInfoBundlePendingEmit];
type ReadableProgramBundleEmitBuildInfo = Omit<ProgramBundleEmitBuildInfo, "fileInfos" | "pendingEmit"> & {
Expand Down Expand Up @@ -278,7 +277,6 @@ interface Symbol {
toFileName(s) :
[toFileName(s[0]), s[1]]
),
emitSignatureDtsMapDiffers: buildInfo.program.emitSignatureDtsMapDiffers?.map(toFileName),
latestChangedDtsFile: buildInfo.program.latestChangedDtsFile,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ IncrementalBuild:
"emitSignatures": [
[
"./a.ts",
"-3198459068-declare const x = 10;\r\n"
[
"-3198459068-declare const x = 10;\r\n"
]
],
[
"./b.ts",
[]
]
],
"emitSignatureDtsMapDiffers": [
"./a.ts",
"./b.ts"
],
"latestChangedDtsFile": "FakeFileName"
},
"version": "FakeTSVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped


//// [/src/project/tsconfig.tsbuildinfo]
{"program":{"fileNames":["../../lib/lib.d.ts","./a.ts","./b.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"5515933561-const x: 20 = 10;","signature":"-1601647902-declare const x: 20;\r\n","affectsGlobalScope":true},{"version":"2026006654-const y = 10;","signature":"-5539113915-declare const y = 10;\r\n","affectsGlobalScope":true}],"options":{"composite":true,"declaration":true,"declarationMap":true,"noEmitOnError":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,[2,[{"file":"./a.ts","start":6,"length":1,"code":2322,"category":1,"messageText":"Type '10' is not assignable to type '20'."}]],3],"affectedFilesPendingEmit":[2,3],"emitSignatures":[[2,"-3198459068-declare const x = 10;\r\n"]],"emitSignatureDtsMapDiffers":[2,3],"latestChangedDtsFile":"./b.d.ts"},"version":"FakeTSVersion"}
{"program":{"fileNames":["../../lib/lib.d.ts","./a.ts","./b.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"5515933561-const x: 20 = 10;","signature":"-1601647902-declare const x: 20;\r\n","affectsGlobalScope":true},{"version":"2026006654-const y = 10;","signature":"-5539113915-declare const y = 10;\r\n","affectsGlobalScope":true}],"options":{"composite":true,"declaration":true,"declarationMap":true,"noEmitOnError":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,[2,[{"file":"./a.ts","start":6,"length":1,"code":2322,"category":1,"messageText":"Type '10' is not assignable to type '20'."}]],3],"affectedFilesPendingEmit":[2,3],"emitSignatures":[[2,["-3198459068-declare const x = 10;\r\n"]],[3,[]]],"latestChangedDtsFile":"./b.d.ts"},"version":"FakeTSVersion"}

//// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt]
{
Expand Down Expand Up @@ -208,17 +208,19 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped
"emitSignatures": [
[
"./a.ts",
"-3198459068-declare const x = 10;\r\n"
[
"-3198459068-declare const x = 10;\r\n"
]
],
[
"./b.ts",
[]
]
],
"emitSignatureDtsMapDiffers": [
"./a.ts",
"./b.ts"
],
"latestChangedDtsFile": "./b.d.ts"
},
"version": "FakeTSVersion",
"size": 1284
"size": 1258
}


Expand Down

0 comments on commit 34e5ec2

Please sign in to comment.