microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.33k stars 12.53k forks source link

Report errors (and quickfixes) for incorrect JSDoc #15852

Open ghost opened 7 years ago

ghost commented 7 years ago

TypeScript Version: nightly (2.4.0-dev.20170515)

Code

/**
 * @param abcdeg A parameter
 */
function f(abcdefg: number) {
    abcdeg;
}

Expected behavior:

Can fix spelling for either abcdeg.

Actual behavior:

Does not work in jsdoc.

mhegazy commented 7 years ago

well.. that means it is an error to have this JSDoc.

if we report this, why not report other things in jsdoc as well.. like invalid tags @params instead of @param...

mhegazy commented 7 years ago

I think this is subsumed by https://github.com/Microsoft/TypeScript/issues/13371

mhegazy commented 7 years ago

closing in favor of #13371

sandersn commented 7 years ago

Let's use this issue to track semantic errors for jsdoc. #13371 tracks syntactic errors.

There is still the open question of whether these errors (and associated quick fixes) should only be availble in js files with // @ts-check or in TS files as well.

brettz9 commented 6 years ago

Might there be optional report of missing JSDoc @param and @return?

And how about detection of a mismatch between actual return and @return/@returns?

ghost commented 6 years ago

@brettz9 Enable "checkJs": true inside compilerOptions in your tsconfig.json and you should get an error if a @return tag is incorrect.

/** @return {number} */
function g() { return ""; } // Error

Enable "noImplicitAny": true (or better, "strict": true) and you will get an error if a @param tag is missing.

function f(x) {} // Error, 'x' is implicitly 'any'