Skip to content

checkJs error for indirect JSDoc param tag #19268

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
DanielRosenwasser opened this issue Oct 17, 2017 · 8 comments
Closed

checkJs error for indirect JSDoc param tag #19268

DanielRosenwasser opened this issue Oct 17, 2017 · 8 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

@DanielRosenwasser
Copy link
Member

TypeScript Version: 2.6.0-dev.20171015

// @ts-check

function Foo() {
    /**
     * @param {string} wat
     */
    this.bar = function(wat) {

    }
}

Expected: No error
Actual: JSDoc '@param' tag has name 'wat', but there is no parameter with that name.

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Salsa labels Oct 17, 2017
@DanielRosenwasser
Copy link
Member Author

Probably due to #18777.

@mhegazy mhegazy added the Domain: JSDoc Relates to JSDoc parsing and type generation label Oct 17, 2017
@mhegazy mhegazy added this to the TypeScript 2.7 milestone Oct 17, 2017
@OliverJAsh
Copy link
Contributor

Any chance this will be fixed in TS 2.6? This is a big blocker for us upgrading to 2.6, as we use JSDoc in many places.

As a workaround, I'm using @ts-ignore.

@sandersn
Copy link
Member

Yeah, it's certainly #18777 -- the type is correct, it just issues a spurious error.

@sandersn
Copy link
Member

Fix is up at #19355

@sandersn sandersn added the Fixed A PR has been merged for this issue label Oct 19, 2017
@OliverJAsh
Copy link
Contributor

@sandersn Thanks for getting this fixed so quickly!

@KtorZ
Copy link

KtorZ commented Nov 1, 2017

Hey!
I ran into a similar issue but from the other perspective. Using a destructuring assignment on the function argument, I got the following error:

/**
 * @param {Object} args 
 * @param {string} args.prop1
 * @param {string} args.prop2
 */
function patate({ prop1, prop2 }) {

}

// JSDoc '@param' tag has name 'args', but there is no parameter with that name.

The problem is the same using an enum syntax:

/**
 * @param {{prop1: string, prop2: string}} args 
 */
function patate({ prop1, prop2 }) {

}

Wouldn't it make sense not to raise this error in this case, but still be able to annotate the properties with the right types ?

@mhegazy
Copy link
Contributor

mhegazy commented Nov 1, 2017

@KtorZ this is tracked by #7429

@KtorZ
Copy link

KtorZ commented Nov 1, 2017

Sweet, thanks 👍

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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

5 participants