Skip to content

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

Closed
@the-ress

Description

@the-ress

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specifically

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions