import {expectType} from 'tsd'; import type {ArraySlice} from '../index.d.ts'; expectType>([0, 1, 2, 3]); expectType>({} as [0, 1, 2] | [0, 1, 2, 3]); expectType>({} as [0, 1] | [3, 2]); expectType>([0, 1, 2, 3]); expectType>([1, 2, 3]); expectType>([1]); expectType>([1, 2]); expectType>([]); expectType>([2]); expectType>([0, 1, 2, 3]); expectType>([0, 1, 2, 3]); expectType>([0, 1, 2]); expectType>([0, 1, 2]); expectType>([]); expectType>([0]); expectType>([0]); expectType>([]); expectType>([]); expectType>([]); expectType>([...(null! as string[]), 1, 2]); expectType>([...(null! as string[]), 1, 2]); expectType>([null! as (string | 1 | 2), null! as (string | 1 | 2)]); expectType>([null! as (string | 1 | 2), null! as (string | 1 | 2), null! as (string | 1 | 2)]); expectType>([1, 2, 3, ...(null! as string[])]); expectType>([1, 2, 3, ...(null! as string[])]); expectType>([1, 2, 3]); expectType>([2, 3, null! as string, null! as string]); expectType>([1, 2, 3, ...(null! as string[]), 4, 5]); expectType>([1, 2, 3, ...(null! as string[]), 4, 5]); expectType>([2, 3, null! as (string | 4 | 5), null! as (string | 4 | 5)]); expectType>([1, 2, 3, ...(null! as string[]), 4, 5]); expectType>([2, 3, ...(null! as string[]), 4, 5]); expectType>([...(null! as string[]), 4, 5]); expectType>([...(null! as string[]), 4, 5]); // Unions // Array is union expectType>({} as [0, 1, 2] | ['a', 'b', 'c', 'd']); // Positive start, no end expectType>({} as [1, 2] | ['c', 'd']); // Negative start, no end expectType>({} as [0, 1] | ['a', 'b']); // Positive start, positive end expectType>({} as [1] | ['c']); // Negative start, negative end expectType>({} as [0, 1] | ['b']); // Negative start, positive end expectType>({} as [1] | ['b', 'c']); // Positive start, negative end // Start is union expectType>({} as [1, 2, 3] | [2, 3]); // Positive/Negative start, no end expectType>({} as [2] | [1, 2]); // Positive/Negative start, positive end expectType>({} as [2] | [0, 1, 2]); // Positive/Negative start, negative end // End is union expectType>({} as [0] | [0, 1]); // Positive start, positive/negative end expectType>({} as [] | [2]); // Negative start, positive/negative end // Array and start are unions expectType>({} as [1, 2] | [2] | ['b', 'c', 'd'] | ['d']); // Positive/Negative start, no end expectType>({} as [1] | ['b'] | []); // Positive/Negative start, positive end expectType>({} as [0, 1] | [1] | ['a', 'b', 'c'] | ['c']); // Positive/Negative start, negative end // Array and end are unions expectType>({} as [2] | [] | ['c']); // Positive start, positive/negative end expectType>({} as [0, 1, 2] | [0] | ['b', 'c'] | ['b']); // Negative start, positive/negative end // Start and end are unions expectType>( // Positive/Negative start, positive/negative end {} as [0, 1] | [0, 1, 2] | [] | [1] | [1, 2], ); // Array, start and end are unions expectType>( // Positive/Negative start, positive/negative end {} as [1] | [1, 2] | [0, 1] | [0, 1, 2] | ['a', 'b', 'c', 'd'] | ['a', 'b', 'c'] | ['b', 'c'] | ['b', 'c', 'd'], );