google / google/closure-compiler

Clarify type errors where value is possibly null or undefined, but otherwise correct.

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

Description

When a type mismatch is wrong only in that the RHS could be null or undefined, explicitly
saying so in the error message can save significant developer frustration.

Error messages like this one are fine when the types are relatively simple,
but for large, nested type definitions it can become a sea of text in which it's really hard to see
that the only problem is that the value could be null.

```
JSC_TYPE_MISMATCH: actual parameter 1 of useFoo does not match formal parameter
found : ({a: string, b: number}|null)
required: {a: string, b: number} at line 18 character 9
useFoo(foo);
^
```

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.