Skip to content

Commit 2e797c8

Browse files
Trim away compilerOptions preference
1 parent 37df8fa commit 2e797c8

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/compiler/utilities.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9139,9 +9139,7 @@ export function usesExtensionsOnImports({ imports }: SourceFile, hasExtension: (
91399139

91409140
/** @internal */
91419141
export function getModuleSpecifierEndingPreference(preference: UserPreferences["importModuleSpecifierEnding"], resolutionMode: ResolutionMode, compilerOptions: CompilerOptions, sourceFile: SourceFile): ModuleSpecifierEnding {
9142-
if (preference === "js" ||
9143-
resolutionMode === ModuleKind.ESNext ||
9144-
[ModuleResolutionKind.Node16, ModuleResolutionKind.NodeNext].includes(compilerOptions.moduleResolution!)) {
9142+
if (preference === "js" || resolutionMode === ModuleKind.ESNext) {
91459143
// Extensions are explicitly requested or required. Now choose between .js and .ts.
91469144
if (!shouldAllowImportingTsExtension(compilerOptions)) {
91479145
return ModuleSpecifierEnding.JsExtension;

tests/cases/fourslash/moveToNewFile_importFileExtensionsNonTypeModule.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
////console.log(someLibFn());
1919

2020
// @Filename: /other.ts
21-
////import { someLibFn } from "./src/main.js";
21+
////import { someLibFn } from "./src/main";
2222
////
2323
////function someOtherFn(): string {
2424
//// return someLibFn();
2525
////}
2626

2727
// @Filename: /act/action.ts
28-
////import { someLibFn } from "../src/main.js";
28+
////import { someLibFn } from "../src/main";
2929
////
3030
////function doAction(): string {
3131
//// return someLibFn();
@@ -35,30 +35,30 @@
3535
verify.moveToNewFile({
3636
newFileContents: {
3737
"/src/main.ts":
38-
`import { someLibFn } from "./someLibFn.js";
38+
`import { someLibFn } from "./someLibFn";
3939
4040
export function main(): string {
4141
return "hello world!";
4242
}
4343
console.log(someLibFn());`,
4444

4545
"/src/someLibFn.ts":
46-
`import { main } from "./main.js";
46+
`import { main } from "./main";
4747
4848
export function someLibFn(): string {
4949
return main();
5050
}
5151
`,
5252

5353
"/other.ts":
54-
`import { someLibFn } from "./src/someLibFn.js";
54+
`import { someLibFn } from "./src/someLibFn";
5555
5656
function someOtherFn(): string {
5757
return someLibFn();
5858
}`,
5959

6060
"/act/action.ts":
61-
`import { someLibFn } from "../src/someLibFn.js";
61+
`import { someLibFn } from "../src/someLibFn";
6262
6363
function doAction(): string {
6464
return someLibFn();

0 commit comments

Comments
 (0)