dsherret / dsherret/ts-morph

Organize Imports with specific ending for module node16

Open
#1,470 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6.2k
Forks
238
Avg merge
2m
Merged PRs (30d)
1

Description

Hello 👋 ,

For files with node resolution set to `node16` (and moduleResolution set to `node16` as well) , I need to append a file extension to my imports.

I create several files in memory, and call `file.organizeImports` at the end. After that I want to write the files to disc getting each files contnt with `file.getFullText()`

I found (what I think is) the right setting:

```ts
file.organizeImports({}, this.userPreferences, {
importModuleSpecifierEnding: 'js',
});
```
But it has no effect 🤔

My compiler options:
```
compilerOptions: {
module: 99,
moduleResolution: 3,
target: ScriptTarget.ESNext,
}

```

I wonder what I'm missing?

Contributor guide

Open the contributing guide

Research direction

Start with the file.organizeImports entry point and its importModuleSpecifierEnding option, using the provided node16 compiler options as the reproduction. Check why the 'js' ending has no effect when files are created in memory, then verify that the generated imports contain the expected extensions before writing file.getFullText() output to disk.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.