mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-13 06:20:23 -06:00
CR feedback
This commit is contained in:
parent
830a10fc92
commit
a7a13296e6
@ -590,10 +590,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (id === "include") {
|
||||
options.include = ConvertJsonOptionToStringArray(id, jsonTypingOptions[id], errors);
|
||||
options.include = convertJsonOptionToStringArray(id, jsonTypingOptions[id], errors);
|
||||
}
|
||||
else if (id === "exclude") {
|
||||
options.exclude = ConvertJsonOptionToStringArray(id, jsonTypingOptions[id], errors);
|
||||
options.exclude = convertJsonOptionToStringArray(id, jsonTypingOptions[id], errors);
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_typing_option_0, id));
|
||||
@ -636,9 +636,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
if (opt.isFilePath) {
|
||||
value = normalizePath(combinePaths(basePath, value));
|
||||
value = normalizePath(combinePaths(basePath, value));
|
||||
if (value === "") {
|
||||
value = ".";
|
||||
value = ".";
|
||||
}
|
||||
}
|
||||
options[opt.name] = value;
|
||||
@ -655,7 +655,7 @@ namespace ts {
|
||||
return { options, errors };
|
||||
}
|
||||
|
||||
function ConvertJsonOptionToStringArray(optionName: string, optionJson: any, errors: Diagnostic[], func?: (element: string) => string): string[] {
|
||||
function convertJsonOptionToStringArray(optionName: string, optionJson: any, errors: Diagnostic[], func?: (element: string) => string): string[] {
|
||||
const items: string[] = [];
|
||||
let invalidOptionType = false;
|
||||
if (!isArray(optionJson)) {
|
||||
|
||||
@ -193,8 +193,8 @@ namespace ts.JsTyping {
|
||||
mergeTypings(filter(cleanedTypingNames, f => hasProperty(safeList, f)));
|
||||
}
|
||||
|
||||
const jsxFileNames = filter(fileNames, f => scriptKindIs(f, /*LanguageServiceHost*/ undefined, ScriptKind.JSX));
|
||||
if (jsxFileNames.length > 0) {
|
||||
const hasJsxFile = forEach(fileNames, f => scriptKindIs(f, /*LanguageServiceHost*/ undefined, ScriptKind.JSX));
|
||||
if (hasJsxFile) {
|
||||
mergeTypings(["react"]);
|
||||
}
|
||||
}
|
||||
@ -214,6 +214,7 @@ namespace ts.JsTyping {
|
||||
filter(
|
||||
host.readDirectory(nodeModulesPath, /*extension*/ undefined, /*exclude*/ undefined, /*depth*/ 2),
|
||||
f => ts.getBaseFileName(f) === "package.json");
|
||||
|
||||
for (const packageJsonFile of packageJsonFiles) {
|
||||
const packageJsonDict = tryParseJson(packageJsonFile, host);
|
||||
if (!packageJsonDict) { continue; }
|
||||
@ -247,13 +248,6 @@ namespace ts.JsTyping {
|
||||
if (!options) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.jsx === JsxEmit.React) {
|
||||
typingNames.push("react");
|
||||
}
|
||||
if (options.moduleResolution === ModuleResolutionKind.NodeJs) {
|
||||
typingNames.push("node");
|
||||
}
|
||||
mergeTypings(typingNames);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user