Skip to content

Commit 3645edb

Browse files
committed
Update LKG
1 parent 846faab commit 3645edb

File tree

6 files changed

+22
-20
lines changed

6 files changed

+22
-20
lines changed

release/compiler.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export declare class ProjectCompiler implements ICompiler {
2929
* Calculates the difference between the common base directory calculated based on the base paths of the input files
3030
* and the common source directory calculated by TypeScript.
3131
*/
32-
private commonBaseDiff;
32+
private readonly commonBaseDiff;
3333
correctSourceMap(map: RawSourceMap): boolean;
3434
private removeSourceMapComment(content);
3535
}

release/compiler.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ var ProjectCompiler = (function () {
2323
this.project.output.finish(reporter_1.emptyCompilationResult());
2424
return;
2525
}
26+
var root = this.project.input.commonBasePath;
27+
var rootFilenames = this.project.input.getFileNames(true);
28+
if (!this.project.singleOutput) {
29+
// Add an empty file under the root.
30+
// This will make sure the commonSourceDirectory, calculated by TypeScript, won't point to a subdirectory of the root.
31+
// We cannot use the `rootDir` option here, since that gives errors if the commonSourceDirectory points to a
32+
// directory containing the rootDir instead of the rootDir, which will break the build when using `noEmitOnError`.
33+
// The empty file is filtered out later on.
34+
var emptyFileName = path.join(this.project.options['rootDir'] ? path.resolve(this.project.projectDirectory, this.project.options['rootDir']) : root, '________________empty.ts');
35+
rootFilenames.push(emptyFileName);
36+
this.project.input.addContent(emptyFileName, '');
37+
}
2638
if (!this.project.input.isChanged(true)) {
2739
// Re-use old output
2840
var old = this.project.previousOutput;
@@ -42,24 +54,12 @@ var ProjectCompiler = (function () {
4254
this.project.output.finish(old.results);
4355
return;
4456
}
45-
var root = this.project.input.commonBasePath;
4657
this.project.options.sourceRoot = root;
4758
this.host = new host_1.Host(this.project.typescript, this.project.currentDirectory, this.project.input, !this.project.noExternalResolve, this.project.options.target >= ts.ScriptTarget.ES6 ? 'lib.es6.d.ts' : 'lib.d.ts');
48-
var rootFilenames = this.project.input.getFileNames(true);
4959
if (this.project.filterSettings !== undefined) {
5060
var filter_2 = new filter_1.Filter(this.project, this.project.filterSettings);
5161
rootFilenames = rootFilenames.filter(function (fileName) { return filter_2.match(fileName); });
5262
}
53-
if (!this.project.singleOutput) {
54-
// Add an empty file under the root.
55-
// This will make sure the commonSourceDirectory, calculated by TypeScript, won't point to a subdirectory of the root.
56-
// We cannot use the `rootDir` option here, since that gives errors if the commonSourceDirectory points to a
57-
// directory containing the rootDir instead of the rootDir, which will break the build when using `noEmitOnError`.
58-
// The empty file is filtered out later on.
59-
var emptyFileName = path.join(this.project.options['rootDir'] ? path.resolve(this.project.projectDirectory, this.project.options['rootDir']) : root, '________________empty.ts');
60-
rootFilenames.push(emptyFileName);
61-
this.project.input.addContent(emptyFileName, '');
62-
}
6363
// Creating a program to compile the sources
6464
// We cast to `tsApi.CreateProgram` so we can pass the old program as an extra argument.
6565
// TS 1.6+ will try to reuse program structure (if possible)

release/host.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ export declare class Host implements ts.CompilerHost {
2323
fileExists(fileName: string): boolean;
2424
readFile(fileName: string): string;
2525
getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void) => ts.SourceFile;
26+
realpath: any;
2627
}

release/host.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ var Host = (function () {
5050
this.input = input;
5151
this.externalResolve = externalResolve;
5252
this.libFileName = libFileName;
53+
this.realpath = typescript.createCompilerHost({})['realpath'];
5354
this.reset();
5455
}
5556
Host.getLibDefault = function (typescript, libFileName, originalFileName) {

release/input.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export declare class FileDictionary {
4343
initTypeScriptSourceFile: (file: File) => void;
4444
getFileNames(onlyGulp?: boolean): string[];
4545
private getSourceFileNames(onlyGulp?);
46-
commonBasePath: string;
47-
commonSourceDirectory: string;
46+
readonly commonBasePath: string;
47+
readonly commonSourceDirectory: string;
4848
}
4949
export declare class FileCache {
5050
previous: FileDictionary;
@@ -62,8 +62,8 @@ export declare class FileCache {
6262
getFile(name: string): File;
6363
getFileChange(name: string): FileChange;
6464
getFileNames(onlyGulp?: boolean): string[];
65-
firstSourceFile: File;
66-
commonBasePath: string;
67-
commonSourceDirectory: string;
65+
readonly firstSourceFile: File;
66+
readonly commonBasePath: string;
67+
readonly commonSourceDirectory: string;
6868
isChanged(onlyGulp?: boolean): boolean;
6969
}

release/project.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ var Project = (function () {
3535
var _this = this;
3636
var configPath = path.dirname(this.configFileName);
3737
var base;
38-
if (this.config.compilerOptions && this.config.compilerOptions.rootDir) {
39-
base = path.resolve(configPath, this.config.compilerOptions.rootDir);
38+
if (this.options["rootDir"]) {
39+
base = path.resolve(configPath, this.options["rootDir"]);
4040
}
4141
if (!this.config.files) {
4242
var files_1 = [path.join(configPath, '**/*.ts')];

0 commit comments

Comments
 (0)