Microsoft/TypeScript

`typeChecker.getTypeArguments` returns unexpected extra type argument

Open

#38.391 geöffnet am 7. Mai 2020

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

Repository-Metriken

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

Beschreibung

TypeScript Version: 3.8.3

Search Terms: getTypeArguments

Code

Given input like

class X extends Y<string> {}

Call typeChecker.getTypeArguments(typeChecker.getTypeAtLocation(...)) on the Y<string> node.

Expected behavior: You get back one type argument (string).

Actual behavior: You get back two, string and X.

I imagine this is maybe something around how TS handles this typing internally, but as a user of the API I'm not sure I can predict when this function returns these or not.

Playground Link:

Related Issues: https://github.com/microsoft/TypeScript/issues/33693 suggests this API changed recently

Contributor Guide