Skip to content

Array spread operator does not resolve type correctly (for javascript in vscode)Β #47462

@goestav

Description

@goestav

Bug Report

πŸ”Ž Search Terms

array spread, jsdoc spread operator, spread operator type

πŸ•— Version & Regression Information

  • This happens in every version I tried, I searched through the FAQ and issues for related issues.

⏯ Playground Link

Does not seem to occur in typescript.

πŸ’» Code

const mapOfStrings = new Map([["foo", "bar"]])

const arrayOfStrings = [...mapOfStrings.values()]
//    ^ should be type string[]

πŸ™ Actual behavior

The type shown in VSCode is any[] while it should be string[].

  • VSCode 1.63.2 (commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3)
  • OS: MacOS 12.0.1 (21A559)
  • Typescript 4.5.4

wrong array spread type

πŸ™‚ Expected behavior

The type should be string[] as shown below (this does work with Array.from()).

const arrayOfStrings string

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions