-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generation
Milestone
Description
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; // stringExpected 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
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generation