Skip to content

Commit

Permalink
fix(60505): Convert to namespace import refactoring should drop file …
Browse files Browse the repository at this point in the history
…extensions on namespace name (#60510)
  • Loading branch information
a-tarasyuk authored Nov 20, 2024
1 parent b3c67d3 commit d6b7c41
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions tests/cases/fourslash/refactorConvertImport_namedToNamespace11.ts
Original file line number Diff line number Diff line change
@@ -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;`,
});

0 comments on commit d6b7c41

Please sign in to comment.