import {expectType} from 'tsd'; import type {IsRequiredKeyOf} from '../source/is-required-key-of.d.ts'; declare const never: never; declare const boolean: boolean; declare const symbol: unique symbol; // Base object type A = { a: string; b?: number; c: boolean; }; expectType>(true); expectType>(false); expectType>(true); // @ts-expect-error `d` is not in `keyof T` expectType>(false); // Index signature with required keys type B = { [k: string]: string; }; expectType>(true); expectType>(false); // Required and readonly combo type C = { readonly a?: number; b: string; }; expectType>(false); expectType>(true); // Required + readonly type D = { readonly x: boolean; y?: string; }; expectType>(true); expectType>(false); // Union type E1 = {a?: number}; type E2 = {a: number}; type E = E1 | E2; expectType>(boolean); // Intersection type F1 = {a?: number}; type F2 = {a: number}; type F = F1 & F2; expectType>(true); // Class class G { x?: string; y = 5; } expectType>(false); expectType>(true); type H = { [symbol]?: number; a: string; }; expectType>(false); expectType>(true); // Method and required prop type I = { name: string; run?(): void; }; expectType>(false); expectType>(true); // Fully required object type J = Partial<{ a: number; b: string; }>; expectType>(false); expectType>(false); // Non-required but union with undefined type L = { a: string | undefined; b?: number; }; expectType>(true); expectType>(false); // Union of keys expectType>(boolean); expectType>(true); // @ts-expect-error expectType>(boolean); expectType>(true); type FullKeyUnion = keyof A; // 'a' | 'b' | 'c' expectType>(boolean); // @ts-expect-error expectType>(boolean); // 'x' is not in A, so filtered as false // `never` / `any type K = {a: string}; expectType>(never); expectType>(never); expectType>(never); expectType>(never); expectType>(never); expectType>(never);