// math.ts
export function add(x: number, y: number): number {
    return x + y;
}

// app.ts
import { add } from './math';

console.log(add(5, 10)); // Output: 15
Bash

Explanation:

  • This program demonstrates how to use modules in TypeScript.
  • The math.ts file exports a function add, which is then imported in the app.ts file.
  • The result of the addition is logged to the console.
Resize text
Scroll to Top