Skip to content

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

@brad4d

Description

@brad4d

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);
         ^

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions