mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Rename setting to referenceTarget
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -2020,7 +2020,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getEmitDeclarations(compilerOptions: CompilerOptions) {
|
||||
if (compilerOptions.project) {
|
||||
if (compilerOptions.referenceTarget) {
|
||||
return true;
|
||||
}
|
||||
return compilerOptions.declaration;
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -3894,6 +3894,7 @@ namespace ts {
|
||||
reactNamespace?: string;
|
||||
jsxFactory?: string;
|
||||
references?: ProjectReference[];
|
||||
referenceTarget?: boolean;
|
||||
removeComments?: boolean;
|
||||
rootDir?: string;
|
||||
rootDirs?: string[];
|
||||
|
||||
@@ -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"]
|
||||
}
|
||||
|
||||
@@ -2285,6 +2285,7 @@ declare namespace ts {
|
||||
reactNamespace?: string;
|
||||
jsxFactory?: string;
|
||||
references?: ProjectReference[];
|
||||
referenceTarget?: boolean;
|
||||
removeComments?: boolean;
|
||||
rootDir?: string;
|
||||
rootDirs?: string[];
|
||||
|
||||
@@ -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'. */
|
||||
|
||||
+1
@@ -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'. */
|
||||
|
||||
+1
@@ -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'. */
|
||||
|
||||
+1
@@ -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'. */
|
||||
|
||||
+1
@@ -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'. */
|
||||
|
||||
+1
@@ -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'. */
|
||||
|
||||
+1
@@ -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'. */
|
||||
|
||||
+1
@@ -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'. */
|
||||
|
||||
Reference in New Issue
Block a user