fix(60505): Convert to namespace import refactoring should drop file extensions on namespace name (#60510)

This commit is contained in:
Oleksandr T. 2024-11-20 05:42:16 +02:00 committed by GitHub
parent b3c67d3202
commit d6b7c41fbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -4061,7 +4061,7 @@ export function moduleSymbolToValidIdentifier(moduleSymbol: Symbol, target: Scri
/** @internal */
export function moduleSpecifierToValidIdentifier(moduleSpecifier: string, target: ScriptTarget | undefined, forceCapitalize?: boolean): string {
const baseName = getBaseFileName(removeSuffix(moduleSpecifier, "/index"));
const baseName = getBaseFileName(removeSuffix(removeFileExtension(moduleSpecifier), "/index"));
let res = "";
let lastCharWasValid = true;
const firstCharCode = baseName.charCodeAt(0);

View File

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
// @allowJs: true
// @checkJs: true
// @filename: /a.js
/////*a*/import { a } from "./foo.js";/*b*/
////a;
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert import",
actionName: "Convert named imports to namespace import",
actionDescription: "Convert named imports to namespace import",
newContent:
`import * as foo from "./foo.js";
foo.a;`,
});