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

In JS, bad error message for missing type argument in param tag #26285

Closed
sandersn opened this issue Aug 7, 2018 · 2 comments
Closed

In JS, bad error message for missing type argument in param tag #26285

sandersn opened this issue Aug 7, 2018 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@sandersn
Copy link
Member

sandersn commented Aug 7, 2018

/** @template T */
class CC {
    /** @param {T} t */
    constructor(t) {
    }
}
/** @param {CC} cc */
function foo(cc) {
}

Expected behavior:
Error, something like "Expected 1 type arguments, got 0".

Actual behavior:
Expected CC type arguments; provide these with an '@extends' tag.

The error message has 3 problems:

  1. The error message is intended for classes only (class DD extends CC { ... })
  2. The type isn't quoted.
  3. The expected number of type arguments isn't given.

I think the fix is two-fold:

  1. For parameters, go back to the normal error message.
  2. For classes, give the number of expected type arguments instead of the class name, which is already given. Reading the code, I'm almost certain this is a bug in which the code chooses between multiple messages and then passes them all the same arguments.
@sandersn sandersn added Salsa Bug A bug in TypeScript labels Aug 7, 2018
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.2 milestone Aug 8, 2018
@joma74
Copy link

joma74 commented Aug 15, 2018

My case

// App.js
/** @type {import("vue").ComponentOptions} */
let vueComponentOptions = {
}

gives

[ts] Expected ComponentOptions<V, Data, Methods, Computed, PropsDef, Props>-1 type arguments; provide these with an '@extends' tag.

which eventually may be the same issue.

P.S. For resolution of said ts ERROR as of TS 3.0.1 containing #14377 one can write

/** @typedef {import("vue").default} Vue */
/** @type {import("vue").ComponentOptions<Vue>} */
let vueComponentOptions = {
}

@sandersn
Copy link
Member Author

This is now fixed.

@sandersn sandersn added the Fixed A PR has been merged for this issue label Oct 31, 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 Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants