I'm developing a web application in VueJs, Typescript and WebPack and I'm a bit confused about how to manage/split groups of functions (utilities and services).
I saw in various project in GitHub that some functions are declared and exported directly from the file ex:
utilities.ts
export function Sum(a:number, b:number):number{
return a+b;
}
this can be used with an import:
import {Sum} from "./utilities.ts"
let result = Sum(5,6);
Another common solution is to declare a const class:
otherUtilities.ts
export const OtherUtilities = {
Sum(a:number, b:number) : number => {
return a+b;
},
Hello() : string => {
return "Hello";
}
}
and import as:
import {OtherUtilities} from "./otherUtilities.ts"
let result = OtherUtilities.Sum(5,6);
What are the differences?
In the past, there was the Name Conflict issue with JS but now with the export/import technique via Loaders, this issue should be outdated, right?
Thank you