google / google/closure-compiler

Unknown type when accessing string in array-like fashion

Open
#3,538 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

The following code produces no warning despite the type mismatch on the second line:
```
var c = "abc"[1];
var /**number*/ n = c; // no warning
```
It looks like getting a character from a string in this way produces a value of unknown type (I have confirmed this by turning `reportUnknownTypes` on).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.