Skip to content
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

Report Syntax Errors in JSDocs Type Annotations #13371

Closed
mjbvz opened this issue Jan 9, 2017 · 9 comments
Closed

Report Syntax Errors in JSDocs Type Annotations #13371

mjbvz opened this issue Jan 9, 2017 · 9 comments
Assignees
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jan 9, 2017

From microsoft/vscode#18229

TypeScript Version: 2.2.0-dev.20170109

Code
In a JS file:

/**
 * @param {(x)=>void} x 
 **/
function foo(x) { }

Expected behavior:
Reports a syntax error when trying to parse the JSDoc type annotation

Actual behavior:
No error reported. x has any type

@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Jan 9, 2017
@mhegazy mhegazy added Suggestion An idea for TypeScript Salsa labels Jan 9, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Jan 9, 2017

Also related to #6802

@ghost
Copy link

ghost commented May 12, 2017

This is more important now that we have @ts-check. Although turning on --noImplicitAny will tell you when you got a parse error.
Note: typeof foo and X & Y currently don't parse!

@mhegazy
Copy link
Contributor

mhegazy commented May 15, 2017

@sandersn, we also need to ensure that applicable quick fixes are working correctly in JSDoc, e.g. #15852

@ghost
Copy link

ghost commented May 15, 2017

Note: fixSpelling.ts would need to be updated so that getTokenAtPosition uses /*includeJsDocComment*/ true. (But that alone wouldn't be sufficent.)

@sandersn
Copy link
Member

@mhegazy @andy-ms that quick fix is for a semantic error. That's a separate issue from this one which reports syntax errors. I'll re-open #15852 to track that.

You're not talking about the quick fix "Disable checking for this file", right?

@sandersn
Copy link
Member

Fix is up at #16156

@sandersn sandersn added the Fixed A PR has been merged for this issue label May 30, 2017
@mhegazy mhegazy modified the milestones: TypeScript 2.4, TypeScript 2.5 Jun 5, 2017
@ghost
Copy link

ghost commented Jul 2, 2017

Just got tripped up by this:

// @ts-check

/** @typedef Foo {number} */

/** @type Foo */
const x = "";

This isn't an error today. Could we report an error on a @typedef tag where we didn't parse any type?

@Jessidhia
Copy link

Jessidhia commented Jul 5, 2017

The error there is actually on the @type tag rather than the @typedef. But yes, sounds reasonable to raise an error.

@ghost
Copy link

ghost commented Jul 5, 2017

@Kovensky Thanks, that is actually 2 errors in one. #16946 #16947

@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.5.2 milestone Aug 19, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

5 participants