I'm currently working on a project where I have a lot of files like that, exporting functions like this:
// file: myFunctions.ts
// Function 1
export function add(a: number, b: number): number {
return a + b;
}
// Function 2
export function subtract(a: number, b: number): number {
return a - b;
}
// Function 3
export function multiply(a: number, b: number): number {
return a * b;
}
Then other files import them like this:
import * as CalcFunctions from './myFunctions';
However, I'd like to organize my code in a way that allows for automatic completion and avoids changing the import names. I'm thinking of using a namespace like this:
namespace CalcFunctions
{
export function add(a: number, b: number): number {
return a + b;
}
// Function 2
export function subtract(a: number, b: number): number {
return a - b;
}
// Function 3
export function multiply(a: number, b: number): number {
return a * b;
}
}
But namespace is not recommended by Eslint: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-namespace.md
So what is the best way to manage that?