Skip to main content

Warm-up Challenges

The warm-up challenge introduces you to how Type Challenges work. You’ll learn the basic format and testing approach used throughout all challenges.
This is the perfect starting point if you’re new to Type Challenges. It explains the testing methodology and gets you comfortable with the format.

Challenge List

#13 - Hello World

Your first Type Challenge - learn how the testing system works

Challenge: Hello World

#13 - Hello World

Description

In Type Challenges, we use the type system itself to do the assertion. For this challenge, you will need to change the following code to make the tests pass (no type check errors).

Starting Code

// expected to be string
type HelloWorld = any

Test Cases

// you should make this work
type test = Expect<Equal<HelloWorld, string>>

Expected Solution

Replace any with the correct type to make HelloWorld equal to string.

What You’ll Learn

  • How Type Challenges uses compile-time assertions
  • The Expect and Equal testing utilities
  • Basic type assignment in TypeScript

Try It Yourself

Take the Challenge

Open this challenge in the TypeScript Playground

Understanding the Test System

Type Challenges uses a unique testing approach:

How Tests Work

type Expect<T extends true> = T
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends
  (<T>() => T extends Y ? 1 : 2) ? true : false
These utility types check if your solution matches the expected type:
  • Equal<X, Y>: Returns true if types X and Y are identical, false otherwise
  • Expect<T>: Only accepts true, causing a type error if the test fails

Example Test

// This passes - no type error
type test1 = Expect<Equal<string, string>>

// This fails - type error!
type test2 = Expect<Equal<string, number>>

Tips for Warm-up

The Hello World challenge is intentionally simple. The goal is to understand the testing format, not to solve a complex problem.
The test cases tell you exactly what type your solution should produce. In this case, HelloWorld must equal string.
Click “Take the Challenge” to open the problem in the TypeScript Playground where you can test your solution interactively.
Your solution is correct when there are no red underlines or type errors in the editor.

Key Concepts

Type Aliases

Type aliases let you create named types:
type MyString = string
type MyNumber = number
type MyObject = { name: string; age: number }

Type Equality

In TypeScript, these are equivalent:
type A = string
type B = string
// A and B are the same type

Why Not any?

The any type opts out of type checking:
type HelloWorld = any
// any is compatible with everything, but provides no type safety

type HelloWorld = string
// string is specific and type-safe

Next Steps

Once you’ve completed the warm-up, you’re ready to move on to:

Easy Challenges

13 challenges covering fundamental type operations

Back to Overview

Review the challenge system overview

Additional Resources

TypeScript Basics

Learn about everyday types in TypeScript