Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

Exclude value from array typescript type

// Exclude Array
type Equal<T, K> = K extends T ? true : false;
type ExcludeArray<T extends any[], K, J extends any[] = []> = T extends [infer first, ...infer Rest]
	? Equal<first, K> extends false
		? ExcludeArray<Rest, K, [...J, first]>
		: ExcludeArray<Rest, K, [...J]>
	: J;
type excludeArray = ExcludeArray<['a', 'b', 'c', 'd'], 'c'>; //['a', 'b', 'd']
type excludeArray_2 = ExcludeArray<['a', 'b', 'c', 'd'], 'c'|'d'>; //['a', 'b']
Comment

PREVIOUS NEXT
Code Example
Typescript :: Lua programming - setting up physics 
Typescript :: pass generic type to arow function typescript 
Typescript :: mixins with parameters typescript 
Typescript :: how to get all dates from range in react js 
Typescript :: difference known_hosts authorized_keys 
Typescript :: element of an array is the same as any of the previous elements pandas 
Typescript :: sts shortcut to resolve error 
Typescript :: python fancy way to get arguments from the command line 
Typescript :: 2 counts of IllegalAnnotationExceptions 
Typescript :: testing with limited information 
Typescript :: fs readFile binary 
Typescript :: TYPESCRIPT PIPLINE FOR THE MULTIPLE TYPE 
Typescript :: Access - Open form non data entry mode 
Typescript :: components of .net framework 
Typescript :: how to set references in sequelize type config/options 
Typescript :: how should a developer write unit tests for a private method in an apex class 
Typescript :: circular indicator gets whole page flutter 
Typescript :: generic function typescript 
Typescript :: node scripts delay 
Typescript :: jquery tscroll up 
Typescript :: unity destroy all objects with tag 
Cpp :: cpp boilerplate 
Cpp :: c++ get filename from path 
Cpp :: separation between paragraphs latex 
Cpp :: lpcwstr to string c++ 
Cpp :: check if intent has extras 
Cpp :: eosio check account exist 
Cpp :: ue4 ftext c++ 
Cpp :: c++ get input without loop 
Cpp :: random in c++ 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =