microsoft / microsoft/TypeScript

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

オープン
#52,644 コメント 2 件 リアクション 2 件 担当者 1 名 GitHub で見る

@weswigham がすでに取り組んでいます。

2023年2月17日 から。

Needs Investigation Rescheduled
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。