Skip to content

Support Object.<type1, type2> JSDoc notation for index signatures #15105

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

Closed
mjbvz opened this issue Apr 10, 2017 · 7 comments
Closed

Support Object.<type1, type2> JSDoc notation for index signatures #15105

mjbvz opened this issue Apr 10, 2017 · 7 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 VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Apr 10, 2017

From: microsoft/vscode#24291
TypeScript Version: 2.2.2

Code

/**
 * Test.
 *
 * @param {Object.<string, number>} obj An object.
 */
function func(obj) {
	console.log(obj);
}

Expected behavior:

obj has a type of Object<string, number> (at at least some equivalent type with an index signature). This syntax is valid according to http://usejsdoc.org/tags-type.html

Actual behavior:
obj has an any type

@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Apr 10, 2017
@mjbvz mjbvz changed the title Support Object.<type1, type2> in JSDoc Support Object.<type1, type2> type notation in JSDoc Apr 10, 2017
@mhegazy mhegazy added the Domain: JSDoc Relates to JSDoc parsing and type generation label Apr 20, 2017
@mhegazy mhegazy added this to the TypeScript 2.4 milestone Apr 20, 2017
@mhegazy mhegazy added the Bug A bug in TypeScript label Apr 20, 2017
@mhegazy mhegazy added the Salsa label May 11, 2017
@mhegazy mhegazy assigned yuit and unassigned sandersn May 24, 2017
@yuit
Copy link
Contributor

yuit commented Jun 1, 2017

I think {object} and {Object} both should be object type and only object type is assignable to it. Because it is any at the moment, all kind of stuffs are allowed

@sandersn sandersn changed the title Support Object.<type1, type2> type notation in JSDoc Support Object.<type1, type2> JSDoc notation for index signatures Jul 13, 2017
@sandersn sandersn assigned sandersn and unassigned yuit Jul 17, 2017
@sandersn sandersn added the Fixed A PR has been merged for this issue label Jul 17, 2017
@sandersn
Copy link
Member

Fix is up at #17254

@michaeljota
Copy link

michaeljota commented Dec 7, 2017

Should the fix work with object.<string, T> annotations or just with capitalized Object.<string, T>?

I ask because it does not seems to work with the former.

@sandersn
Copy link
Member

sandersn commented Dec 7, 2017

The code currently only checks for Object, not object. But note that we treat Object as different from object in Javascript already: Object is a synonym for any, but object means "anything that's not number/boolean/string/null/undefined".

Feel free to open an issue and we can decide what the correct behaviour should be.

@michaeljota
Copy link

I understand that when is being used as a JSDoc annotation, object and Object should be treated as the same, but I may be wrong. I will try to post another issues with similarities on this.

@sandersn
Copy link
Member

sandersn commented Dec 7, 2017

Yep, the current behaviour may be wrong because it is largely inherited from Typescript. A new issue to discuss it would be helpful so we can examine all the issues.

@michaeljota
Copy link

Done. 👍 Thanks you.

@microsoft microsoft locked and limited conversation to collaborators Jun 21, 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 VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

5 participants