microsoft / microsoft/TypeScript

`extends ArrayBufferLike` works for own package; but causes errors for downstream users

Open
#35,172 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Proposal Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 3.5.1

Search Terms:

  • extends ArrayBufferLike
  • TS2312
  • An interface can only extend an object type or intersection of object types with statically known members.

Code

Repro,
https://github.com/AnyhowStep/ts-issue-35172

The line of code that introduced the problem,
https://github.com/AnyhowStep/type-mapping/commit/cb420b8e14dda4de5bf017bcc4a3ab3f35e71de5#diff-f84343d86daf9a112cfa32bdb89c7cdaR2

The following is safe to use on own package and downstream packages,

interface Buffer {
    ___doesNotExist? : any;
}

The following causes downstream packages to break,

interface Buffer extends ArrayBufferLike {
    ___doesNotExist? : any;
}

Expected behavior:

Option A:

  • Should crash for own package
  • Should crash for downstream packages

Option B:

  • Should not crash for own package
  • Should not crash for downstream packages

Actual behavior:

  • Does not crash for own package
  • Crashes for downstream packages

Playground Link:

None.

But I have repro steps,

https://github.com/AnyhowStep/ts-issue-35172

Related Issues:

None that I could find.

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 linked AnyhowStep/ts-issue-35172 reproduction and compare the two Buffer declarations in the issue, including the referenced type-mapping commit. Confirm the downstream-package failure and determine whether the compiler should reject the declaration consistently or accept it consistently; done means the chosen behavior is reproduced and covered by an appropriate regression test.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.