google / google/closure-compiler

When there is a var_args param, treat `arguments` like an Array of that type

Open
#577 7 comments 0 reactions 0 assignees View on GitHub
enhancement Types
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

While working on https://github.com/google/closure-compiler/issues/152 I found a few places we're lacking type information because we don't know the type of the `arguments` object. For example at https://github.com/google/closure-library/blob/d0bd16969214db45c6719604e59bd46da8fce616/closure/goog/math/box.js#L76-77

it is obvious that `coord` is a `goog.math.Coordinate` from the type of the var_args parameter. But the compiler treats it as "unknown" because it doesn't know that `arguments` is an Array\* of `goog.math.Coordinate`, so it doesn't know that `arguments[i]` is a `goog.math.Coordinate`.
- I know, it's not really an Array, but it's sufficiently Array-ish that we should know the type of its elements.

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.