Implement the built-in ReturnType<T>
generic without using it.
For example
const fn = (v
Implement the built-in Omit<T, K>
generic without using it.
Constructs a type by picking all pr
Implement a generic MyReadonly2<T, K>
which takes two type argument T
and K
.
K
specify th
Implement a generic DeepReadonly<T>
which make every parameter of an object - and its sub-object
Implement a generic TupleToUnion<T>
which covers the values of a tuple to its values union.
For
Chainable options are commonly used in Javascript. But when we switch to TypeScript, can you prope
TypeScript 4.0 is recommended in this challenge
Implement a generic Last<T>
that takes an Arr
TypeScript 4.0 is recommended in this challenge
Implement a generic Pop<T>
that takes an Arra
Type the function PromiseAll
that accepts an array of PromiseLike objects, the returning value s
Sometimes, you may want to look up a type in a union by its attributes.
In this challenge, we wou
Implement TrimLeft<T>
which takes an exact string type and returns a new string with the whitesp
Implement Trim<T>
which takes an exact string type and returns a new string with the whitespace
Implement Capitalize<T>
which converts the first letter of a string to uppercase and leave the r
Implement Replace<S, From, To>
which replace the string From
with To
once in the given strin
Implement ReplaceAll<S, From, To>
which replace the all the substring From
with To
in the gi
For given function type Fn
, and any type A
(any in this context means we don't restrict the ty
Implement permutation type that transforms union types into the array that includes permutations o
Compute the length of a string literal, which behaves like String#length
.
Implement a type that adds a new field to the interface. The type takes the three arguments. The o
Implement the Absolute
type. A type that take string, number or bigint. The output should be a p
Implement the String to Union type. Type take string argument. The output should be a union of inp
Merge two types into a new type. Keys of the second type overrides keys of the first type.
For ex
Replace the camelCase
or PascalCase
string with kebab-case
.
FooBarBaz
-> foo-bar-baz
F
Get an Object
that is the difference between O
& O1
Implement Python liked any
function in the type system. A type takes the Array and returns `true
Implement a type IsNever, which takes input type T
.
If the type of resolves to never
, return `
Implement a type IsUnion
, which takes an input type T
and returns whether T
resolves to a un
Implement a type ReplaceKeys, that replace keys in union types, if some type has not this key, jus
Implement RemoveIndexSignature<T>
, exclude the index signature from object types.
For example:
Implement PercentageParser/^(\+|\-)?(\d*)?(\%)?$/
regularit
Drop a specified char from a string.
For example:
type Butterfly = DropChar<' b u t t e r
Given a number (always positive) as a type. Your type should return the number decreased by one.
From T
, pick a set of properties whose type are assignable to U
.
For Example
t
Implement StartsWith<T, U>
which takes two exact string types and returns whether T
starts wit
Implement EndsWith<T, U>
which takes two exact string types and returns whether T
ends with `U
Implement a generic PartialByKeys<T, K>
which takes two type argument T
and K
.
K
specify
Implement a generic RequiredByKeys<T, K>
which takes two type argument T
and K
.
K
specif
Implement the generic Mutable<T>
which makes all properties in T
mutable (not readonly
From T
, pick a set of properties whose type are not assignable to U
.
For Example
Implement the type version of Object.entries
For example
interface Model {
Implement the type version of Array.shift
For example
type Result = Shift<[3
Given a tuple type T
that only contains string type, and a type U
, build an object rec
Implement the type version of Array.reverse
For example:
type a = Reverse<['
Implement the type version of lodash's _.flip
.
Type FlipArguments<T>
requires functio
Recursively flatten array up to depth times.
For example:
type a = FlattenDepth<[1
The Block, Element, Modifier methodology (BEM) is a popular naming convention for classes in CSS.
Implement the type of just-flip-object
. Examples:
Flip<{ a: "x", b: "y", c: "z" }
Implement a generic Fibonacci<T>
that takes a number T
and returns its corresponding [Fibonacc
Implement type AllCombinations<S>
that return all combinations of strings which use characte
In This Challenge, You should implement a type GreaterThan<T, U>
like T > U
Negative numbers
In This Challenge, You should implement a type Zip<T, U>
, T and U must be Tuple
type exp
Implement a type IsTuple
, which takes an input type T
and returns whether T
is t
Do you know lodash
? Chunk
is a very useful function in it, now let's implement it.
`Chunk<T, N
Fill
, a common JavaScript function, now let us implement it with types.
`Fill<T, N, Start?, End?
Implement TrimRight<T>
which takes an exact string type and returns a new string with the whites
Implement the type version of Lodash.without, Without<T, U> takes an Array T, number or array U an
Implement the type version of Math.trunc
, which takes string or number and returns the integ
Implement the type version of Array.indexOf, indexOf<T, U> takes an Array T, any U and returns the
Implement the type version of Array.join, Join<T, U> takes an Array T, string or number U and retu
Implement the type version of Array.lastIndexOf
, LastIndexOf<T, U>
takes an Array ```
Implement the type version of Lodash.uniq, Unique
Implement MapTypes<T, R>
which will transform types in object T to different types defined by ty
Construct a tuple with a given length.
For example
type result = ConstructTuple<2> // expe
Sometimes we want to limit the range of numbers... For examples.
type result = NumberRange<2
Given an array of strings, do Permutation & Combination. It's also useful for the prop types like
Given an array of unique elements, return all possible subsequences.
A subsequence is a seque
Implement type CheckRepeatedChars<S>
which will return whether type S
contains duplica
Given a string s, find the first non-repeating character in it and return its index. If it does no
You're required to implement a type-level parser to parse URL params string into an Union.
Get the middle element of the array by implementing a GetMiddleElement
method, represented by an
Find the elements in the target array that appear only once. For example:input: `[1,2,2,3,3,4,5,6,
With type CountElementNumberToObject
, get the number of occurrences of every item from an arra
Please complete type Integer<T>
, type T
inherits from number
, if T
is an integer return it
Convert a property of type literal (label type) to a primitive type.
For example
t
Implement a generic DeepMutable
Returns true if all elements of the list are equal to the second parameter passed in, false if the
Implement the type Filter<T, Predicate>
takes an Array T
, primitive type or union primitive ty
Given a pattern string P and a text string T, implement the type FindAll<T, P>
that returns an A
Given a generic tuple type T extends unknown[]
, write a type which produces all permutations o
Implement the type ReplaceFirst<T, S, R> which will replace the first occurrence of S in a tuple T
The transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switc
Implement the generic type JSONSchema2TS which will return the TypeScript type corresponding to th
Given a number, your type should return its square.
Given a number N, find the Nth triangular number, i.e. 1 + 2 + 3 + ... + N
Given 2 sets (unions), return its Cartesian product in a set of tuples, e.g.
CartesianProd
Merge variadic number of types into a new type. If the keys overlap, its values should be merged i
Implement type CheckRepeatedChars<T>
which will return whether type T
contains duplicated memb
Remove the key starting with _
from given type T
.
Implement a type that extract prop value to the interface. The type takes the two arguments. The o
Implement a typeDeepOmit
, Like Utility types [Omit](https://www.typescriptlang.org/docs/handbook
return true is a number is odd
Simulate the solution for the Tower of Hanoi puzzle. Your type should take the number of rings as
Given a number N, construct the Pascal's triangle with N rows. [Wikipedia](https://en.wikipedia.o
Sometimes you may want to determine whether a string literal is a definite type. For example, when
Implement CompareArrayLength
to compare two array length(T & U).
If length of T array is gre