This repository demonstrates a common type error in TypeScript: attempting to perform an operation on incompatible types. The add function is explicitly typed to accept two numbers, but the call to add(1, "2") passes a string as the second argument. This leads to a compile-time error in TypeScript and a runtime error in JavaScript if the type checking is not enabled. The solution demonstrates how to use type guards or type assertions to handle potential type mismatches.
-
Notifications
You must be signed in to change notification settings - Fork 0
Bug-Hunter-X/Type-Error-in-TypeScript-Addition
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
This code produces a TypeError because it attempts to add a number and a string. TypeScript's type system catches this error during compilation.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published