Skip to main content

Type Illusions

A Learning TypeScript > Declaration Files 🍲 entree project.

Salutations! Come one, come all - to the amazing Type Illusionist!

It's no trick, no common shenanigan. These illusions will amaze and astound.

Watch as I make the entire ./show.ts file... disappear! ✨ Poof!

But wait, there's more! I will also disappear all the type annotations in ./index.ts, leaving behind only JavaScript!

Now, our audience volunteer -that's you!- will have to add those type annotations back to prove the magic did not harm the code's runtime behavior.


If you haven't yet, set up the repository locally.

git clone learning-typescript-projects
cd learning-typescript-projects
npm i

Change your terminal directory to this project's:

cd projects/declaration-files/type-illusions

In a terminal, start the TypeScript compiler in watch mode:

tsc --watch


  • index.ts: Add back type imports from "./show" and corresponding type annotations
  • show.d.ts: Declare types for the missing show module here based on the remaining code in index.ts
  • index.solution.ts and show.solution.ts: Solution code


  • Don't use any or leave any implicit anys.
  • Don't change any runtime code behavior. You're just working in the type system.