Skip to content

Better diagnostics for nullness inference related errors #17433

Open
@psfinaki

Description

@psfinaki

I think it would be good to be more explicit about nullness inference happening behind the scenes.

For the code

let xs = [| ""; ""; null |]

we'll get

Nullness warning: The type 'string' does not support 'null'

It would be helpful to have something like

"xs was inferred to have the type string[] but got null among its values. Either explicitly specify null in the return type ((string | null)[]), or remove null from the collection - or suppress the warning but no please don't."

Originally posted by @psfinaki in #15181 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Diagnosticsmistakes and possible improvements to diagnosticsArea-NullnessIssues related to handling of Nullable Reference Types

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions