microsoft / microsoft/TypeScript

quickfix: convert to es6 should add extension

Open
#45,490 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

TS Template added by @mjbvz

TypeScript Version: 4.3.5

Search Terms

  • code action
  • suggestion

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.59.0
  • OS Version: Mac 10.15.7

Steps to Reproduce:

  1. Take any commonjs project (not written in typescript)
  2. Do the quick fix of converting any javascript project into a ES6

Then the extension is omitted. I think it should automatically be added. Cuz ESM is strict about file paths.


  • old code: var dateFormat = require("../lib/dateformat");
  • after conversion: import dateFormat from "../lib/dateformat"; (file not found)
  • expected import dateFormat from "../lib/dateformat.js";

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the JavaScript-to-ES6 quick fix on a CommonJS project using the example import from ../lib/dateformat. Trace the quick-fix entry point and its tests, then verify that converted relative imports include the .js extension and no longer produce a file-not-found result.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.