microsoft / microsoft/TypeScript
JSDoc property on typedef can only extend `Object` type
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo gli esempi JSDoc per i typedef basati su Array, any[], {}, e Object, verificando come viene applicata ogni @property. Confronta le diagnosi osservate con il comportamento previsto descritto nell’issue e considera completato il lavoro quando il comportamento scelto è coperto da test di regressione per tutti e quattro i casi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100