microsoft / microsoft/TypeScript

Error TS4020 or TS4023, working with mixins, base class has static symbol property, only when multiple files.

Open
#52,644 2 comments 2 reactions 1 assignee View on GitHub

@weswigham is already working on this.

Since Feb 17, 2023.

Needs Investigation Rescheduled
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

In the following code (file: index.ts)

export class TestComponent extends MixinComponent(Component<HTMLElement>)<number> {
}

I get error TS4020: 'extends' clause of exported class 'TestComponent' has or is using private name 'Test'.

I've gotten that error before and managed to fix it by exporting the "private name" the compiler is complaining about.

But in this case, said name IS being exported (file: component.decl.ts)

export const Test = Symbol("test");  // <--- HERE

export declare abstract class Component<T extends HTMLElement = HTMLElement> {
  readonly element: T;

  public static [Test]: string;
}

What other reason is there to cause this error? I don't see no "private name".

It's also a different error Exported variable 'MixinParent' has or is using name 'Test' from external module "/sandbox/component.decl" but cannot be named. if I put the inheritance in two separate lines (file: index.ts)

export const MixinParent = MixinComponent(Component<HTMLElement>);

export class AnotherTestComponent extends MixinParent<string> {
}
🔎 Search Terms

all in title.

🕗 Version & Regression Information

latest.
(declaration: true)

⏯ Playground Link

codesandbox.io link

in playground is not reproducible, I suppose because everything is in a single file, but here's a link anyway.

Playground link

💻 Code

above.

🙁 Actual behavior

errors.

🙂 Expected behavior

no errors.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.