Microsoft/TypeScript

lib.es*.d.ts: constructor methods

Open

#44,883 创建于 2021年7月3日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: lib.d.tsHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

lib Update Request

Configuration Check

My compilation target is ES2015 and my lib is the default.

Missing / Incorrect Definition

Array and other interfaces for built-ins do not declare their own constructor methods

Sample Code

[].constructor[Symbol.species];
Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index type 'Function'.
  Property '[SymbolConstructor.species]' does not exist on type 'Function'.

The code compiles fine when defining the appropriate constructor method:

declare global {
  interface Array<T> {
    constructor: ArrayConstructor;
  }
}

Playground link

Documentation Link

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor

贡献者指南