Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Include Type TypeScript

// type a = Equal<'a' | 'a'>
type Equal<T, K> = K extends T ? true : false;
type Includes<T extends any[], K> = T extends [infer first, ...infer Rest]
	? Equal<first, K> extends true
		? true
		: Includes<Rest, K>
	: false;
type isPillarMen = Includes<['Kars', 'Esidisi', 'Wamuu', 'Santana'], 'Kars'>; // expected to be `false`
 
PREVIOUS NEXT
Tagged: #Include #Type #TypeScript
ADD COMMENT
Topic
Name
3+7 =