Completed Challenges

Generic Function Arguments

BEGINNER
24
147
@dimitropoulos
1 year ago

Give generic function types to your functions

Hello World

BEGINNER
20
93
@typehero
5 months ago

Hello, World!

In Type Challenges, we use the type system itself to do the assertion.

For this ch

Generic Type Arguments

BEGINNER
10
70
@dimitropoulos
1 year ago

Generic types are like function arguments.

Generic Type Constraints

BEGINNER
4
59
@dimitropoulos
1 year ago

Generic type constraints allow us to restrict the possible types a generic type will accept.

Index Signatures

BEGINNER
8
62
@dimitropoulos
1 year ago

Index signatures allow us to handle types where the properties are a non-specific literal value.

Indexed Types

BEGINNER
12
44
@dimitropoulos
1 year ago

Some types can be indexed to lookup a particular value.

The `keyof` operator

BEGINNER
5
37
@dimitropoulos
1 year ago

keyof allows us to extract a union of another type's keys.

Literal Types

BEGINNER
23
47
@dimitropoulos
1 year ago

TypeScript can be more specific than string or number. It can remember literal values.

Mapped Object Types

BEGINNER
9
52
@dimitropoulos
1 year ago

Mapping objects is a foundational skill that allows you to write type translation logic.

Primitive Data Types

BEGINNER
19
86
@dimitropoulos
1 year ago

Your TypeScript journey starts with these building blocks.

Type Aliases

BEGINNER
6
60
@dimitropoulos
1 year ago

You can create multiple names for the same type.

The `typeof` Operator

BEGINNER
8
63
@dimitropoulos
1 year ago

When you need to create a type from existing JavaScript values, typeof is the tool for the job.

Default Generic Arguments

BEGINNER
5
111
@dimitropoulos
1 year ago

Default generic arguments allow you to optionally pass a generic argument.

Type Unions

BEGINNER
4
27
@dimitropoulos
1 year ago

Type unions are a powerful tool that allow you to create a type that's many values all at once.

Awaited

EASY
16
56
@typehero
5 months ago

If we have a type which is a wrapped type like Promise, how can we get the type which is inside th

Tuple to Object

EASY
4
39
@typehero
5 months ago

Given an array, transform it into an object type and the key/value must be in the provided array.

First of Array

EASY
4
35
@typehero
5 months ago

Implement a generic First<T> that takes an Array T and returns its first element's type.

For

Length of Tuple

EASY
0
28
@typehero
5 months ago

For given a tuple, you need create a generic Length, pick the length of the tuple

For example:

Exclude

EASY
4
34
@typehero
5 months ago

Implement the built-in Exclude<T, U>

Exclude from T those types that are assignable to U

Readonly

EASY
2
41
@typehero
5 months ago

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

Constructs a type with all proper

If

EASY
0
12
@typehero
5 months ago

Implement the util type If<C, T, F> which accepts condition C, a truthy value T, and a falsy

Concat

EASY
0
17
@typehero
5 months ago

Implement the JavaScript Array.concat function in the type system. A type takes the two argument

Includes

EASY
12
30
@typehero
5 months ago

Implement the JavaScript Array.includes function in the type system. A type takes the two argume

Push

EASY
1
16
@typehero
5 months ago

Implement the generic version of Array.push

For example:

type Result = Push<

Unshift

EASY
0
7
@typehero
5 months ago

Implement the type version of Array.unshift

For example:

type Result = Unshi

Parameters

EASY
0
14
@typehero
5 months ago

Implement the built-in Parameters generic without using it.

For example:

const foo = (a

The `Pick` builtin

EASY
1
14
@dimitropoulos
1 year ago

TypeScript ships with a Pick type. Learn how to make it yourself!

Get Return Type

MEDIUM
0
18
@typehero
5 months ago

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

For example

const fn = (v

Omit

MEDIUM
0
14
@typehero
5 months ago

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

Constructs a type by picking all pr

Readonly 2

MEDIUM
0
20
@typehero
5 months ago

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

K specify th

Deep Readonly

MEDIUM
6
18
@typehero
5 months ago

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

Tuple to Union

MEDIUM
0
9
@typehero
5 months ago

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

For

Last of Array

MEDIUM
0
7
@typehero
5 months ago

TypeScript 4.0 is recommended in this challenge

Implement a generic Last<T> that takes an Arr

Pop

MEDIUM
1
5
@typehero
5 months ago

TypeScript 4.0 is recommended in this challenge

Implement a generic Pop<T> that takes an Arra

Capitalize

MEDIUM
0
6
@typehero
5 months ago

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

Length of String

MEDIUM
0
3
@typehero
5 months ago

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

Trim Left

MEDIUM
0
5
@typehero
5 months ago

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

Trim

MEDIUM
0
4
@typehero
5 months ago

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

String to Union

MEDIUM
0
1
@typehero
5 months ago

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

Append to object

MEDIUM
0
4
@typehero
5 months ago

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

Append Argument

MEDIUM
0
3
@typehero
5 months ago

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

Type Lookup

MEDIUM
0
5
@typehero
5 months ago

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

In this challenge, we wou

Replace

MEDIUM
0
8
@typehero
5 months ago

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

ReplaceAll

MEDIUM
0
7
@typehero
5 months ago

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

Absolute

MEDIUM
0
13
@typehero
5 months ago

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

Permutation

MEDIUM
1
8
@typehero
5 months ago

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

Merge

MEDIUM
4
2
@typehero
5 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
5 months ago

Replace the camelCase or PascalCase string with kebab-case.

FooBarBaz -> foo-bar-baz

F

Diff

MEDIUM
0
2
@typehero
5 months ago

Get an Object that is the difference between O & O1

AnyOf

MEDIUM
1
2
@typehero
5 months ago

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