Microsoft/TypeScript

Language service: open Type.id

Open

#5.687 geöffnet am 16. Nov. 2015

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
Domain: APIHelp WantedSuggestion

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

I am using language service to "traverse" the program, and I would like very much to "remember" which types and symbols I already saw, and to cache my computation results for them. Performance boost and avoiding infinite loops.

The compiler very helpfully supplies id for Type, Symbol and Node, and it seems to be "really, really" unique for symbols and nodes, and "relatively unique" (i.e. within a given typechecker) for types.

The problem is, however, that, unlike nodes and symbols, types hide their ids behind the "internal" qualifier and the lack of accessor function, making them not legally visible to me as a consumer of the language service. Of course, this being JavaScript, nothing prevents me from accessing them anyway, and that is what I currently do, but this is not ideal, because I am not protected from the code evolution in the future.

So it seems to me that nothing stands in the way of adding a getTypeId method to the typechecker, unless I'm missing something very important.

Contributor Guide