Skip to content

[new rule] Disallow !?? (Non-null + nullish) #2853

@fregante

Description

@fregante

! in TypeScript (non-null assertion operator) cancels the null type and ?? (nullish coalescing operator) actually handles it. The first one is redundant.

This is a suggestion for a new rule:

Fail

return document.querySelector('a')! ?? defaultElement

Pass

return document.querySelector('a') ?? defaultElement

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions