mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-26 21:05:54 -06:00
- Adding new lines after { for single-line if statements
- Renaming DiscoverTypingsSettings to DiscoverTypingsInfo to match host
This commit is contained in:
parent
4bbdf2a0bb
commit
e8772bc0a2
@ -2439,7 +2439,7 @@ namespace ts {
|
||||
[option: string]: string[] | boolean;
|
||||
}
|
||||
|
||||
export interface DiscoverTypingsSettings {
|
||||
export interface DiscoverTypingsInfo {
|
||||
fileNames: string[]; // The file names that belong to the same project.
|
||||
cachePath: string; // The path to the typings cache
|
||||
projectRootPath: string; // The path to the project root directory
|
||||
|
||||
@ -60,8 +60,12 @@ namespace ts.JsTyping {
|
||||
|
||||
if (!safeList) {
|
||||
const result = readConfigFile(safeListPath, (path: string) => host.readFile(path));
|
||||
if (result.config) { safeList = result.config; }
|
||||
else { safeList = {}; };
|
||||
if (result.config) {
|
||||
safeList = result.config;
|
||||
}
|
||||
else {
|
||||
safeList = {};
|
||||
};
|
||||
}
|
||||
|
||||
const filesToWatch: string[] = [];
|
||||
@ -188,9 +192,13 @@ namespace ts.JsTyping {
|
||||
const fileNames = host.readDirectory(nodeModulesPath, "*.json", /*exclude*/ undefined, /*depth*/ 2);
|
||||
for (const fileName of fileNames) {
|
||||
const normalizedFileName = normalizePath(fileName);
|
||||
if (getBaseFileName(normalizedFileName) !== "package.json") { continue; }
|
||||
if (getBaseFileName(normalizedFileName) !== "package.json") {
|
||||
continue;
|
||||
}
|
||||
const result = readConfigFile(normalizedFileName, (path: string) => host.readFile(path));
|
||||
if (!result.config) { continue; }
|
||||
if (!result.config) {
|
||||
continue;
|
||||
}
|
||||
const packageJson: PackageJson = result.config;
|
||||
|
||||
// npm 3's package.json contains a "_requiredBy" field
|
||||
@ -203,7 +211,9 @@ namespace ts.JsTyping {
|
||||
|
||||
// If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
|
||||
// to download d.ts files from DefinitelyTyped
|
||||
if (!packageJson.name) { continue; }
|
||||
if (!packageJson.name) {
|
||||
continue;
|
||||
}
|
||||
if (packageJson.typings) {
|
||||
const absolutePath = getNormalizedAbsolutePath(packageJson.typings, getDirectoryPath(normalizedFileName));
|
||||
inferredTypings[packageJson.name] = absolutePath;
|
||||
|
||||
@ -990,16 +990,16 @@ namespace ts {
|
||||
public discoverTypings(discoverTypingsJson: string): string {
|
||||
const getCanonicalFileName = createGetCanonicalFileName(/*useCaseSensitivefileNames:*/ false);
|
||||
return this.forwardJSONCall("discoverTypings()", () => {
|
||||
const settings = <DiscoverTypingsSettings>JSON.parse(discoverTypingsJson);
|
||||
const info = <DiscoverTypingsInfo>JSON.parse(discoverTypingsJson);
|
||||
return ts.JsTyping.discoverTypings(
|
||||
this.host,
|
||||
settings.fileNames,
|
||||
toPath(settings.cachePath, settings.cachePath, getCanonicalFileName),
|
||||
toPath(settings.projectRootPath, settings.projectRootPath, getCanonicalFileName),
|
||||
toPath(settings.safeListPath, settings.safeListPath, getCanonicalFileName),
|
||||
settings.packageNameToTypingLocation,
|
||||
settings.typingOptions,
|
||||
settings.compilerOptions);
|
||||
info.fileNames,
|
||||
toPath(info.cachePath, info.cachePath, getCanonicalFileName),
|
||||
toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName),
|
||||
toPath(info.safeListPath, info.safeListPath, getCanonicalFileName),
|
||||
info.packageNameToTypingLocation,
|
||||
info.typingOptions,
|
||||
info.compilerOptions);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user