microsoft / microsoft/TypeScript

API about Identifier's scope

Open
#28,026 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I want to write a CustomTransformers for my webpack loader config.

Babel's visitors have API about scope
If I get a path of ImportDeclaration import * as React from "react", I can using path.scope.getBinding('React').referencePaths to get all reference paths using React.

Is there any API in TypeScript to get identifier's scope or referenced nodes/identifiers?

Also, Is there any API in TypeScript to get ImportDeclaration's moduleSpecifier's resolved source file? for example import * as React from "react"'s resolved source file is /home/me/my-ts-project/node_modules/react/cjs/react.development.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

Start by investigating the TypeScript compiler API for identifier scope and reference information, then examine how ImportDeclaration module specifiers are resolved. Done means documenting or exposing APIs that provide both referenced identifiers and the resolved source file for an import such as "react".

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.