microsoft / microsoft/TypeScript

JSDoc optional/required variant doesn't play well with multi-@param RecordType declarations

Open
#23,397 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

TypeScript Version: 2.9.0-dev.20180330

Search Terms: as mentioned in this comment, I'm opening this issue because with this JSDoc syntax typescript doesn't recognize the params correctly.

Code

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

/**
 * @param {!object} args 
 * @param {!string} args.prop1
 * @param {?string} args.prop2
 */
function patate(args) {
  const { prop1, prop2 } = args;
} 

Expected behavior: No errors

Actual behavior: With allowJs and checkJs, I get JSDoc '@param' tag has name 'prop1', but is no parameter with that name.

Playground Link:

Related Issues: https://github.com/Microsoft/TypeScript/issues/19645

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 with the self-contained JavaScript example in the issue and run tsc with allowJs and checkJs enabled. Investigate how the compiler handles the multi-@param JSDoc declaration; done means the example produces no diagnostic for args.prop1 or args.prop2.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.