Skip to content

Using rest parameters in JavaScript type annotations seems broken in 3.1 #28637

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
the-ress opened this issue Nov 21, 2018 · 2 comments
Closed
Labels
Bug A bug in TypeScript Domain: JavaScript The issue relates to JavaScript specifically
Milestone

Comments

@the-ress
Copy link

TypeScript Version: 3.3.0-dev.20181121

Search Terms: js, javascript, A rest parameter must be of an array type

Code

//@ts-check
/** @type {(...bar: string[]) => void} */
function foo(...bar) {}

Expected behavior:
Doesn't report any errors. Type of bar parameter is string[].

Actual behavior:

asdf.js:3:14 - error TS2370: A rest parameter must be of an array type.

3 function foo(...bar) {}
               ~~~~~~

Found 1 error.

VS Code intellisense shows bar is string instead of string[].

TypeScript 3.0.3 works as expected, 3.1.1 and later versions don't.

@ahejlsberg ahejlsberg added the Bug A bug in TypeScript label Nov 24, 2018
@ahejlsberg
Copy link
Member

It appears to work if you use an @param tag, so there's always that workaround for now.

@sandersn sandersn added the Domain: JavaScript The issue relates to JavaScript specifically label Nov 26, 2018
@weswigham weswigham added this to the TypeScript 3.3 milestone Dec 8, 2018
@jakebailey
Copy link
Member

This was fixed by #39473.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: JavaScript The issue relates to JavaScript specifically
Projects
None yet
Development

No branches or pull requests

6 participants