Skip to content

Rule proposal: Disallow unions with unknown or any #4776

@fregante

Description

@fregante

Description

From what I understand, T | unknown and T | any resolve to just unknown and any respectively, so I don't think they're particularly useful.

Screen Shot 9

Fail

type MaybeNumber = number | unknown;

function isNumber(value: number | any): value is number {
	return typeof value === 'number';
}

Pass

type MaybeNumber = unknown;

function isNumber(value: any): value is number {
	return typeof value === 'number';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already existspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions