Command Palette

Search for a command to run...

Hectal
Phase 15: TypeScript in Real Projects
TypeScript · Exercise 3 of 6 PreviousNext
Intermediate

Make the type tests pass

The file has Equal, Expect and three type tests for a helper type IsString<T>. The helper is a stub that always says false, so two tests fail.

Write IsString<T> so IsString<"a"> is true, IsString<1> is false, and IsString<string | number> is false (a union containing a non-string is not a string).

What Check tests

  1. Your code has no type errors
  2. Plain string is true
  3. A wrong expectation fails
  4. A union with a non-string is false

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Console

Nothing printed yet.