microsoft / microsoft/TypeScript

In JSDocs notation for index signatures, Object and object should be treated as the same

Open
#20,555 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: JSDoc In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 2.7.0-dev.201xxxxx

Code

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

Expected behavior:

obj should have a index signature as in #15105

Actual behavior:

obj is treated as any

Additional Info:

This was mentioned in the above issue, and it seems to be related to the way Typescript manage Object and object, but in JSDocs, they are treated similar.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided JSDoc example with the TypeScript version under investigation and compare it with the behavior described in issue #15105. Trace how the JSDoc index-signature annotation is interpreted, then verify that object.<string, number> gives obj an index signature instead of any.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.