# Type Annotation

> A note that says what kind of value a name holds, like count: number.

**Field:** Software Development  
**Category:** Programming Paradigms  
**Also known as:** Type Hint, Type Hints, Type Declaration

## Think of it like

Think of it like a label on a jar. It says sugar, so nobody fills it with salt.

## Definition

A type annotation is a note in the code that says what kind of value a name holds. In TypeScript you write a colon and the type, like count: number. Python has type hints that look the same, like width: int. A checker reads them and warns when a value of the wrong kind is used. They also tell the next reader what each function expects and gives back.

## Example

Jack marks area to take two whole numbers and give one back. When he passes it a word by mistake, his editor shows a red line.

## Example code

```python
def area(width: int, height: int) -> int:
    return width * height

print(area(3, 4))  # 12
```

The hints say both inputs and the answer are whole numbers.

## Why it matters

Annotations turn guesses into checked facts. Editors also use them to suggest the right names as you type.

## Common mistake

Expecting Python's hints to stop a wrong value on their own. Python ignores them at run time; a separate checker reads them.

## Three principles

- **A label on a name.** Says what kind it holds.
- **Read by checkers.** They warn on a mismatch.
- **Read by people.** Shows what a function wants.

## Related terms

- [Type System](https://learn.benibix.com/term/development/type-system)
- [Type Inference](https://learn.benibix.com/term/development/type-inference)
- [TypeScript](https://learn.benibix.com/term/development/typescript)
- [Data Type](https://learn.benibix.com/term/development/data-type)

## Told apart from

- [Type Annotation vs Type Inference](https://learn.benibix.com/compare/type-annotation-vs-type-inference): People think a typed language makes you write a type on every name, and it does not. A type annotation is a type you write yourself, such as count: number. Type inference is the language working the type out from the value, so let count = 0 is already a number. Most code uses both, with notes where they help the reader.

---

Source: https://learn.benibix.com/term/development/type-annotation
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
