microsoft / microsoft/TypeScript

lib.es*.d.ts: constructor methods

Open
#44,883 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: lib.d.ts Help Wanted
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the relevant lib.es*.d.ts declarations and reproduce the reported [].constructor[Symbol.species] error using the supplied sample or Playground link. Check the built-in interfaces described in the issue and ensure the constructor definitions support this access pattern; the sample should compile without the reported error when the work is done.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.