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

Handle nested properties in JSDoc @typedef #20078

Closed
fongandrew opened this issue Nov 16, 2017 · 3 comments
Closed

Handle nested properties in JSDoc @typedef #20078

fongandrew opened this issue Nov 16, 2017 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Fixed A PR has been merged for this issue

Comments

@fongandrew
Copy link

TypeScript Version: 2.7.0-dev.20171116

Code

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

/** @type {App} */
const app = {
	name: 'name',
	icons: {
		image32: 'x.png',
		image64: 'y.png' 
	}
};

Expected behavior: No error.

Actual behavior: Error. TypeScript treats the above typedef as defining something like this:

interface App {
  name: string;
  icons: any;
  image32: string;
  image64: string;
}

When what we really want is this:

interface App {
  name: string;
  icons: {
    image32: string;
    image64: string;
  }
}

The @property {type} parent.nestedProp syntax can be found here (http://usejsdoc.org/tags-property.html). TypeScript currently supports a similar syntax when used with @param but not with @property.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 17, 2017

Duplicate of #7429

@mhegazy mhegazy marked this as a duplicate of #7429 Nov 17, 2017
@mhegazy mhegazy added the Duplicate An existing issue was already created label Nov 17, 2017
@fongandrew
Copy link
Author

@mhegazy This isn't a duplicate. #7429 concerns the use of @param with dotted names. This PR concerns the use of @property. As of 2.7.0-dev.20171116, the former works but not the latter.

@mhegazy mhegazy added Domain: JSDoc Relates to JSDoc parsing and type generation Bug A bug in TypeScript and removed Duplicate An existing issue was already created labels Nov 17, 2017
@NemoStein
Copy link

Any news on this?

@mhegazy mhegazy added this to the TypeScript 2.9 milestone Mar 27, 2018
@mhegazy mhegazy added Fixed A PR has been merged for this issue Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet labels Mar 28, 2018
@mhegazy mhegazy reopened this Apr 2, 2018
@mhegazy mhegazy removed the Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet label Apr 2, 2018
@mhegazy mhegazy closed this as completed Apr 2, 2018
@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
Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants