microsoft / microsoft/TypeScript
Compiler API: Expose More from typescript.d.ts
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 2.9.0-dev.20180426
While Traversing the TypeScript AST of a source file, there have been a number of helpful things I've found by extending ts.* from typescript.d.ts and I would like it if these could be exposed (or not marked /* @internal */).
Search Terms:
typescript.d.ts
Node.locals
Symbol.parent
getContainingFunction
isAssignmentTarget
Code
declare namespace ts {
interface Node {
/* @internal */ readonly locals?: SymbolTable; // Locals associated with node (initialized by binding)
}
interface Symbol {
/* @internal */ readonly parent?: Symbol; // Parent symbol
}
function getContainingFunction(node: Node): SignatureDeclaration | undefined;
function isAssignmentTarget(node: Node): boolean;
}
Note:
- Added
readonlyforNode#locals&Symbol#parent - For
Symbol#parent, the goal is: given the symbol for a method (e.g.,methodSymbolforNumber#toString) find where that method is defined (e.g.,Number)... maybeprogram.getTypeChecker().getSymbolAtLocation(methodSymbol.valueDeclaration.parent)is what is "supposed" to be used instead? - For
ts.getContainingFunction()it seems more appropriate to have a return type ofSignatureDeclaration | undefinedinstead ofSignatureDeclaration
Related Issues:
#15841
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the public declarations in typescript.d.ts and compare the listed Node.locals, Symbol.parent, getContainingFunction, and isAssignmentTarget members with their compiler implementations. Resolve the stated API and return-type questions, then verify that the intended members are exposed consistently for Compiler API consumers.
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
- 30/100