Skip to content

JSDoc /** @type */ tags don't check return types #25424

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 Jul 4, 2018 · 2 comments
Closed

JSDoc /** @type */ tags don't check return types #25424

DanielRosenwasser opened this issue Jul 4, 2018 · 2 comments
Assignees
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Fixed A PR has been merged for this issue

Comments

@DanielRosenwasser
Copy link
Member

// @ts-check

/** @type {(x: number, y: number, z: number) => string} */
function foo(x, y, z) {
    return 100;
}

Expected: Error.
Actual: No error.

@DanielRosenwasser DanielRosenwasser changed the title JSDoc /** @type */ tags don't validate function declarations JSDoc /** @type */ tags don't check return types Jul 4, 2018
@mhegazy mhegazy added the Bug A bug in TypeScript label Jul 5, 2018
@mhegazy mhegazy added this to the TypeScript 3.1 milestone Jul 5, 2018
@mhegazy mhegazy added the checkJs Relates to checking JavaScript using TypeScript label Jul 5, 2018
@sandersn
Copy link
Member

sandersn commented Jul 6, 2018

Note: doesn't repro for function expressions:

var foo = function (...
// or
var bar = (...

@sandersn
Copy link
Member

sandersn commented Jul 6, 2018

getJSDocReturnType only looks at @return tags, it doesn't check @type tags to see whether their type node has a return type. Seems easy to fix.

@sandersn sandersn added the Fixed A PR has been merged for this issue label Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants