microsoft / microsoft/TypeScript

TypeScript refactoring: option to use `export default` with "Move to a new file"

Open
#58,894 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Among other reasons, I'd like to avoid barrel files and I find that default exports make doing so more intuitive (named exports are easily spread into a barrel file while default exports not so much).

Some files like default exports and some folks do not. I get that.

Unless there's a need to do so, I'd like VSCode to make it just as easy to use default exports as named exports. Today, TypeScript refactoring with Visual Studio Code favors named exports. This default behavior may provide some encouragement/bias to use them and not use default exports as much.

There is also a "Convert between default export and named export" refactoring which is handy but requires another step and an aware/intentional decision to use default exports.

Can "Move to a new file" be split into two options or otherwise support prompting developers to explicitly select which type of export to use while they are refactoring?

e.g.

  1. "Move to a new file as default export"
  2. "Move to a new file as named export"

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

Read the linked TypeScript refactoring documentation and start from the “Move to a new file” refactoring described in the issue. Define the scope for offering explicit default-export and named-export choices; done means users can select either export style during that refactoring.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.