microsoft / microsoft/TypeScript

Auto fix compilerOptions Lib

Open
#32,560 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Experience Enhancement Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Search Terms

compilerOptions Lib, autofix Lib, auto Lib generation, Auto compilerOptions

Suggestion

Suggest adding the appropriate library to compilerOptions.lib if you are using a feature that requires it.

Use Cases

  • Help the developer code by preventing them from having to look up which compilerOptions.lib setting they need to use a particual feature of the standard library. As it is difficult to remember which version of ES introduced which additions.
  • In the future this could be used to auto generate the compilerOptions.Lib the developer needs by the JS features they are using. Which would remove some configuration. 🎉

Examples

Object.entities(object).map(([key, value]) => {
  ...
});

📎💬 “Looks like your using Object.entities, would you like to add 'es2017.object' to your compilerOptions.lib?”


if (array.includes(testValue)) {
  ...
}

📎💬 “Looks like your using Array.include, would you like to add 'es2016.array.include' to your compilerOptions.lib?”

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

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

Start by reviewing the issue's compilerOptions.lib proposal and the Object.entries and Array.includes examples. Define how feature usage would map to library names such as es2017.object and es2016.array.include, and consider the broader auto-generation use case; done means the design and scope are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.