import {expectType} from 'tsd'; import type { IsLiteral, IsStringLiteral, IsNumericLiteral, IsBooleanLiteral, IsSymbolLiteral, Tagged, LiteralUnion, } from '../index.d.ts'; const stringLiteral = ''; const numberLiteral = 1; const bigintLiteral = 1n; const booleanLiteral = true; const symbolLiteral = Symbol(''); declare const _string: string; declare const _number: number; declare const _bigint: bigint; declare const _boolean: boolean; declare const _symbol: symbol; // Literals should be true expectType>(true); expectType>(true); expectType>(true); expectType>(true); expectType>(true); // Primitives should be false expectType>(false); expectType>(false); expectType>(false); expectType>(false); expectType>(false); // Null, undefined, and non-primitives should fail all literal checks expectType>(false); expectType>(false); expectType>(false); expectType>(false); expectType>(true); expectType>(false); // Strings with infinite set of possible values return `false` expectType>>(false); expectType>>(false); expectType>>(false); expectType>>(false); expectType>>>(false); expectType>>>(false); expectType>(false); expectType>(false); expectType>(false); expectType}`>>(false); expectType}abc`>>(false); expectType>(false); expectType>(false); expectType>>(false); expectType | Uppercase>>(false); expectType>(false); // Strings with finite set of possible values return `true` expectType>(true); expectType>>(true); expectType>>(true); expectType>>(true); expectType>>(true); expectType>>(true); expectType>>(true); expectType>(true); expectType | 'C' | 'D'>>(true); expectType | Capitalize<'abc'>>>(true); // Strings with union of literals and non-literals return `boolean` expectType | 'abc'>>({} as boolean); expectType | 'Abc'>>({} as boolean); expectType>({} as boolean); expectType>({} as boolean); expectType>({} as boolean); // Types other than string return `false` expectType>(false); expectType>(false); expectType>(false); expectType>(false); // Boundary types expectType>(false); expectType>(false); expectType>(false); expectType>(true); expectType>(true); expectType>(false); expectType>(false); expectType>(true); expectType>(false); expectType>(true); expectType>(false); // Missing generic parameter // @ts-expect-error type A0 = IsLiteral; // @ts-expect-error type A1 = IsStringLiteral; // @ts-expect-error type A2 = IsNumericLiteral; // @ts-expect-error type A3 = IsBooleanLiteral; // @ts-expect-error type A4 = IsSymbolLiteral; // Tagged types expectType>>(false); expectType, 'Tag'>>>(false); expectType>>(false); expectType>>(true); expectType>>({} as boolean); expectType>>({} as boolean); expectType | Tagged>>(false); expectType | Tagged<'bar', 'Tag'>>>(true); expectType | Tagged>>({} as boolean); expectType | number>>({} as boolean); // Uncollapsed unions (e.g., `'foo' | 'bar' | (string & {})`) expectType>(false); expectType>>(false); expectType>>(false); expectType>>({} as boolean); expectType>>({} as boolean); expectType, 'Tag'>>>(false); expectType, 'Tag'>>>({} as boolean); expectType>>(false); expectType>>(false);