microsoft / microsoft/TypeScript

Return export nodes of ast when resolving alias symbol

Open
#36,972 1 comment 1 reaction 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

export star node

Suggestion

Add an API which returns alias symbol of import specifier and the export nodes on the searching path.

Use Cases

I want to write a little tool to extract certain type in typescript code and its dependent types.
Current approaches just return the alias symbol, and it's difficult to establish relationship between import specifier and export star statements.

Examples

a.ts:

import {C} from './b';

b.ts:

export * from './c';
export * from './d';
export * from './e';

c.ts:

export const C = 1;

I want to get not only the location of symbol "C", but also the export star node in the AST of "b.ts", which is "export * from './c'".

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

No files, tests, or compiler entry points are named. Start by tracing how alias symbols and export-star declarations are resolved for the import in the example; done means a public API returns both the alias symbol and the export nodes on the search path without changing emitted JavaScript.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.