question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Strange error: string is not a string type

See original GitHub issue

TypeScript Version: 4.1.2

Search Terms: downlevelIteration, string, spread

Code

function test(name: string) {
    for (const _char of [...name]) {
    }
}

Run tsc on just this ts file with no extra flags (I couldn’t find the right combination of playground checkboxes to simulate this.

Expected behavior: Assuming the code is wrong, the error message should probably not say that string is not a string type.

Actual behavior:

error TS2569: Type 'string' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of 
iterators.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
amcaseycommented, Dec 10, 2020

@RyanCavanaugh 4.1.2 (as in the description 😛)

0reactions
aminpakscommented, Dec 13, 2020

Please guide me a little bit as this is my first PR. Thanks!

https://github.com/microsoft/TypeScript/pull/41948

Read more comments on GitHub >

github_iconTop Results From Across the Web

TS Error: Type 'string' is not an array type or a ... - Stack Overflow
Show activity on this post. TS throws strange error: Error:(125, 18) TS2569: Type 'string' is not an array type or a string type....
Read more >
Fix C++ Error: String is Undefined - Linux Hint
Undefined string in C++ programming refers to when a program fails to compile, when it executes wrong, crashes or produces inaccurate results, or...
Read more >
ERR34-C. Detect errors when converting a string to a number
The string might not contain a number. It might contain a number of the correct type that is out of range (such as...
Read more >
Panic column:string is not type of time
Yet I get a strange error: Error: panic: column create_datetime:string is not of type time. I didn't even get to the to() part....
Read more >
Strange "TypeError: string indices must be integers" when ...
Algorithm parameters should be a dictionary object not a string object. When you pass your procString variable, you are giving the parameters ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found