diff --git a/package.json b/package.json index 1263eee..af25104 100644 --- a/package.json +++ b/package.json @@ -63,4 +63,4 @@ "express": "^4.18.1", "zod": "^3.17.10" } -} +} \ No newline at end of file diff --git a/src/01-number.md b/src/01-number.md new file mode 100644 index 0000000..d336119 --- /dev/null +++ b/src/01-number.md @@ -0,0 +1,30 @@ +# Parameter X implicitly has an 'any' type + +```typescript +const addTwoNumbers = (a, b) => { + return a + b +} +``` + +> Parameter 'a' implicitly has an 'any' type. +> +> Parameter 'b' implicitly has an 'any' type. + +## What is going on? + +Missing type annotation to a parameter in a function. + +It is turned on by strict mode. + +```json +// tsconfig.json +{ + "compilerOptions": { + "strict": true + } +} +``` + +## Why is this important? + +This is the essence of Typescript, without it the code is loosely typed and errors are prone to happen. diff --git a/src/01-number.problem.ts b/src/01-number.problem.ts index 0f6286e..f206234 100644 --- a/src/01-number.problem.ts +++ b/src/01-number.problem.ts @@ -1,6 +1,6 @@ import { expect, it } from "vitest"; -export const addTwoNumbers = (a, b) => { +export const addTwoNumbers = (a: number, b:number) => { return a + b; };