# Intrinsic String Types

> Built-in types for manipulating string casing.

Subject: TypeScript | Lesson 33 of 54 | 4 min read
Interactive lesson: https://codewithanimation.in/typescript/intrinsic-string-types
Previous: [Template Literal Types](https://codewithanimation.in/typescript/template-literal-types.md) | Next: [Recursive Types](https://codewithanimation.in/typescript/recursive-types.md)

## Compiler Magic

TypeScript provides four special utility types specifically for manipulating the casing of string literal types: `Uppercase<StringType>`, `Lowercase<StringType>`, `Capitalize<StringType>`, and `Uncapitalize<StringType>`.

Unlike other utilities like `Partial<T>`, you cannot see the source code for these types. They are marked as `intrinsic`, meaning the TypeScript compiler handles them internally for performance.

## Enforcing String Formats

When building complex UI libraries or mapping APIs, you often need to transform keys—for example, converting an `id` property into a `setId` action.

Intrinsic string types, when combined with Template Literal Types, allow you to enforce these naming conventions perfectly at compile-time.

## Syntax

```typescript
type A = Uppercase<"hello">; // "HELLO"
type B = Lowercase<"WORLD">; // "world"
type C = Capitalize<"john">; // "John"
type D = Uncapitalize<"App">; // "app"

// Often used in template literal types:
type Prefix<T extends string> = `get${Capitalize<T>}`;
type NameGetter = Prefix<"name">; // "getName"
```

## Common mistake: Strict Inputs

Intrinsic string types ONLY accept string literal types or string unions.

If you try to pass a `number`, `boolean`, or a non-string object into `Uppercase<T>`, the compiler will immediately throw a type error. (Which is why you often see `string & K` when iterating over keys).

## Tip: Union Distribution

Like conditional types, intrinsic string types distribute across unions! `Uppercase<"yes" | "no">` automatically becomes `"YES" | "NO"`.

## Try it: Try it

Explore the four intrinsic string types and observe how the compiler instantly manipulates string literal values at compile-time.

The animation is on the lesson page and is not part of this text version: https://codewithanimation.in/typescript/intrinsic-string-types

## Check yourself

### Question 1

Why are these string types called 'intrinsic'?

- A. Because they are written in JavaScript instead of TypeScript.
- B. Because their implementation is hardcoded directly into the TypeScript compiler.
- C. Because they are imported from the 'intrinsic' module.

Correct answer: B

Intrinsic types don't have standard mapped/conditional type definitions. The TypeScript compiler engine executes their logic directly for better performance.

- Why not A: They are part of the type system, not the runtime code.
- Why not C: They are globally available without importing anything.

## Remember this

- TypeScript provides 4 intrinsic string types: Uppercase, Lowercase, Capitalize, and Uncapitalize.
- Their logic runs internally inside the compiler (`intrinsic`).
- They are almost always used alongside Template Literal Types.
- They distribute across string unions automatically.
