mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into this-function-types
This commit is contained in:
commit
fa22250110
548 files changed
+61983
-23041
No files matched your search
@@ -17,6 +17,12 @@ namespace ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Generates_corresponding_d_ts_file,
|
||||
},
|
||||
{
|
||||
name: "declarationDir",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
paramType: Diagnostics.DIRECTORY,
|
||||
},
|
||||
{
|
||||
name: "diagnostics",
|
||||
type: "boolean",
|
||||
@@ -541,6 +547,7 @@ namespace ts {
|
||||
return {
|
||||
options,
|
||||
fileNames: getFileNames(),
|
||||
typingOptions: getTypingOptions(),
|
||||
errors
|
||||
};
|
||||
|
||||
@@ -605,6 +612,35 @@ namespace ts {
|
||||
}
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
function getTypingOptions(): TypingOptions {
|
||||
const options: TypingOptions = getBaseFileName(configFileName) === "jsconfig.json"
|
||||
? { enableAutoDiscovery: true, include: [], exclude: [] }
|
||||
: { enableAutoDiscovery: false, include: [], exclude: [] };
|
||||
const jsonTypingOptions = json["typingOptions"];
|
||||
if (jsonTypingOptions) {
|
||||
for (const id in jsonTypingOptions) {
|
||||
if (id === "enableAutoDiscovery") {
|
||||
if (typeof jsonTypingOptions[id] === "boolean") {
|
||||
options.enableAutoDiscovery = jsonTypingOptions[id];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_typing_option_0, id));
|
||||
}
|
||||
}
|
||||
else if (id === "include") {
|
||||
options.include = convertJsonOptionToStringArray(id, jsonTypingOptions[id], errors);
|
||||
}
|
||||
else if (id === "exclude") {
|
||||
options.exclude = convertJsonOptionToStringArray(id, jsonTypingOptions[id], errors);
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_typing_option_0, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions, errors: Diagnostic[] } {
|
||||
@@ -645,28 +681,7 @@ namespace ts {
|
||||
break;
|
||||
case "object":
|
||||
// "object" options with 'isFilePath' = true expected to be string arrays
|
||||
let paths: string[] = [];
|
||||
let invalidOptionType = false;
|
||||
if (!isArray(value)) {
|
||||
invalidOptionType = true;
|
||||
}
|
||||
else {
|
||||
for (const element of <any[]>value) {
|
||||
if (typeof element === "string") {
|
||||
paths.push(normalizePath(combinePaths(basePath, element)));
|
||||
}
|
||||
else {
|
||||
invalidOptionType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (invalidOptionType) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Option_0_should_have_array_of_strings_as_a_value, opt.name));
|
||||
}
|
||||
else {
|
||||
value = paths;
|
||||
}
|
||||
value = convertJsonOptionToStringArray(opt.name, value, errors, (element) => normalizePath(combinePaths(basePath, element)));
|
||||
break;
|
||||
}
|
||||
if (value === "") {
|
||||
@@ -686,4 +701,28 @@ namespace ts {
|
||||
|
||||
return { options, errors };
|
||||
}
|
||||
|
||||
function convertJsonOptionToStringArray(optionName: string, optionJson: any, errors: Diagnostic[], func?: (element: string) => string): string[] {
|
||||
const items: string[] = [];
|
||||
let invalidOptionType = false;
|
||||
if (!isArray(optionJson)) {
|
||||
invalidOptionType = true;
|
||||
}
|
||||
else {
|
||||
for (const element of <any[]>optionJson) {
|
||||
if (typeof element === "string") {
|
||||
const item = func ? func(element) : element;
|
||||
items.push(item);
|
||||
}
|
||||
else {
|
||||
invalidOptionType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (invalidOptionType) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Option_0_should_have_array_of_strings_as_a_value, optionName));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user