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