TypeScript Challenges

170+ hands-on TypeScript exercises with worked solutions. Practice everything from basic type annotations to advanced type-level programming, and track your progress as you go.

Choose your difficulty

Not sure where to start? Skim the TypeScript concept guides first, or jump straight into the full list below — each challenge links the concepts and compiler errors you will run into while solving it.

#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#612

KebabCase

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

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#1978

Percentage Parser

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

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#2946

ObjectEntries

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

MediumPro
#3062

Shift

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

MediumPro
#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.

MediumPro
#3192

Reverse

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

MediumPro
#3196

Flip Arguments

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

MediumPro
#3243

FlattenDepth

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

MediumPro
#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.

MediumPro
#3376

InorderTraversal

Implement the type version of binary tree inorder traversal. Master recursive conditional types and tree structures in this medium-level challenge on TypeScriptPro.

MediumPro
#4179

Flip

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

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#4518

Fill

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

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#7544

Construct Tuple

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

MediumPro
#8640

Number Range

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

MediumPro
#8767

Combination

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

MediumPro
#8987

Subsequence

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

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#19749

IsEqual

Implement the type-level equal operator that returns a boolean for whether two given types are equal. Master conditional types and type comparison in this medium-level challenge on TypeScriptPro.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#27133

Square

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

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#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.

MediumPro
#28333

Public Type

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

MediumPro
#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.

MediumPro
#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.

MediumPro
#30301

IsOdd

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

MediumPro
#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.

MediumPro
#30958

Pascal's triangle

Given a number N, construct the Pascal's triangle with N rows. Learn array type operations in this medium-level challenge on TypeScriptPro.

MediumPro
#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.

MediumPro
#34007

Compare Array Length

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

MediumPro
#34857

Defined Partial Record

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

MediumPro
#35045

Longest Common Prefix

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

MediumPro
#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.

MediumPro
#35252

IsAlphabet

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

MediumPro
#35991

MyUppercase

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

MediumPro
#6

Simple Vue

A Vue-style defineComponent where this means the right thing in data, computed and methods: three inferred shapes fed back into the same object literal via ThisType.

Hard
#17

Currying 1

Type a currying function that turns a multi-argument function into a chain of single-argument calls. Recursive tuple inference peels one parameter per step.

Hard
#55

Union to Intersection

Turn A | B | C into A & B & C. There is no built-in operator for this; distributive conditionals and contravariant inference get you there.

Hard
#57

Get Required

Write GetRequired<T>, which drops every optional property from an object type. The filter runs inside the mapped type: as-remapping a key to never erases it.

Hard
#59

Get Optional

Build GetOptional<T>, which keeps only the optional fields of an object type. Filtering keys is half the job; each surviving property must also keep its ? modifier.

Hard
#89

Required Keys

Build RequiredKeys<T>, which collects every required key of an object type into a union. Checking for undefined fails; you have to test the ? modifier itself.

Hard
#90

Optional Keys

Build OptionalKeys<T>, which collects every optional key of an object type into a union. The hard part: optionality is a modifier, so checking for undefined gets you nowhere.

Hard
#112

Capitalize Words

Uppercase the first letter of every word in a string type, where a word boundary is any character without an upper or lower case form.

Hard
#114

CamelCase

Convert a snake_case string type to camelCase with recursive template literal inference. The tricky part: characters that cannot be uppercased, like _ and $.

HardPro
#147

C-printf Parser

Parse a C-style printf format string at the type level, collecting placeholders like %d into a tuple. Lazy template inference handles %% escapes for free.

HardPro
#213

Vue Basic Props

Extend Simple Vue with a props option: infer prop types from constructors like Boolean, String or custom classes, including unions from constructor arrays.

HardPro
#223

IsAny

Detect the any type, and only any. Every obvious check produces false positives; the working one-liner is 0 extends 1 & T, and the why behind it is the real lesson.

HardPro
#270

Typed Get

A fully typed version of lodash's get: parse a dot-separated path string with template literal inference and resolve it to the exact value type.

HardPro
#300

String to Number

Convert a string literal type to its number, like Number.parseInt but stricter. One infer extends clause replaces pages of digit-by-digit recursion.

HardPro
#399

Tuple Filter

FilterOut<T, F> removes tuple elements assignable to F. The catch is never, which makes naked conditional checks silently evaporate.

HardPro
#472

Tuple to Enum Object

Convert a string tuple into a readonly enum-like object: PascalCase keys, filtered array keys, and index strings turned back into number literals.

HardPro
#545

printf

Format<T> turns a printf-style format string into a curried function type, one typed argument per placeholder. The twist: the recursion builds function types, not tuples.

HardPro
#553

Deep object to unique

Brand an object and every nested object with its own identity while staying mutually assignable with the original. Nominal typing built by hand.

HardPro
#651

Length of String 2

Count the length of a string type with a tuple accumulator. The naive recursion dies at about 45 characters; tail recursion takes you to 999.

HardPro
#730

Union to Tuple

Convert a union into a tuple even though unions have no order. The key move is extracting a single member via function overload resolution.

HardPro
#847

String Join

A curried join function whose return type is the exact joined string literal, computed from the delimiter and arguments by a recursive template literal type.

HardPro
#956

DeepPick

A Pick that understands dot paths like friend.family.name, building one nested pick per path and folding them into an intersection via contravariant inference.

HardPro
#1290

Pinia

Type Pinia's defineStore: getters are written as functions but read as values, and state is mutable in actions but read-only in getters. ThisType does the work.

HardPro
#1383

Camelize

Rename every snake_case key in an object type to camelCase, recursing through nested objects and tuples. The array branch must come before the object branch.

HardPro
#2059

Drop String

Remove every character of R from the string type S. One recursion turns R into a union of characters, another walks S and filters against it.

HardPro
#2822

Split

A type-level String.split() that turns a string type into a tuple of substrings. Reproducing JavaScript's odd empty-string rules is the hard part.

HardPro
#2828

ClassPublicKeys

Extract the public keys of a class into a union. The answer is one line, because keyof never sees private or protected members in the first place.

HardPro
#2857

IsRequiredKey

IsRequiredKey<T, K> reports whether every key in K is required on T. Optionality is a modifier, not a value type, so the check compares Pick against Required.

HardPro
#2949

ObjectFromEntries

Turn a union of [key, value] tuples into an object type, the type-level Object.fromEntries. One mapped type does it, once you know in can iterate any union.

HardPro
#4037

IsPalindrome

Check whether a string or number reads the same backwards, entirely in types. A recursive template-literal split does the reversal.

HardPro
#5181

Mutable Keys

Build MutableKeys<T>, a union of the non-readonly keys of an object type. Assignability checks ignore readonly, so detecting it takes the Equal trick.

HardPro
#5423

Intersection

The type-level version of Lodash intersection: compute what several lists have in common. Normalize every entry to a union and let & do the set math.

HardPro
#6141

Binary to Decimal

Convert a binary string literal like '1010' into the number type 10. The type system has no arithmetic, so tuples stand in for numbers and spreads do the math.

HardPro
#7258

Object Key Paths

Generate every path string lodash _.get accepts on an object, dot and bracket notation included, by walking the type with recursive template literals.

HardPro
#8804

Two Sum

Solve Two Sum in the type system, where there is no + operator and no loop. Two nested recursions over a tuple, with addition built from tuple lengths.

HardPro
#9155

ValidDate

Implement ValidDate<T>, which checks whether an MMDD string is a real calendar date. Every legal month and day gets enumerated as a union of string literals.

HardPro
#9160

Assign

Recreate Object.assign at the type level: merge an array of sources into a target, later sources winning. Intersections collapse conflicts to never, so they're out.

HardPro
#9384

Maximum

Find the largest number in a tuple type with no greater-than operator in sight. A counting tuple eliminates union members until only the maximum remains.

HardPro
#9775

Capitalize Nest Object Keys

Capitalize every key of an object type recursively, following values into nested arrays. The branch order decides whether tuples survive the mapping.

HardPro
#13580

Replace Union

UnionReplace<T, U> rewrites a union according to a list of [from, to] type pairs: one conditional distributes over the members, another recurses through the pairs.

HardPro
#14080

FizzBuzz

Generate the FizzBuzz sequence as a tuple of string literals, without loops or a modulo operator. Tuple counters and a tail-recursive accumulator do the work.

HardPro
#14188

Run-length encoding

Encode and decode run-length compressed strings at the type level, combining template literal inference, string accumulators, tuple counters and a digit trick.

HardPro
#15260

Tree path array

Path<T> computes every valid key path through a nested object as a union of tuples. The machinery behind type-safe lodash.get and form field paths.

HardPro
#19458

SnakeCase

SnakeCase<T> converts camelCase string types to snake_case by scanning one character at a time. Union inputs work for free thanks to distributive conditionals.

HardPro
#25747

IsNegativeNumber

IsNegativeNumber<N> returns true for negative literals, false for zero and positives, and never for number or unions. Union detection is the tricky part.

HardPro
#28143

OptionalUndefined

Make every property that allows undefined optional, restricted to a chosen key set. Split the object with key remapping, add the ? modifier, merge back.

HardPro
#30178

Unique Items

Write uniqueItems, a function that rejects tuples with duplicate elements and pins the compiler error on each repeated element instead of the whole argument.

HardPro
#30575

BitwiseXOR

XOR two binary string literals of different lengths. Bitwise ops align at the right end, the one end template literal inference cannot reach, so you reverse first.

HardPro
#31797

Sudoku

A type that verifies a solved Sudoku board: 27 region checks built from indexed access on tuples and one union-as-set comparison.

HardPro
#31824

Length of String 3

Count string lengths up to a million characters at the type level. Fixed-width template patterns strip 100,000 characters per match; the counts become digits.

HardPro
#32427

Unbox

Build Unbox<T>, which unwraps functions, promises, arrays and tuples, recursively or to a chosen depth. Fixpoint recursion meets a type-level counter.

HardPro
#32532

Binary Addition

Add two binary numbers, given as bit tuples, by modeling a full adder: a sum and a carry bit per column, carry rippling left. Tuple-length counting tricks are banned.

HardPro
#33763

Union to Object from key

Filter a union of object types down to the members that have a given key. No recursion, no infer: the whole difficulty is understanding distribution.

HardPro
#34286

Take Elements

Take<N, Arr> extracts the first N elements of a tuple, or the last N when N is negative. Accumulator counting and template literal sign detection do the work.

HardPro
#35314

Valid Sudoku

Grade a finished 9x9 Sudoku grid entirely in the type system. Indexed access over unions carves out rows, columns and boxes without any tuple slicing.

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

Frequently asked questions

Are the challenges free?

A selection of warm-up and easy challenges is free, including the full problem statement and solution walkthrough. Pro unlocks the complete set with interactive editors and video walkthroughs.

Do I need to install anything?

No. Every challenge runs in an in-browser TypeScript editor with instant type checking, so you can practice from any machine.

What order should I solve them in?

Work through a difficulty level at a time. The challenges are ordered so that each one builds on ideas from earlier ones, and every solution links the concept guides it relies on.

How are these different from type-challenges on GitHub?

Many challenges are curated from the well-known type-challenges collection, but each one here adds a step-by-step solution explanation, links to related concept guides and TypeScript error references, and progress tracking.