Rename getPackageNameFromAtTypesDirectoryWithoutPrefix to getUnmangledNameForScopedPackage

This commit is contained in:
Andrew Casey 2018-01-10 15:17:27 -08:00
parent 211be0ae69
commit 9a4fe8eb7e
2 changed files with 7 additions and 7 deletions

View file

@ -1097,16 +1097,16 @@ namespace ts {
export function getPackageNameFromAtTypesDirectory(mangledName: string): string {
const withoutAtTypePrefix = removePrefix(mangledName, "@types/");
if (withoutAtTypePrefix !== mangledName) {
return getPackageNameFromAtTypesDirectoryWithoutPrefix(withoutAtTypePrefix);
return getUnmangledNameForScopedPackage(withoutAtTypePrefix);
}
return mangledName;
}
/* @internal */
export function getPackageNameFromAtTypesDirectoryWithoutPrefix(withoutAtTypePrefix: string): string {
return stringContains(withoutAtTypePrefix, mangledScopedPackageSeparator) ?
"@" + withoutAtTypePrefix.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
withoutAtTypePrefix;
export function getUnmangledNameForScopedPackage(typesPackageName: string): string {
return stringContains(typesPackageName, mangledScopedPackageSeparator) ?
"@" + typesPackageName.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
typesPackageName;
}
function tryFindNonRelativeModuleNameInCache(cache: PerModuleNameCache | undefined, moduleName: string, containingDirectory: string, traceEnabled: boolean, host: ModuleResolutionHost): SearchResult<Resolved> {

View file

@ -315,7 +315,7 @@ namespace ts.Completions.PathCompletions {
const seen = createMap<true>();
if (options.types) {
for (const typesName of options.types) {
const moduleName = getPackageNameFromAtTypesDirectoryWithoutPrefix(typesName);
const moduleName = getUnmangledNameForScopedPackage(typesName);
pushResult(moduleName);
}
}
@ -349,7 +349,7 @@ namespace ts.Completions.PathCompletions {
for (let typeDirectory of directories) {
typeDirectory = normalizePath(typeDirectory);
const directoryName = getBaseFileName(typeDirectory);
const moduleName = getPackageNameFromAtTypesDirectoryWithoutPrefix(directoryName);
const moduleName = getUnmangledNameForScopedPackage(directoryName);
pushResult(moduleName);
}
}