microsoft / microsoft/TypeScript

Support for custom Automatic Type Acquisition scopes.

Open
#23,952 5 comments 4 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
2d 4h
Merged PRs (30d)
132

Description

Search Terms

Automatic type acquisition scopes, custom type acquisition, acquire types from custom scope

Suggestion

The ability to specify in .tsconfig and/or IDE settings additional scopes to search beyond @types for type acquisition.

Use Cases

Private repositories with large amounts of JavaScript code and a small number of TypeScript developers who wish to produce accurate typings, and a high barrier to entry to modifying/adding declaration files to the JavaScript projects. This mirrors the public ecosystem with say, react and @types/react.

Examples

A new string array parameter of scopes to search for:

{
  "typeAcquisition": {
    "searchScopes": [
      "@companyname-types",
      "@types"
    ]
  }
}

This would also allow overriding the @types scope. The first scope with a matching declaration should win.

Checklist

My suggestion meets these guidelines:
[X] This wouldn't be a breaking change in existing TypeScript / JavaScript code
[X] This wouldn't change the runtime behavior of existing JavaScript code
[X] This could be implemented without emitting different JS based on the types of the expressions
[X] This isn't a runtime feature (e.g. new expression-level syntax)

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 locating the automatic type acquisition implementation and the tsconfig typeAcquisition handling, then trace how declaration package scopes are currently resolved. Define the configuration behavior for searchScopes, including ordering and @types overrides, and add coverage showing that the first matching declaration scope is selected.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
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.