Skip to content

Commit d6b7c41

Browse files
authored
fix(60505): Convert to namespace import refactoring should drop file extensions on namespace name (#60510)
1 parent b3c67d3 commit d6b7c41

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/services/utilities.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4061,7 +4061,7 @@ export function moduleSymbolToValidIdentifier(moduleSymbol: Symbol, target: Scri
40614061

40624062
/** @internal */
40634063
export function moduleSpecifierToValidIdentifier(moduleSpecifier: string, target: ScriptTarget | undefined, forceCapitalize?: boolean): string {
4064-
const baseName = getBaseFileName(removeSuffix(moduleSpecifier, "/index"));
4064+
const baseName = getBaseFileName(removeSuffix(removeFileExtension(moduleSpecifier), "/index"));
40654065
let res = "";
40664066
let lastCharWasValid = true;
40674067
const firstCharCode = baseName.charCodeAt(0);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @allowJs: true
4+
// @checkJs: true
5+
6+
// @filename: /a.js
7+
/////*a*/import { a } from "./foo.js";/*b*/
8+
////a;
9+
10+
goTo.select("a", "b");
11+
edit.applyRefactor({
12+
refactorName: "Convert import",
13+
actionName: "Convert named imports to namespace import",
14+
actionDescription: "Convert named imports to namespace import",
15+
newContent:
16+
`import * as foo from "./foo.js";
17+
foo.a;`,
18+
});

0 commit comments

Comments
 (0)