type
hero BETA
Explore
Tracks
Advent of TS
New
Explore
Tracks
Advent of TS
New
Theme
Login
Support Us
Login

    Medium

    Get Return Type

    MEDIUM
    0
    18
    @typehero
    7 months ago

    Implement the built-in ReturnType<T> generic without using it.

    For example

    const fn = (v

    Omit

    MEDIUM
    0
    15
    @typehero
    7 months ago

    Implement the built-in Omit<T, K> generic without using it.

    Constructs a type by picking all pr

    Readonly 2

    MEDIUM
    0
    21
    @typehero
    7 months ago

    Implement a generic MyReadonly2<T, K> which takes two type argument T and K.

    K specify th

    Deep Readonly

    MEDIUM
    6
    19
    @typehero
    7 months ago

    Implement a generic DeepReadonly<T> which make every parameter of an object - and its sub-object

    Tuple to Union

    MEDIUM
    0
    10
    @typehero
    7 months ago

    Implement a generic TupleToUnion<T> which covers the values of a tuple to its values union.

    For

    Chainable Options

    MEDIUM
    3
    34
    @typehero
    7 months ago

    Chainable options are commonly used in Javascript. But when we switch to TypeScript, can you prope

    Last of Array

    MEDIUM
    0
    8
    @typehero
    7 months ago

    TypeScript 4.0 is recommended in this challenge

    Implement a generic Last<T> that takes an Arr

    Pop

    MEDIUM
    1
    6
    @typehero
    7 months ago

    TypeScript 4.0 is recommended in this challenge

    Implement a generic Pop<T> that takes an Arra

    Promise.all

    MEDIUM
    0
    10
    @typehero
    7 months ago

    Type the function PromiseAll that accepts an array of PromiseLike objects, the returning value s

    Type Lookup

    MEDIUM
    0
    5
    @typehero
    7 months ago

    Sometimes, you may want to look up a type in a union by its attributes.

    In this challenge, we wou

    Trim Left

    MEDIUM
    0
    5
    @typehero
    7 months ago

    Implement TrimLeft<T> which takes an exact string type and returns a new string with the whitesp

    Trim

    MEDIUM
    0
    5
    @typehero
    7 months ago

    Implement Trim<T> which takes an exact string type and returns a new string with the whitespace

    Capitalize

    MEDIUM
    0
    6
    @typehero
    7 months ago

    Implement Capitalize<T> which converts the first letter of a string to uppercase and leave the r

    Replace

    MEDIUM
    0
    9
    @typehero
    7 months ago

    Implement Replace<S, From, To> which replace the string From with To once in the given strin

    ReplaceAll

    MEDIUM
    0
    8
    @typehero
    7 months ago

    Implement ReplaceAll<S, From, To> which replace the all the substring From with To in the gi

    Append Argument

    MEDIUM
    0
    4
    @typehero
    7 months ago

    For given function type Fn, and any type A (any in this context means we don't restrict the ty

    Permutation

    MEDIUM
    1
    10
    @typehero
    7 months ago

    Implement permutation type that transforms union types into the array that includes permutations o

    Length of String

    MEDIUM
    0
    3
    @typehero
    7 months ago

    Compute the length of a string literal, which behaves like String#length.

    Append to object

    MEDIUM
    0
    5
    @typehero
    7 months ago

    Implement a type that adds a new field to the interface. The type takes the three arguments. The o

    Absolute

    MEDIUM
    0
    13
    @typehero
    7 months ago

    Implement the Absolute type. A type that take string, number or bigint. The output should be a p

    String to Union

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement the String to Union type. Type take string argument. The output should be a union of inp

    Merge

    MEDIUM
    4
    2
    @typehero
    7 months ago

    Merge two types into a new type. Keys of the second type overrides keys of the first type.

    For ex

    KebabCase

    MEDIUM
    0
    4
    @typehero
    7 months ago

    Replace the camelCase or PascalCase string with kebab-case.

    FooBarBaz -> foo-bar-baz

    F

    Diff

    MEDIUM
    0
    2
    @typehero
    7 months ago

    Get an Object that is the difference between O & O1

    AnyOf

    MEDIUM
    1
    2
    @typehero
    7 months ago

    Implement Python liked any function in the type system. A type takes the Array and returns `true

    IsNever

    MEDIUM
    2
    5
    @typehero
    7 months ago

    Implement a type IsNever, which takes input type T. If the type of resolves to never, return `

    IsUnion

    MEDIUM
    0
    5
    @typehero
    7 months ago

    Implement a type IsUnion, which takes an input type T and returns whether T resolves to a un

    ReplaceKeys

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement a type ReplaceKeys, that replace keys in union types, if some type has not this key, jus

    Remove Index Signature

    MEDIUM
    0
    8
    @typehero
    7 months ago

    Implement RemoveIndexSignature<T> , exclude the index signature from object types.

    For example:

    Percentage Parser

    MEDIUM
    0
    2
    @typehero
    7 months ago

    Implement PercentageParser. According to the /^(\+|\-)?(\d*)?(\%)?$/ regularit

    Drop Char

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Drop a specified char from a string.

    For example:

    type Butterfly = DropChar<' b u t t e r

    MinusOne

    MEDIUM
    3
    5
    @typehero
    7 months ago

    Given a number (always positive) as a type. Your type should return the number decreased by one.

    PickByType

    MEDIUM
    0
    3
    @typehero
    7 months ago

    From T, pick a set of properties whose type are assignable to U.

    For Example

    t

    StartsWith

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement StartsWith<T, U> which takes two exact string types and returns whether T starts wit

    EndsWith

    MEDIUM
    0
    3
    @typehero
    7 months ago

    Implement EndsWith<T, U> which takes two exact string types and returns whether T ends with `U

    PartialByKeys

    MEDIUM
    0
    3
    @typehero
    7 months ago

    Implement a generic PartialByKeys<T, K> which takes two type argument T and K.

    K specify

    RequiredByKeys

    MEDIUM
    0
    2
    @typehero
    7 months ago

    Implement a generic RequiredByKeys<T, K> which takes two type argument T and K.

    K specif

    Mutable

    MEDIUM
    0
    2
    @typehero
    7 months ago

    Implement the generic Mutable<T> which makes all properties in T mutable (not readonly

    OmitByType

    MEDIUM
    0
    2
    @typehero
    7 months ago

    From T, pick a set of properties whose type are not assignable to U.

    For Example

    ObjectEntries

    MEDIUM
    2
    4
    @typehero
    7 months ago

    Implement the type version of Object.entries

    For example

    interface Model {

    Shift

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Implement the type version of Array.shift

    For example

    type Result = Shift<[3

    Tuple to Nested Object

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Given a tuple type T that only contains string type, and a type U, build an object rec

    Reverse

    MEDIUM
    0
    4
    @typehero
    7 months ago

    Implement the type version of Array.reverse

    For example:

    type a = Reverse<['

    Flip Arguments

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement the type version of lodash's _.flip.

    Type FlipArguments<T> requires functio

    FlattenDepth

    MEDIUM
    0
    6
    @typehero
    7 months ago

    Recursively flatten array up to depth times.

    For example:

    type a = FlattenDepth<[1

    BEM style string

    MEDIUM
    0
    4
    @typehero
    7 months ago

    The Block, Element, Modifier methodology (BEM) is a popular naming convention for classes in CSS.

    Flip

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement the type of just-flip-object. Examples:

    Flip<{ a: "x", b: "y", c: "z" }

    Fibonacci Sequence

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement a generic Fibonacci<T> that takes a number T and returns its corresponding [Fibonacc

    AllCombinations

    MEDIUM
    0
    3
    @typehero
    7 months ago

    Implement type AllCombinations<S> that return all combinations of strings which use characte

    Greater Than

    MEDIUM
    0
    1
    @typehero
    7 months ago

    In This Challenge, You should implement a type GreaterThan<T, U> like T > U

    Negative numbers

    Zip

    MEDIUM
    0
    2
    @typehero
    7 months ago

    In This Challenge, You should implement a type Zip<T, U>, T and U must be Tuple

    type exp

    IsTuple

    MEDIUM
    0
    3
    @typehero
    7 months ago

    Implement a type IsTuple, which takes an input type T and returns whether T is t

    Chunk

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Do you know lodash? Chunk is a very useful function in it, now let's implement it. `Chunk<T, N

    Fill

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Fill, a common JavaScript function, now let us implement it with types. `Fill<T, N, Start?, End?

    Trim Right

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Implement TrimRight<T> which takes an exact string type and returns a new string with the whites

    Without

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement the type version of Lodash.without, Without<T, U> takes an Array T, number or array U an

    Trunc

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Implement the type version of Math.trunc, which takes string or number and returns the integ

    IndexOf

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Implement the type version of Array.indexOf, indexOf<T, U> takes an Array T, any U and returns the

    Join

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement the type version of Array.join, Join<T, U> takes an Array T, string or number U and retu

    LastIndexOf

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement the type version of Array.lastIndexOf, LastIndexOf<T, U> takes an Array ```

    Unique

    MEDIUM
    0
    2
    @typehero
    7 months ago

    Implement the type version of Lodash.uniq, Unique takes an Array T, returns the Array T without

    MapTypes

    MEDIUM
    0
    3
    @typehero
    7 months ago

    Implement MapTypes<T, R> which will transform types in object T to different types defined by ty

    Construct Tuple

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Construct a tuple with a given length.

    For example

    type result = ConstructTuple<2> // expe

    Number Range

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Sometimes we want to limit the range of numbers... For examples.

    type result = NumberRange<2

    Combination

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Given an array of strings, do Permutation & Combination. It's also useful for the prop types like

    Subsequence

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Given an array of unique elements, return all possible subsequences.

    A subsequence is a seque

    CheckRepeatedChars

    MEDIUM
    1
    0
    @typehero
    7 months ago

    Implement type CheckRepeatedChars<S> which will return whether type S contains duplica

    FirstUniqueCharIndex

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Given a string s, find the first non-repeating character in it and return its index. If it does no

    Parse URL Params

    MEDIUM
    0
    0
    @typehero
    7 months ago

    You're required to implement a type-level parser to parse URL params string into an Union.

    undefined

    GetMiddleElement

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Get the middle element of the array by implementing a GetMiddleElement method, represented by an

    Appear only once

    MEDIUM
    0
    4
    @typehero
    7 months ago

    Find the elements in the target array that appear only once. For example:input: `[1,2,2,3,3,4,5,6,

    Count Element Number To Object

    MEDIUM
    0
    3
    @typehero
    7 months ago

    With type CountElementNumberToObject, get the number of occurrences of every item from an arra

    Integer

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Please complete type Integer<T>, type T inherits from number, if T is an integer return it

    ToPrimitive

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Convert a property of type literal (label type) to a primitive type.

    For example

    t

    DeepMutable

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement a generic DeepMutable which make every parameter of an object - and its sub-objects r

    All

    MEDIUM
    0
    5
    @typehero
    7 months ago

    Returns true if all elements of the list are equal to the second parameter passed in, false if the

    Filter

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Implement the type Filter<T, Predicate> takes an Array T, primitive type or union primitive ty

    FindAll

    MEDIUM
    0
    3
    @typehero
    7 months ago

    Given a pattern string P and a text string T, implement the type FindAll<T, P> that returns an A

    Combination key type

    MEDIUM
    0
    0
    @typehero
    7 months ago
    1. Combine multiple modifier keys, but the same modifier key combination cannot appear.
    2. In the

    Permutations of Tuple

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Given a generic tuple type T extends unknown[], write a type which produces all permutations o

    Replace First

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Implement the type ReplaceFirst<T, S, R> which will replace the first occurrence of S in a tuple T

    Transpose

    MEDIUM
    0
    0
    @typehero
    7 months ago

    The transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switc

    JSON Schema to TypeScript

    MEDIUM
    0
    2
    @typehero
    7 months ago

    Implement the generic type JSONSchema2TS which will return the TypeScript type corresponding to th

    Square

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Given a number, your type should return its square.

    Triangular number

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Given a number N, find the Nth triangular number, i.e. 1 + 2 + 3 + ... + N

    CartesianProduct

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Given 2 sets (unions), return its Cartesian product in a set of tuples, e.g.

    CartesianProd

    MergeAll

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Merge variadic number of types into a new type. If the keys overlap, its values should be merged i

    CheckRepeatedTuple

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Implement type CheckRepeatedChars<T> which will return whether type T contains duplicated memb

    Public Type

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Remove the key starting with _ from given type T.

    ExtractToObject

    MEDIUM
    0
    2
    @typehero
    7 months ago

    Implement a type that extract prop value to the interface. The type takes the two arguments. The o

    Deep Omit

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement a typeDeepOmit, Like Utility types [Omit](https://www.typescriptlang.org/docs/handbook

    IsOdd

    MEDIUM
    0
    4
    @typehero
    7 months ago

    return true is a number is odd

    Tower of hanoi

    MEDIUM
    0
    2
    @typehero
    7 months ago

    Simulate the solution for the Tower of Hanoi puzzle. Your type should take the number of rings as

    Pascal's triangle

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Given a number N, construct the Pascal's triangle with N rows. [Wikipedia](https://en.wikipedia.o

    IsFixedStringLiteralType

    MEDIUM
    0
    0
    @typehero
    7 months ago

    Sometimes you may want to determine whether a string literal is a definite type. For example, when

    Compare Array Length

    MEDIUM
    0
    1
    @typehero
    7 months ago

    Implement CompareArrayLength to compare two array length(T & U).

    If length of T array is gre

    Defined Partial Record

    MEDIUM
    0
    2
    @Type Challenges
    7 months ago

    Defined Partial Record

    Using a Record with union types as keys doesn't allow you to make

    Longest Common Prefix

    MEDIUM
    0
    1
    @Type Challenges
    7 months ago

    Longest Common Prefix

    Write a type, LongestCommonPrefix that returns the longest common p

    Trace

    MEDIUM
    0
    0
    @Type Challenges
    7 months ago

    The trace of a square matrix is the sum of the elements on its main diagonal. However, it's diffic

    IsAlphabet

    MEDIUM
    0
    2
    @Type Challenges
    7 months ago

    Determine if the given letter is an alphabet.