microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.65k stars 12.44k forks source link

Return export nodes of ast when resolving alias symbol #36972

Open ooyyloo opened 4 years ago

ooyyloo commented 4 years ago

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:

ooyyloo commented 4 years ago

I could contribute codes to implement this feature.