google / google/closure-compiler

void() operator results in unknown type

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

Description

The `BanUnknownTypedClassPropsReferences` conformance rule chokes on expressions inside `void()`.

``` js
[].push(1);
void([].push(1));
```

The second line produces an error:

```
The property "push" on type "Array"
void([].push(1));
```

Strangely, the error still knows what the type is.

http://closure-compiler-debugger.appspot.com/#input0%3D%255B%255D.push(1)%253B%250Avoid(%255B%255D.push(1))%253B%26input1%26conformanceConfig%3Drequirement%253A%2520%257B%250A%2520%2520type%253A%2520CUSTOM%250A%2520%2520java_class%253A%2520'com.google.javascript.jscomp.ConformanceRules%2524BanUnknownTypedClassPropsReferences'%250A%2520%2520error_message%253A%2520'No%2520properties%2520on%2520unknown%2520types!'%250A%257D%26externs%26refasterjs-template%26includeDefaultExterns%3D1%26CHECK_SYMBOLS%3D1%26CHECK_TYPES%3D1%26CLOSURE_PASS%3D1%26LANG_IN_IS_ES6%3D1%26MISSING_PROPERTIES%3D1%26PRESERVE_TYPE_ANNOTATIONS%3D1%26PRETTY_PRINT%3D1%26TRANSPILE%3D1

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.