Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
TypeScript
/
Type guards
Why is declaring isSmallNumber(value): value is number unsafe when it returns false for n…
from Type guards
TypeScript 6
advanced
1 min
Why is declaring isSmallNumber(value): value is number unsafe when it returns false for numbers outside -9 through 9?
The false branch may still contain a number, but TypeScript can exclude number from the union.
Type predicates are allowed only for object types.
The compiler converts large numbers to strings in the false branch.
A predicate must throw whenever it returns false.
Check
Ask AI about this kata
Report an error
previous kata
After checking "id" in value on a non-null object, what has been proved?
Quiz
next kata
What does this program print?
Predict the output
A new version is available
Reload