TypeScript Challenges

Explore our collection of hands-on TypeScript coding challenges. Perfect for beginners and experienced developers alike. Each challenge is designed to help you master real-world concepts, from basic types to advanced generics, with practical problems and detailed solution walkthroughs. Solve, learn, and improve your TypeScript expertise by taking on a new challenge today!

#3256

Hello World

Start your TypeScript journey with the classic "Hello World" coding challenge. Learn by doing, get instant feedback, and master TypeScript basics step-by-step on TypeScriptPro.

Warm-up
#4

Pick

Learn to implement TypeScript's built-in Pick utility type from scratch. Master type manipulation and generic constraints with this easy-level TypeScript challenge on TypeScriptPro.

Easy
#7

Readonly

Learn to implement TypeScript's built-in Readonly utility type from scratch. Master readonly properties and mapped types with this easy-level TypeScript challenge on TypeScriptPro.

Easy
#11

Tuple to Object

Transform TypeScript tuples into object types with this easy-level challenge. Learn about const assertions, mapped types, and literal types on TypeScriptPro.

Easy
#14

First of Array

Extract the first element type from TypeScript arrays and tuples. Master indexed access types and conditional types in this easy-level challenge on TypeScriptPro.

Easy
#18

Length of Tuple

Get the length of TypeScript tuples at the type level. Learn about tuple types and the length property in this easy-level challenge on TypeScriptPro.

Easy
#43

Exclude

Implement TypeScript's built-in Exclude utility type from scratch. Master conditional types and type distribution in this easy-level challenge on TypeScriptPro.

Easy
#189

Awaited

Unwrap Promise types recursively with TypeScript. Learn conditional types, infer keyword, and recursive types in this easy-level challenge on TypeScriptPro.

Easy
#268

If

Implement conditional logic at the type level with TypeScript. Master conditional types and type constraints in this easy-level challenge on TypeScriptPro.

Easy
#533

Concat

Implement array concatenation at the type level with TypeScript. Learn about tuple types and the spread operator in this easy-level challenge on TypeScriptPro.

Easy
#898

Includes

Check if an array includes a value at the type level. Learn about recursive types and type equality in this easy-level TypeScript challenge on TypeScriptPro.

Easy
#3057

Push

Add elements to the end of tuples with TypeScript's type system. Master the spread operator and tuple manipulation in this easy-level challenge on TypeScriptPro.

Easy
#3060

Unshift

Add elements to the beginning of tuples with TypeScript. Learn tuple manipulation and spread operators in this easy-level challenge on TypeScriptPro.

Easy
#3312

Parameters

Extract function parameter types with TypeScript. Master the infer keyword and function type manipulation in this easy-level challenge on TypeScriptPro.

Easy
#2

Get Return Type

Implement the built-in `ReturnType<T>` generic without using it. Learn conditional types with `infer` in this medium-level challenge on TypeScriptPro.

Medium
#3

Omit

Implement the built-in `Omit<T, K>` generic without using it. Learn union type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#8

Readonly 2

Implement a generic `MyReadonly2<T, K>` which takes two type argument `T` and `K`. Learn how to use `readonly` modifiers in this medium-level challenge on TypeScriptPro.

Medium
#9

Deep Readonly

Implement a generic `DeepReadonly<T>` which makes every parameter of an object - and its sub-objects recursively - readonly. Learn readonly modifiers in this medium-level challenge on TypeScriptPro.

Medium
#10

Tuple to Union

Implement a generic `TupleToUnion<T>` which covers the values of a tuple to its values union. Learn conditional types with `infer`, union type manipulation, tuple manipulation in this medium-level challenge on TypeScriptPro.

Medium
#12

Chainable Options

Chainable options are commonly used in Javascript. But when we switch to TypeScript, can you properly type it? Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#15

Last of Array

Extract the last element type from TypeScript arrays and tuples. Master conditional types with `infer` in this medium-level challenge on TypeScriptPro.

Medium
#16

Pop

Remove the last element from an array. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#20

Promise.all

Implement a type-safe version of Promise.all that preserves tuple types and recursively unwraps nested promises. Master advanced TypeScript techniques including recursive types, mapped types, and conditional types in this medium-level challenge on TypeScriptPro.

Medium
#62

Type Lookup

Implement the `LookUp<U, T>` type, that looks up a type in a union by its attributes. Learn union type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#106

Trim Left

Implement `TrimLeft<T>` which takes an exact string type and returns a new string with the whitespace beginning removed. Master advanced TypeScript template literal types in this medium-level challenge on TypeScriptPro.

Medium
#108

Trim

Implement `Trim<T>` which takes an exact string type and returns a new string with the whitespace from both ends removed. Master TypeScript template literal types in this medium-level challenge on TypeScriptPro.

Medium
#110

Capitalize

Implement `Capitalize<T>` which converts the first letter of a string to uppercase and leave the rest as-is. Master TypeScript template literal types in this medium-level challenge on TypeScriptPro.

Medium
#116

Replace

Implement `Replace<S, From, To>` which replaces the string `From` with `To` in the given string `S`. Master TypeScript template literal types in this medium-level challenge on TypeScriptPro.

Medium
#119

ReplaceAll

Implement `ReplaceAll<S, From, To>` which replaces the substring `From` with `To` in the given string `S`. Master TypeScript template literal types in this medium-level challenge on TypeScriptPro.

Medium
#191

Append Argument

Implement the `AppendArgument<Fn, A>` type, that appends a new argument to parameters of a function type. Learn TypeScript function types in this medium-level challenge on TypeScriptPro.

Medium
#296

Permutation

Implement permutation type that transforms union types into the array that includes permutations of unions. Learn union type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#298

Length of String

Compute the length of a string literal, which behaves like `String.length`. Master TypeScript template literal types in this medium-level challenge on TypeScriptPro.

Medium
#459

Flatten

In this challenge, you would need to write a type that takes an array and emitted the flatten array type. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#527

Append to object

Implement a Generic Type that can append a new field to any object type. Master mapped types in TypeScript in this medium-level challenge on TypeScriptPro.

Medium
#529

Absolute

Implement the `Absolute` type. A type that takes string, number or bigint and returns a positive number string. Master TypeScript template literal types in this medium-level challenge on TypeScriptPro.

Medium
#531

String to Union

Implement the String to Union type, that turns a string into a union of its characters. Learn TypeScript template literal types in this medium-level challenge on TypeScriptPro.

Medium
#599

Merge

Implement the `Merge<F, S>` type, that merges two types into a new type. Master mapped types in TypeScript in this medium-level challenge on TypeScriptPro.

Medium
#612

KebabCase

Replace the `camelCase` or `PascalCase` string with `kebab-case`. Learn TypeScript template literal types in this medium-level challenge on TypeScriptPro.

Medium
#645

Diff

Implement the `Diff<O, O1>` type, that returns an object with the difference between two objects. Master union and intersection types in TypeScript in this medium-level challenge on TypeScriptPro.

Medium
#949

AnyOf

Implement Python liked `any` function in the type system. A type takes the Array and returns `true` if any element of the Array is true. If the Array is empty, return `false`. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#1042

IsNever

Implement a `IsNever` Generic, which allows you to check if a type is never. Learn type distribution in TypeScript in this medium-level challenge on TypeScriptPro.

Medium
#1097

IsUnion

Implement a type `IsUnion`, which takes an input type `T` and returns whether `T` resolves to a union type. Learn union type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#1130

ReplaceKeys

Implement a type ReplaceKeys, that replace keys in union types, if some type has not this key, just skip replacing, Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#1367

Remove Index Signature

Implement `RemoveIndexSignature<T>` , exclude the index signature from object types. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#1978

Percentage Parser

Implement PercentageParser<T extends string>. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#2070

Drop Char

Implement the `DropChar<S, C>` type, that drops a specified char from a string. Learn template literal types in TypeScript in this medium-level challenge on TypeScriptPro.

Medium
#2257

MinusOne

Given a number (always positive) as a type. Your type should return the number decreased by one. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#2595

PickByType

From `T`, pick a set of properties whose type are assignable to `U`. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#2688

StartsWith

Implement `StartsWith<T, U>` which takes two exact string types and returns whether `T` starts with `U` Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#2693

EndsWith

Implement `EndsWith<T, U>` which takes two exact string types and returns whether `T` ends with `U` Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#2757

PartialByKeys

Implement a generic `PartialByKeys<T, K>` which takes two type argument `T` and `K`. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#2759

RequiredByKeys

Implement a generic `RequiredByKeys<T, K>` which takes two type argument `T` and `K`. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#2793

Mutable

Implement the generic ```Mutable<T>``` which makes all properties in ```T``` mutable (not readonly). Learn readonly modifiers in this medium-level challenge on TypeScriptPro.

Medium
#2852

OmitByType

From ```T```, pick a set of properties whose type are not assignable to ```U```. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#2946

ObjectEntries

Implement the type version of ```Object.entries``` Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#3062

Shift

Implement the type version of ```Array.shift``` Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#3188

Tuple to Nested Object

Given a tuple type ```T``` that only contains string type, and a type ```U```, build an object recursively. Learn tuple manipulation in this medium-level challenge on TypeScriptPro.

Medium
#3192

Reverse

Implement the type version of `Array.reverse()`. Learn tuple manipulation in TypeScript in this medium-level challenge on TypeScriptPro.

Medium
#3196

Flip Arguments

Implement the type version of lodash's ```_.flip```. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#3243

FlattenDepth

Recursively flatten array up to depth times. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#3326

BEM style string

The Block, Element, Modifier methodology (BEM) is a popular naming convention for classes in CSS. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#4179

Flip

Implement the type of `just-flip-object`. Examples: Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#4182

Fibonacci Sequence

Implement a generic `Fibonacci<T>` that takes a number `T` and returns its corresponding [Fibonacci number](https://en.wikipedia.org/wiki/Fibonacci_number). Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#4260

AllCombinations

Implement type ```AllCombinations<S>``` that return all combinations of strings which use characters from ```S``` at most once. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#4425

Greater Than

In This Challenge, You should implement a type `GreaterThan<T, U>` like `T > U` Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#4471

Zip

In This Challenge, You should implement a type `Zip<T, U>`, T and U must be `Tuple` Learn tuple manipulation in this medium-level challenge on TypeScriptPro.

Medium
#4484

IsTuple

Implement a type ```IsTuple```, which takes an input type ```T``` and returns whether ```T``` is tuple type. Learn tuple manipulation in this medium-level challenge on TypeScriptPro.

Medium
#4499

Chunk

Do you know `lodash`? `Chunk` is a very useful function in it, now let's implement it. Learn tuple manipulation in this medium-level challenge on TypeScriptPro.

Medium
#4518

Fill

`Fill`, a common JavaScript function, now let us implement it with types. Learn tuple manipulation in this medium-level challenge on TypeScriptPro.

Medium
#4803

Trim Right

Implement `TrimRight<T>` which takes an exact string type and returns a new string with the whitespace ending removed. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#5117

Without

Implement the type version of Lodash.without, Without<T, U> takes an Array T, number or array U and returns an Array without the elements of U. Learn union type manipulation, array type operations in this medium-level challenge on TypeScriptPro.

Medium
#5140

Trunc

Implement the type version of ```Math.trunc```, which takes string or number and returns the integer part of a number by removing any fractional digits. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#5153

IndexOf

Implement the type version of Array.indexOf, indexOf<T, U> takes an Array T, any U and returns the index of the first U in Array T. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#5310

Join

Implement the type version of Array.join, Join<T, U> takes an Array T, string or number U and returns the Array T with U stitching up. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#5317

LastIndexOf

Implement the type version of ```Array.lastIndexOf```, ```LastIndexOf<T, U>``` takes an Array ```T```, any ```U``` and returns the index of the last ```U``` in Array ```T``` Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#5360

Unique

Implement the type version of Lodash.uniq, Unique<T> takes an Array T, returns the Array T without repeated values. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#5821

MapTypes

Implement `MapTypes<T, R>` which will transform types in object T to different types defined by type R which has the following structure Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#7544

Construct Tuple

Construct a tuple with a given length. Learn tuple manipulation in this medium-level challenge on TypeScriptPro.

Medium
#8640

Number Range

Sometimes we want to limit the range of numbers... Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#8767

Combination

Given an array of strings, do Permutation & Combination. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#8987

Subsequence

Given an array of unique elements, return all possible subsequences. Learn union type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#9142

CheckRepeatedChars

Implement type ```CheckRepeatedChars<S>``` which will return whether type ```S``` contains duplicated chars? Learn union type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#9286

FirstUniqueCharIndex

Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. (Inspired by [leetcode 387](https://leetcode.com/problems/first-unique-character-in-a-string/)) Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#9616

Parse URL Params

You're required to implement a type-level parser to parse URL params string into an Union. Learn conditional types with `infer` in this medium-level challenge on TypeScriptPro.

Medium
#9896

GetMiddleElement

Get the middle element of the array by implementing a `GetMiddleElement` method, represented by an array Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#9898

Appear only once

Find the elements in the target array that appear only once. For example:input: `[1,2,2,3,3,4,5,6,6,6]`,output: `[1,4,5]`. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#9989

Count Element Number To Object

With type ``CountElementNumberToObject``, get the number of occurrences of every item from an array and return them in an object. For example: Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#10969

Integer

Please complete type `Integer<T>`, type `T` inherits from `number`, if `T` is an integer return it, otherwise return `never`. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#16259

ToPrimitive

Convert a property of type literal (label type) to a primitive type. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#17973

DeepMutable

Implement a generic DeepMutable<T> which make every parameter of an object - and its sub-objects recursively - mutable. Learn recursive type definitions, readonly modifiers in this medium-level challenge on TypeScriptPro.

Medium
#18142

All

Returns true if all elements of the list are equal to the second parameter passed in, false if there are any mismatches. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#18220

Filter

Implement the type `Filter<T, Predicate>` takes an Array `T`, primitive type or union primitive type `Predicate` and returns an Array include the elements of `Predicate`. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#21104

FindAll

Given a pattern string P and a text string T, implement the type `FindAll<T, P>` that returns an Array that contains all indices (0-indexed) from T where P matches. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#21106

Combination key type

1. Combine multiple modifier keys, but the same modifier key combination cannot appear. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#21220

Permutations of Tuple

Given a generic tuple type `T extends unknown[]`, write a type which produces all permutations of `T` as a union. Learn union type manipulation, tuple manipulation in this medium-level challenge on TypeScriptPro.

Medium
#25170

Replace First

Implement the type ReplaceFirst<T, S, R> which will replace the first occurrence of S in a tuple T with R. If no such S exists in T, the result should be T. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#25270

Transpose

The transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix A by producing another matrix, often denoted by A<sup>T</sup>. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#26401

JSON Schema to TypeScript

Implement the generic type JSONSchema2TS which will return the TypeScript type corresponding to the given JSON schema. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#27133

Square

Given a number, your type should return its square. Learn tuple manipulation, array type operations in this medium-level challenge on TypeScriptPro.

Medium
#27152

Triangular number

Given a number N, find the Nth triangular number, i.e. `1 + 2 + 3 + ... + N` Learn tuple manipulation, array type operations in this medium-level challenge on TypeScriptPro.

Medium
#27862

CartesianProduct

Given 2 sets (unions), return its Cartesian product in a set of tuples, e.g. Learn union type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#27932

MergeAll

Merge variadic number of types into a new type. If the keys overlap, its values should be merged into an union. Learn union type manipulation, array type operations in this medium-level challenge on TypeScriptPro.

Medium
#27958

CheckRepeatedTuple

Implement type `CheckRepeatedChars<T>` which will return whether type `T` contains duplicated member Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#28333

Public Type

Remove the key starting with `_` from given type `T`. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#29650

ExtractToObject

Implement a type that extract prop value to the interface. The type takes the two arguments. The output should be an object with the prop values. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#29785

Deep Omit

Implement a type`DeepOmit`, Like Utility types [Omit](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys), A type takes two arguments. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#30301

IsOdd

return true is a number is odd Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#30430

Tower of hanoi

Simulate the solution for the Tower of Hanoi puzzle. Your type should take the number of rings as input an return an array of steps to move the rings from tower A to tower B using tower C as additional. Each entry in the array should be a pair of strings `[From, To]` which denotes ring being moved `From -> To`. Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#30970

IsFixedStringLiteralType

Sometimes you may want to determine whether a string literal is a definite type. For example, when you want to check whether the type specified as a class identifier is a fixed string literal type. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#34007

Compare Array Length

Implement `CompareArrayLength` to compare two array length(T & U). Learn array type operations in this medium-level challenge on TypeScriptPro.

Medium
#34857

Defined Partial Record

### Defined Partial Record Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#35045

Longest Common Prefix

### Longest Common Prefix Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#35191

Trace

The trace of a square matrix is the sum of the elements on its main diagonal. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#35252

IsAlphabet

Determine if the given letter is an alphabet. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
#35991

MyUppercase

Implement `Uppercase<T>`, convert all letter to uppercase Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

Medium
More Challenges Coming Soon! Get notified when we launch new challenges.

We only send TypeScript related emails. No spam. Unsubscribe anytime.