#35991Medium

MyUppercase

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

In this medium-level challenge, you'll implement your own version of the built-in Uppercase<T> intrinsic type, converting all lowercase letters in a string literal type to uppercase without using the built-in.

Challenge Instructions: MyUppercase

Medium

Implement Uppercase<T>, convert all letter to uppercase

Change the following code to make the test cases pass (no type check errors).

Loading...

Detailed Explanation

type UpperMap = {
  a: 'A'; b: 'B'; c: 'C'; d: 'D'; e: 'E'; f: 'F'; g: 'G';
  h: 'H'; i: 'I'; j: 'J'; k: 'K'; l: 'L'; m: 'M'; n: 'N';
  o: 'O'; p: 'P'; q: 'Q'; r: 'R'; s: 'S'; t: 'T'; u: 'U';
  v: 'V'; w: 'W'; x: 'X'; y: 'Y'; z: 'Z';
};
 
type MyUppercase<T extends string> =
  T extends `${infer First}${infer Rest}`
    ? `${First extends keyof UpperMap ? UpperMap[First] : First}${MyUppercase<Rest>}`
    : T;

How it works:

This challenge helps you understand recursive template literal type transformations and character-level string processing, and how to apply these concepts in real-world scenarios.

This challenge is originally from here.

Share this challenge

Join early, learn faster.

Be the first to access the course, unlock exclusive launch bonuses, and get special early-bird pricing before anyone else.

No spam, unsubscribe at any time. We respect your privacy.

Limited Availability

Only 27 Spots left

Early Access

Get 1 month early access

>75% Off

Pre-Launch discount