Skip to content

Commit f1392ad

Browse files
committed
Update LKG
1 parent 7aee43b commit f1392ad

File tree

6 files changed

+273
-124
lines changed

6 files changed

+273
-124
lines changed

bin/tsc.js

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,8 @@ var ts;
13991399
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
14001400
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." },
14011401
Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
1402+
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
1403+
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
14021404
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
14031405
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
14041406
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@@ -11553,7 +11555,7 @@ var ts;
1155311555
return type;
1155411556
}
1155511557
function combineTypeMappers(mapper1, mapper2) {
11556-
return function (t) { return mapper2(mapper1(t)); };
11558+
return function (t) { return instantiateType(mapper1(t), mapper2); };
1155711559
}
1155811560
function instantiateTypeParameter(typeParameter, mapper) {
1155911561
var result = createType(512);
@@ -24663,6 +24665,53 @@ var ts;
2466324665
return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos);
2466424666
}
2466524667
}
24668+
function computeCommonSourceDirectory(sourceFiles) {
24669+
var commonPathComponents;
24670+
var currentDirectory = host.getCurrentDirectory();
24671+
ts.forEach(files, function (sourceFile) {
24672+
if (ts.isDeclarationFile(sourceFile)) {
24673+
return;
24674+
}
24675+
var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory);
24676+
sourcePathComponents.pop();
24677+
if (!commonPathComponents) {
24678+
commonPathComponents = sourcePathComponents;
24679+
return;
24680+
}
24681+
for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
24682+
if (commonPathComponents[i] !== sourcePathComponents[i]) {
24683+
if (i === 0) {
24684+
diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
24685+
return;
24686+
}
24687+
commonPathComponents.length = i;
24688+
break;
24689+
}
24690+
}
24691+
if (sourcePathComponents.length < commonPathComponents.length) {
24692+
commonPathComponents.length = sourcePathComponents.length;
24693+
}
24694+
});
24695+
return ts.getNormalizedPathFromPathComponents(commonPathComponents);
24696+
}
24697+
function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
24698+
var allFilesBelongToPath = true;
24699+
if (sourceFiles) {
24700+
var currentDirectory = host.getCurrentDirectory();
24701+
var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory));
24702+
for (var _i = 0; _i < sourceFiles.length; _i++) {
24703+
var sourceFile = sourceFiles[_i];
24704+
if (!ts.isDeclarationFile(sourceFile)) {
24705+
var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
24706+
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
24707+
diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
24708+
allFilesBelongToPath = false;
24709+
}
24710+
}
24711+
}
24712+
}
24713+
return allFilesBelongToPath;
24714+
}
2466624715
function verifyCompilerOptions() {
2466724716
if (options.separateCompilation) {
2466824717
if (options.sourceMap) {
@@ -24710,34 +24759,13 @@ var ts;
2471024759
options.sourceRoot ||
2471124760
(options.mapRoot &&
2471224761
(!options.out || firstExternalModuleSourceFile !== undefined))) {
24713-
var commonPathComponents;
24714-
ts.forEach(files, function (sourceFile) {
24715-
if (!(sourceFile.flags & 2048)
24716-
&& !ts.fileExtensionIs(sourceFile.fileName, ".js")) {
24717-
var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory());
24718-
sourcePathComponents.pop();
24719-
if (commonPathComponents) {
24720-
for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) {
24721-
if (commonPathComponents[i] !== sourcePathComponents[i]) {
24722-
if (i === 0) {
24723-
diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
24724-
return;
24725-
}
24726-
commonPathComponents.length = i;
24727-
break;
24728-
}
24729-
}
24730-
if (sourcePathComponents.length < commonPathComponents.length) {
24731-
commonPathComponents.length = sourcePathComponents.length;
24732-
}
24733-
}
24734-
else {
24735-
commonPathComponents = sourcePathComponents;
24736-
}
24737-
}
24738-
});
24739-
commonSourceDirectory = ts.getNormalizedPathFromPathComponents(commonPathComponents);
24740-
if (commonSourceDirectory) {
24762+
if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) {
24763+
commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory());
24764+
}
24765+
else {
24766+
commonSourceDirectory = computeCommonSourceDirectory(files);
24767+
}
24768+
if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) {
2474124769
commonSourceDirectory += ts.directorySeparator;
2474224770
}
2474324771
}
@@ -24864,6 +24892,13 @@ var ts;
2486424892
type: "boolean",
2486524893
description: ts.Diagnostics.Do_not_emit_comments_to_output
2486624894
},
24895+
{
24896+
name: "rootDir",
24897+
type: "string",
24898+
isFilePath: true,
24899+
description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
24900+
paramType: ts.Diagnostics.LOCATION
24901+
},
2486724902
{
2486824903
name: "separateCompilation",
2486924904
type: "boolean"

bin/tsserver.js

Lines changed: 67 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,8 @@ var ts;
13991399
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
14001400
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." },
14011401
Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
1402+
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
1403+
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
14021404
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
14031405
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
14041406
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@@ -2796,6 +2798,13 @@ var ts;
27962798
type: "boolean",
27972799
description: ts.Diagnostics.Do_not_emit_comments_to_output
27982800
},
2801+
{
2802+
name: "rootDir",
2803+
type: "string",
2804+
isFilePath: true,
2805+
description: ts.Diagnostics.Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
2806+
paramType: ts.Diagnostics.LOCATION
2807+
},
27992808
{
28002809
name: "separateCompilation",
28012810
type: "boolean"
@@ -11896,7 +11905,7 @@ var ts;
1189611905
return type;
1189711906
}
1189811907
function combineTypeMappers(mapper1, mapper2) {
11899-
return function (t) { return mapper2(mapper1(t)); };
11908+
return function (t) { return instantiateType(mapper1(t), mapper2); };
1190011909
}
1190111910
function instantiateTypeParameter(typeParameter, mapper) {
1190211911
var result = createType(512);
@@ -25006,6 +25015,53 @@ var ts;
2500625015
return findSourceFile(fileName, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos);
2500725016
}
2500825017
}
25018+
function computeCommonSourceDirectory(sourceFiles) {
25019+
var commonPathComponents;
25020+
var currentDirectory = host.getCurrentDirectory();
25021+
ts.forEach(files, function (sourceFile) {
25022+
if (ts.isDeclarationFile(sourceFile)) {
25023+
return;
25024+
}
25025+
var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, currentDirectory);
25026+
sourcePathComponents.pop();
25027+
if (!commonPathComponents) {
25028+
commonPathComponents = sourcePathComponents;
25029+
return;
25030+
}
25031+
for (var i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
25032+
if (commonPathComponents[i] !== sourcePathComponents[i]) {
25033+
if (i === 0) {
25034+
diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
25035+
return;
25036+
}
25037+
commonPathComponents.length = i;
25038+
break;
25039+
}
25040+
}
25041+
if (sourcePathComponents.length < commonPathComponents.length) {
25042+
commonPathComponents.length = sourcePathComponents.length;
25043+
}
25044+
});
25045+
return ts.getNormalizedPathFromPathComponents(commonPathComponents);
25046+
}
25047+
function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
25048+
var allFilesBelongToPath = true;
25049+
if (sourceFiles) {
25050+
var currentDirectory = host.getCurrentDirectory();
25051+
var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory));
25052+
for (var _i = 0; _i < sourceFiles.length; _i++) {
25053+
var sourceFile = sourceFiles[_i];
25054+
if (!ts.isDeclarationFile(sourceFile)) {
25055+
var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
25056+
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
25057+
diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
25058+
allFilesBelongToPath = false;
25059+
}
25060+
}
25061+
}
25062+
}
25063+
return allFilesBelongToPath;
25064+
}
2500925065
function verifyCompilerOptions() {
2501025066
if (options.separateCompilation) {
2501125067
if (options.sourceMap) {
@@ -25053,34 +25109,13 @@ var ts;
2505325109
options.sourceRoot ||
2505425110
(options.mapRoot &&
2505525111
(!options.out || firstExternalModuleSourceFile !== undefined))) {
25056-
var commonPathComponents;
25057-
ts.forEach(files, function (sourceFile) {
25058-
if (!(sourceFile.flags & 2048)
25059-
&& !ts.fileExtensionIs(sourceFile.fileName, ".js")) {
25060-
var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory());
25061-
sourcePathComponents.pop();
25062-
if (commonPathComponents) {
25063-
for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) {
25064-
if (commonPathComponents[i] !== sourcePathComponents[i]) {
25065-
if (i === 0) {
25066-
diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
25067-
return;
25068-
}
25069-
commonPathComponents.length = i;
25070-
break;
25071-
}
25072-
}
25073-
if (sourcePathComponents.length < commonPathComponents.length) {
25074-
commonPathComponents.length = sourcePathComponents.length;
25075-
}
25076-
}
25077-
else {
25078-
commonPathComponents = sourcePathComponents;
25079-
}
25080-
}
25081-
});
25082-
commonSourceDirectory = ts.getNormalizedPathFromPathComponents(commonPathComponents);
25083-
if (commonSourceDirectory) {
25112+
if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) {
25113+
commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, host.getCurrentDirectory());
25114+
}
25115+
else {
25116+
commonSourceDirectory = computeCommonSourceDirectory(files);
25117+
}
25118+
if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) {
2508425119
commonSourceDirectory += ts.directorySeparator;
2508525120
}
2508625121
}
@@ -34835,6 +34870,9 @@ var ts;
3483534870
if (lineText.charAt(i) == " ") {
3483634871
indentPosition--;
3483734872
}
34873+
else if (lineText.charAt(i) == "\t") {
34874+
indentPosition -= editorOptions.IndentSize;
34875+
}
3483834876
else {
3483934877
break;
3484034878
}

bin/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,7 @@ declare module "typescript" {
10951095
preserveConstEnums?: boolean;
10961096
project?: string;
10971097
removeComments?: boolean;
1098+
rootDir?: string;
10981099
sourceMap?: boolean;
10991100
sourceRoot?: string;
11001101
suppressImplicitAnyIndexErrors?: boolean;

0 commit comments

Comments
 (0)