Rename setting to referenceTarget

This commit is contained in:
Ryan Cavanaugh
2017-12-29 13:16:06 -08:00
parent a348e246e7
commit f287d63539
16 changed files with 42 additions and 12 deletions
+1 -1
View File
@@ -218,7 +218,7 @@ namespace ts {
description: Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
},
{
name: "project",
name: "referenceTarget",
type: "boolean",
category: Diagnostics.Basic_Options,
description: Diagnostics.Enable_project_compilation,
+1 -1
View File
@@ -2020,7 +2020,7 @@ namespace ts {
}
export function getEmitDeclarations(compilerOptions: CompilerOptions) {
if (compilerOptions.project) {
if (compilerOptions.referenceTarget) {
return true;
}
return compilerOptions.declaration;
+1 -1
View File
@@ -3433,7 +3433,7 @@
"category": "Error",
"code": 6305
},
"Referenced project '{0}' must have setting \"project\": true.": {
"Referenced project '{0}' must have setting \"referenceTarget\": true.": {
"category": "Error",
"code": 6306
},
+5 -5
View File
@@ -613,7 +613,7 @@ namespace ts {
Debug.assert(!!missingFilePaths);
// List of collected files is complete; validate exhautiveness if this is a project with a file list
if (options.project && rootNames.length < files.length) {
if (options.referenceTarget && rootNames.length < files.length) {
const normalizedRootNames = rootNames.map(r => normalizePath(r));
const sourceFiles = files.filter(f => !f.isDeclarationFile).map(f => normalizePath(f.path));
for (const file of sourceFiles) {
@@ -685,7 +685,7 @@ namespace ts {
function getCommonSourceDirectory() {
if (commonSourceDirectory === undefined) {
const emittedFiles = filter(files, file => sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary));
if (options.project) {
if (options.referenceTarget) {
// Project compilations never infer their root from the input source paths
commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir || ".", currentDirectory);
}
@@ -2112,8 +2112,8 @@ namespace ts {
Debug.fail("Options cannot be undefined");
return;
}
if (!opts.project) {
createDiagnosticForOptionName(Diagnostics.Referenced_project_0_must_have_setting_project_Colon_true, fileName);
if (!opts.referenceTarget) {
createDiagnosticForOptionName(Diagnostics.Referenced_project_0_must_have_setting_referenceTarget_Colon_true, fileName);
}
illegalRefs.set(normalizedPath, true);
cycleName.push(normalizedPath);
@@ -2155,7 +2155,7 @@ namespace ts {
createDiagnosticForOptionName(Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option, "paths");
}
if (options.project) {
if (options.referenceTarget) {
if (options.declaration === false) {
createDiagnosticForOptionName(Diagnostics.Projects_may_not_disable_declaration_emit, "declaration");
}
+1
View File
@@ -3894,6 +3894,7 @@ namespace ts {
reactNamespace?: string;
jsxFactory?: string;
references?: ProjectReference[];
referenceTarget?: boolean;
removeComments?: boolean;
rootDir?: string;
rootDirs?: string[];
+23 -4
View File
@@ -52,8 +52,8 @@ namespace ts {
const configFileName = combineAllPaths("/", key, sp.configFileName || "tsconfig.json");
const options = {
compilerOptions: {
references: sp.references.map(r => ({ path: r })),
project: true,
references: (sp.references || []).map(r => ({ path: r })),
referenceTarget: true,
outDir: "bin",
...sp.options
},
@@ -140,7 +140,27 @@ namespace ts {
assertHasError("Reports an error about the wrong decl setting", errs, Diagnostics.Projects_may_not_disable_declaration_emit);
});
});
// * TODO Projects must list all files or none
it("errors when the referenced project doesn't have referenceTarget:true", () => {
const spec: TestSpecification = {
"/primary": {
files: { "/primary/a.ts": emptyModule },
references: [],
options: {
referenceTarget: false
}
},
"/reference": {
files: { "/secondary/b.ts": moduleImporting("../primary/a") },
references: ["../primary"]
}
};
testProjectReferences(spec, "/reference/tsconfig.json", program => {
const errs = program.getOptionsDiagnostics();
assertHasError("Reports an error about 'referenceTarget' not being set", errs, Diagnostics.Referenced_project_0_must_have_setting_referenceTarget_Colon_true);
});
});
it("errors when the file list is not exhaustive", () => {
const spec: TestSpecification = {
"/primary": {
@@ -148,7 +168,6 @@ namespace ts {
"/primary/a.ts": "import * as b from './b'",
"/primary/b.ts": "export {}"
},
references: [],
config: {
files: ["a.ts"]
}
+1
View File
@@ -2285,6 +2285,7 @@ declare namespace ts {
reactNamespace?: string;
jsxFactory?: string;
references?: ProjectReference[];
referenceTarget?: boolean;
removeComments?: boolean;
rootDir?: string;
rootDirs?: string[];
+1
View File
@@ -2285,6 +2285,7 @@ declare namespace ts {
reactNamespace?: string;
jsxFactory?: string;
references?: ProjectReference[];
referenceTarget?: boolean;
removeComments?: boolean;
rootDir?: string;
rootDirs?: string[];
@@ -12,6 +12,7 @@
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "referenceTarget": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
@@ -12,6 +12,7 @@
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "referenceTarget": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
@@ -12,6 +12,7 @@
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "referenceTarget": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
@@ -12,6 +12,7 @@
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "referenceTarget": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
@@ -12,6 +12,7 @@
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "referenceTarget": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
@@ -12,6 +12,7 @@
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "referenceTarget": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
@@ -12,6 +12,7 @@
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "referenceTarget": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
@@ -12,6 +12,7 @@
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "referenceTarget": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */