I have a web development framework which I use on personal backend projects. All web apps revolve around my framework and the API is quite big so importing it in each file becomes tiring and repetitive.
The solution I came up with is using this code in my program main/entry point
Object.assign(global, require("@mycompany/myframework"));
Now I'm able to access all classes, constants and functions without importing them in each file.
The only problem is that my framework is written in TypeScript but my IDE is not recognising the types globally, so after using any of my framework class, the editor/IDE will report that the API has not been imported.
Do you have a complete solution for this problem?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/TqDuQgm
Comments
Post a Comment