microsoft / microsoft/TypeScript
JSDoc property on typedef can only extend `Object` type
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
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; // 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the JSDoc examples for typedefs based on Array, any[], {}, and Object, checking how each @property is applied. Compare the observed diagnostics with the expected behavior described in the issue, and consider the work complete when the chosen behavior is covered by regression tests for all four cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100