Improve error message for untyped import of scoped package (#22189)

This commit is contained in:
Andy
2018-02-26 10:38:54 -08:00
committed by GitHub
parent b31aa4e012
commit e4e4b17669
7 changed files with 53 additions and 2 deletions

View File

@@ -2092,7 +2092,7 @@ namespace ts {
else if (noImplicitAny && moduleNotFoundError) {
let errorInfo = resolvedModule.packageId && chainDiagnosticMessages(/*details*/ undefined,
Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0,
resolvedModule.packageId.name);
getMangledNameForScopedPackage(resolvedModule.packageId.name));
errorInfo = chainDiagnosticMessages(errorInfo,
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type,
moduleReference,

View File

@@ -1157,7 +1157,8 @@ namespace ts {
return `@types/${getMangledNameForScopedPackage(packageName)}`;
}
function getMangledNameForScopedPackage(packageName: string): string {
/* @internal */
export function getMangledNameForScopedPackage(packageName: string): string {
if (startsWith(packageName, "@")) {
const replaceSlash = packageName.replace(ts.directorySeparator, mangledScopedPackageSeparator);
if (replaceSlash !== packageName) {