Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 99cb2ad

Browse files
committedMay 9, 2018
Merge branch 'master' into libReference
2 parents 6c35abe + 6f9dc2f commit 99cb2ad

File tree

200 files changed

+3947
-1327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+3947
-1327
lines changed
 

‎src/compiler/checker.ts

+100-72
Large diffs are not rendered by default.

‎src/compiler/commandLineParser.ts

+100-5
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ namespace ts {
248248
category: Diagnostics.Basic_Options,
249249
description: Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
250250
},
251+
{
252+
name: "composite",
253+
type: "boolean",
254+
isTSConfigOnly: true,
255+
category: Diagnostics.Basic_Options,
256+
description: Diagnostics.Enable_project_compilation,
257+
},
251258
{
252259
name: "removeComments",
253260
type: "boolean",
@@ -827,12 +834,14 @@ namespace ts {
827834
export function parseCommandLine(commandLine: ReadonlyArray<string>, readFile?: (path: string) => string | undefined): ParsedCommandLine {
828835
const options: CompilerOptions = {};
829836
const fileNames: string[] = [];
837+
const projectReferences: ProjectReference[] | undefined = undefined;
830838
const errors: Diagnostic[] = [];
831839

832840
parseStrings(commandLine);
833841
return {
834842
options,
835843
fileNames,
844+
projectReferences,
836845
errors
837846
};
838847

@@ -946,6 +955,49 @@ namespace ts {
946955
return optionNameMap.get(optionName);
947956
}
948957

958+
959+
export type DiagnosticReporter = (diagnostic: Diagnostic) => void;
960+
/**
961+
* Reports config file diagnostics
962+
*/
963+
export interface ConfigFileDiagnosticsReporter {
964+
/**
965+
* Reports unrecoverable error when parsing config file
966+
*/
967+
onUnRecoverableConfigFileDiagnostic: DiagnosticReporter;
968+
}
969+
970+
/**
971+
* Interface extending ParseConfigHost to support ParseConfigFile that reads config file and reports errors
972+
*/
973+
export interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter {
974+
getCurrentDirectory(): string;
975+
}
976+
977+
/**
978+
* Reads the config file, reports errors if any and exits if the config file cannot be found
979+
*/
980+
export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost): ParsedCommandLine | undefined {
981+
let configFileText: string;
982+
try {
983+
configFileText = host.readFile(configFileName);
984+
}
985+
catch (e) {
986+
const error = createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message);
987+
host.onUnRecoverableConfigFileDiagnostic(error);
988+
return undefined;
989+
}
990+
if (!configFileText) {
991+
const error = createCompilerDiagnostic(Diagnostics.File_0_not_found, configFileName);
992+
host.onUnRecoverableConfigFileDiagnostic(error);
993+
return undefined;
994+
}
995+
996+
const result = parseJsonText(configFileName, configFileText);
997+
const cwd = host.getCurrentDirectory();
998+
return parseJsonSourceFileConfigFileContent(result, host, getNormalizedAbsolutePath(getDirectoryPath(configFileName), cwd), optionsToExtend, getNormalizedAbsolutePath(configFileName, cwd));
999+
}
1000+
9491001
/**
9501002
* Read tsconfig.json file
9511003
* @param fileName The path to the config file
@@ -1021,6 +1073,14 @@ namespace ts {
10211073
name: "extends",
10221074
type: "string"
10231075
},
1076+
{
1077+
name: "references",
1078+
type: "list",
1079+
element: {
1080+
name: "references",
1081+
type: "object"
1082+
}
1083+
},
10241084
{
10251085
name: "files",
10261086
type: "list",
@@ -1428,7 +1488,7 @@ namespace ts {
14281488
for (let i = 0; i < nameColumn.length; i++) {
14291489
const optionName = nameColumn[i];
14301490
const description = descriptionColumn[i];
1431-
result.push(optionName && `${tab}${tab}${optionName}${ description && (makePadding(marginLength - optionName.length + 2) + description)}`);
1491+
result.push(optionName && `${tab}${tab}${optionName}${description && (makePadding(marginLength - optionName.length + 2) + description)}`);
14321492
}
14331493
if (fileNames.length) {
14341494
result.push(`${tab}},`);
@@ -1512,12 +1572,13 @@ namespace ts {
15121572
const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors);
15131573
const { raw } = parsedConfig;
15141574
const options = extend(existingOptions, parsedConfig.options || {});
1515-
options.configFilePath = configFileName;
1575+
options.configFilePath = configFileName && normalizeSlashes(configFileName);
15161576
setConfigFileInOptions(options, sourceFile);
1517-
const { fileNames, wildcardDirectories, spec } = getFileNames();
1577+
const { fileNames, wildcardDirectories, spec, projectReferences } = getFileNames();
15181578
return {
15191579
options,
15201580
fileNames,
1581+
projectReferences,
15211582
typeAcquisition: parsedConfig.typeAcquisition || getDefaultTypeAcquisition(),
15221583
raw,
15231584
errors,
@@ -1571,10 +1632,33 @@ namespace ts {
15711632
}
15721633

15731634
const result = matchFileNames(filesSpecs, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile);
1574-
if (result.fileNames.length === 0 && !hasProperty(raw, "files") && resolutionStack.length === 0) {
1635+
if (result.fileNames.length === 0 && !hasProperty(raw, "files") && resolutionStack.length === 0 && !hasProperty(raw, "references")) {
15751636
errors.push(getErrorForNoInputFiles(result.spec, configFileName));
15761637
}
15771638

1639+
if (hasProperty(raw, "references") && !isNullOrUndefined(raw.references)) {
1640+
if (isArray(raw.references)) {
1641+
const references: ProjectReference[] = [];
1642+
for (const ref of raw.references) {
1643+
if (typeof ref.path !== "string") {
1644+
createCompilerDiagnosticOnlyIfJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "reference.path", "string");
1645+
}
1646+
else {
1647+
references.push({
1648+
path: getNormalizedAbsolutePath(ref.path, basePath),
1649+
originalPath: ref.path,
1650+
prepend: ref.prepend,
1651+
circular: ref.circular
1652+
});
1653+
}
1654+
}
1655+
result.projectReferences = references;
1656+
}
1657+
else {
1658+
createCompilerDiagnosticOnlyIfJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "references", "Array");
1659+
}
1660+
}
1661+
15781662
return result;
15791663
}
15801664

@@ -1863,6 +1947,9 @@ namespace ts {
18631947

18641948
const options = getDefaultCompilerOptions(configFileName);
18651949
convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors);
1950+
if (configFileName) {
1951+
options.configFilePath = normalizeSlashes(configFileName);
1952+
}
18661953
return options;
18671954
}
18681955

@@ -2061,7 +2148,7 @@ namespace ts {
20612148
// new entries in these paths.
20622149
const wildcardDirectories = getWildcardDirectories(validatedIncludeSpecs, validatedExcludeSpecs, basePath, host.useCaseSensitiveFileNames);
20632150

2064-
const spec: ConfigFileSpecs = { filesSpecs, includeSpecs, excludeSpecs, validatedIncludeSpecs, validatedExcludeSpecs, wildcardDirectories };
2151+
const spec: ConfigFileSpecs = { filesSpecs, referencesSpecs: undefined, includeSpecs, excludeSpecs, validatedIncludeSpecs, validatedExcludeSpecs, wildcardDirectories };
20652152
return getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions);
20662153
}
20672154

@@ -2132,8 +2219,16 @@ namespace ts {
21322219

21332220
const literalFiles = arrayFrom(literalFileMap.values());
21342221
const wildcardFiles = arrayFrom(wildcardFileMap.values());
2222+
const projectReferences = spec.referencesSpecs && spec.referencesSpecs.map((r): ProjectReference => {
2223+
return {
2224+
...r,
2225+
path: getNormalizedAbsolutePath(r.path, basePath)
2226+
};
2227+
});
2228+
21352229
return {
21362230
fileNames: literalFiles.concat(wildcardFiles),
2231+
projectReferences,
21372232
wildcardDirectories,
21382233
spec
21392234
};

0 commit comments

Comments
 (0)
Please sign in to comment.