Skip to content
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

@typedef supports nested @property names just like @param does #22967

Merged
merged 1 commit into from
Mar 29, 2018

Conversation

sandersn
Copy link
Member

Previously it did not, because this capability is not documented on usejsdoc.org. However, several people requested this feature.

/** @typedef {Object} App
 * @property {string} name
 * @property {Object} icons
 * @property {string} icons.image32
 * @property {string} icons.image64
 */

Now properly produces the type { name: string, icons: { image32: string, image64: string } }.

Fixes #20078

Previously it did not, because this capability is not documented on
usejsdoc.org. However, several people requested this feature.
@sandersn sandersn requested review from mhegazy and a user March 28, 2018 23:04
children = append(children, child);
let children: JSDocPropertyLikeTag[];
while (child = tryParse(() => parseChildParameterOrPropertyTag(target, name))) {
if (child.kind === SyntaxKind.JSDocParameterTag || child.kind === SyntaxKind.JSDocPropertyTag) {
Copy link

Choose a reason for hiding this comment

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

If we parsed an unexpected child we just drop it?

Copy link
Member Author

Choose a reason for hiding this comment

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

The alternative that I thought was to break here, but it seems worse to pop up a level and start ignoring the prefixes the way we did before this PR.
(You can see an example at the end of the test I added.)

This is consistent with our treatment of jsdoc elsewhere, although perhaps we should have an error like "@type in the middle of a nested @typedef property". I don't think this mistake will happen that often though.

@sandersn sandersn merged commit eca3d68 into master Mar 29, 2018
@sandersn sandersn deleted the js/typedef-tag-supports-nested-properties branch March 29, 2018 16:39
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants