Microsoft/TypeScript

`typeChecker.getTypeArguments` returns unexpected extra type argument

开放

#38,391 创建于 2020年5月7日

 (1 条评论) (0 个反应) (0 位负责人)TypeScript (13,395 个派生)batch import
BugDomain: APIHelp Wanted

仓库指标

星标
 (108,860 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南