Type Hint
PronunciationTYPE hint
Definition
A type hint is a note in the code that says what type a value should have. Tools such as editors and type checkers use it to find mistakes early.
Where you hear it
In Python and TypeScript projects, code reviews, and discussions of how to make a dynamic language safer.
Examples
Add type hints to the function signature so the editor can warn us.
Python ignores type hints at runtime; a separate checker reads them.
The function signature has type hints, so the editor shows the expected argument type.
Common mistake
Assuming type hints are enforced. In Python they are not checked when the program runs; you need a tool such as mypy.
Don't confuse with
A runtime check such as isinstance, which actually inspects a value while the program runs.
Say it at work
- In a meeting or chat
Please add type hints to the public functions.
- In an email or ticket
The checker caught a wrong type before the tests even ran.
Keep exploring
More in Programming Fundamentals