JavaScript

JavaScript

Made by DeepSource

Intersection or union definition have duplicate types JS-T1000

Type check
Minor
Autofix

Having duplicate types in an intersection or union type definition impacts readability. It is often the result of a mistake while declaring the types.

Bad Practice

type CustomType = 1 | 2 | 1

let foo: number | string | number
let bar: string & number & string

function foobar(quz: string | number | number): boolean | boolean {
  // function body
}

Recommended

type CustomType = 1 | 2

let foo: number | string
let bar: string & number

function foobar(quz: string | number): boolean {
  // function body
}