Skip to content

Spread syntax doesn't work for strings for arrays #2435

Description

@highlou

Hi I was working on some project and had an issue with the spread operator on strings.

How to replicate:

  • Go to JSFiddle
  • Select TypeScript
  • Remove the default code in the TypeScript panel
  • Paste this TypeScript code
let chars = [...'hello'];
console.log(chars);
  • Click Run

After clicking run, it shows in the console (on my end):

"[Line 15] Uncaught TypeError: Cannot use 'in' operator to search for '0' in hello"

Here's a screenshot:
Image

Here's also the link to the JSFIddle.

I'm using .split('') in the meantime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions