microsoft / microsoft/TypeScript

Missing computed properties in declaration emit

Offen
#61,068 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

In Discussion Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

With #60052, we now emit qualified names rather than generate an index signature for computed names in classes; however, this now puts us in an awkward place where regardless of errors, declaration emit diverges on isolatedDeclarations.

Playground Links:

export const greeting: unique symbol = Symbol();
export const count: unique symbol = Symbol();

export class MyClass1 {
    [greeting]: string = "world";
    [count]: number = 42;
}

export enum PropertyNames {
    greeting = "greeting",
    count = "count",
}

export class MyClass2 {
    [PropertyNames.greeting]: string = "world";
    [PropertyNames.count]: number = 42;
}

export let prop!: string;

export class MyClass3 {
    [prop]: () => void = () => {}
}

Compared to --isolatedDeclarations false The declaration emit lacks expected contents in MyClass1 and MyClass2:

  export declare const greeting: unique symbol;
  export declare const count: unique symbol;
  export declare class MyClass1 {
-     [greeting]: string;
-     [count]: number;
  }
  export declare enum PropertyNames {
      greeting = "greeting",
      count = "count"
  }
  export declare class MyClass2 {
-     [PropertyNames.greeting]: string;
-     [PropertyNames.count]: number;
  }
  export declare let prop: string;
  export declare class MyClass3 {
      [prop]: () => void;
  }

It is surprising that prop is emitted regardless of --isolatedDeclarations, but not the other contents.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem in den Playground-Links gezeigten Verhalten der TypeScript-Deklarationsausgabe und vergleiche die Ausgabe mit und ohne --isolatedDeclarations für MyClass1, MyClass2 und MyClass3. Verfolge die Behandlung berechneter Eigenschaften und stelle sicher, dass die Deklarationsausgabe die erwarteten berechneten Eigenschaften beibehält, während das aktuelle prop-Verhalten erhalten bleibt; überprüfe den Diff der ausgegebenen Deklarationen anhand des Beispiels.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.