functionadd(a: number, b: number): number { return a + b; }
main.ts
1 2 3
import { add } from'./add';
console.log(add(1000, 337));
Fixed Code ✔️
The error TS2306 signals that the file (add.ts) can be found (otherwise it would throw error TS2307) but does not provide the necessary exports. We can solve this with a named export:
add.ts
1 2 3
exportfunctionadd(a: number, b: number): number { return a + b; }
Alternatively we can use a default export:
add.ts
1 2 3
exportdefaultfunctionadd(a: number, b: number): number { return a + b; }
Using a default export requires that we also adjust our import statement in main.ts (otherwise we would end up with error TS2614):