Skip to content

JSDoc, Erroneous "TS2350" for js tagged constructors called with incorrect parameters. #26122

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
jameskeane opened this issue Aug 1, 2018 · 0 comments · Fixed by #26124
Closed
Labels
Bug A bug in TypeScript checkJs Relates to checking JavaScript using TypeScript Domain: Error Messages The issue relates to error messaging Domain: JavaScript The issue relates to JavaScript specifically Domain: JSDoc Relates to JSDoc parsing and type generation Fixed A PR has been merged for this issue

Comments

@jameskeane
Copy link
Contributor

TypeScript Version: master

Search Terms: jsdoc

Code

/**
 * @param {number} num
 * @constructor
 */
var E = function (num) {};
var k = new E();

Expected behavior:

error TS2554: Expected 1 arguments, but got 0.

Actual behavior:

error TS2350: Only a void function can be called with the 'new' keyword.
error TS2554: Expected 1 arguments, but got 0.

Playground Link:
https://www.typescriptlang.org/play/#src=%0D%0A%2F**%0D%0A%20*%20%40param%20%7Bnumber%7D%20num%0D%0A%20*%20%40constructor%0D%0A%20*%2F%0D%0Avar%20E%20%3D%20function%20(num)%20%7B%7D%3B%0D%0Avar%20k%20%3D%20new%20E()%3B%0D%0A

Related Issues:
#25979

jameskeane added a commit to jameskeane/TypeScript that referenced this issue Aug 1, 2018
When `resolveCall` does not resolve in `resolveNewExpression`, the error should only be thrown if there is a *defined* signature that is not-void.
@ghost ghost added Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Domain: JSDoc Relates to JSDoc parsing and type generation checkJs Relates to checking JavaScript using TypeScript Salsa Domain: JavaScript The issue relates to JavaScript specifically Fixed A PR has been merged for this issue labels Aug 1, 2018
sandersn pushed a commit that referenced this issue Aug 1, 2018
…orrect parameters (#26124)

* Fixes #26122.

When `resolveCall` does not resolve in `resolveNewExpression`, the error should only be thrown if there is a *defined* signature that is not-void.

* Fix other baselines to remove erroneous TS2350.
@mhegazy mhegazy added this to the TypeScript 3.1 milestone Aug 2, 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 Domain: Error Messages The issue relates to error messaging Domain: JavaScript The issue relates to JavaScript specifically Domain: JSDoc Relates to JSDoc parsing and type generation Fixed A PR has been merged for this issue
Projects
None yet
2 participants