microsoft / microsoft/TypeScript

JSDoc property on typedef can only extend `Object` type

Offen
#31,410 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug Domain: JSDoc
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

TypeScript Version: 3.4.0-dev.201xxxxx

Search Terms: typedef jsdoc widen extend property

Code

/**
 * @typedef {Array} A
 * @property {string} a
 */
/**
 * @type {A}
 */
var a;
a.a; // Property 'a' does not exist on type 'any[]'.
/**
 * @typedef {any[]} B
 * @property {string} b
 */
/**
 * @type {B}
 */
var b;
b.b; // Property 'b' does not exist on type 'any[]'.
/**
 * @typedef {{}} C
 * @property {string} c
 */
/**
 * @type {C}
 */
var c;
c.c; // Property 'c' does not exist on type '{}'.
/**
 * @typedef {Object} O
 * @property {string} o
 */
/**
 * @type {O}
 */
var o;
o.o; // string

Expected behavior:

Other types to behave similarly? I thought non-alias typedefs would act like

type __X = {}; // from @typedef type expression
interface X extends __X {
    x: string // from @property
}

Either way of making it not work for object or allowing it to work for other types seems reasonable.

Actual behavior: Object is treated as a special type that doesn't behave like other types. See comments in example for errors when using other types.

Playground Link: it is JSDoc, can't.

Related Issues: n/a

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 damit, die JSDoc-Beispiele für typedefs auf Grundlage von Array, any[], {}, und Object zu reproduzieren und prüfe, wie jede @property angewendet wird. Vergleiche die beobachteten Diagnosen mit dem im Issue beschriebenen erwarteten Verhalten und betrachte die Arbeit als abgeschlossen, wenn das gewählte Verhalten durch Regressionstests für alle vier Fälle abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 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.