Skip to content

@typedef's nested Object syntax disallows type arguments #36172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sandersn
Copy link
Member

Previously the jsdoc index signature syntax was incorrectly treated the same as Object:

/** @typedef {Object} AllowsNesting
 * @property ... */
/** @typedef {Object.<string,string>} IncorrectlyAllowsNesting */

Fixes #34911

The creator of the issue expected @property to work with Object.<string,string> as well, but that's not documented on jsdoc.app.
For example, @typedef could allow combining @typedef {Object<string,string>} X with @property {string} p to create type X = { [s: string]: string, p: string }.

Previously the jsdoc index signature syntax was incorrectly treated the
same as Object:

```js
/** @typedef {Object} AllowsNesting
 * @Property ... */
/** @typedef {Object.<string,string>} IncorrectlyAllowsNesting */
```

Fixes #34911
@sandersn
Copy link
Member Author

@weswigham you might be interested too, since you've worked with @typedef quite a bit before.

Copy link
Contributor

@elibarzilay elibarzilay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One side-comment: shouldn't there be some warning or some indication that stuff that you thing is doing something is actually ignored?

@sandersn
Copy link
Member Author

@elibarzilay We assume that lots of jsdoc with checkJS is still incorrect and it would be annoying to have errors on it all. We've thought about a strictCheckJS mode before but haven't come to any conclusions. Might be time to revisit the question.

@sandersn sandersn merged commit 1bbcb55 into master Jan 29, 2020
@sandersn sandersn deleted the nested-object-typedef-disallows-object-type-arguments branch January 29, 2020 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@property should only add a property to a @typedef with initial type of Object
6 participants