I would really like intellisense to work on VS Code and it does if I choose a string literal for the module I wish to require. For eg:
// When using this, intellisense works
const myLib = require("../../MyLibraries/myLibrary.js");
When I use this, intellisense does not work
const pathToLib = "../../MyLibraries";
const myLib = require(`${pathToLib}/myLibrary.js`);
Or when I use this, intellisense still does not work.
function requireFromLib(file) {
return require(`../../MyLibraries/${file}`);
}
const logger = requireFromLib('myLibrary.js');
This last option was recommended by ChatGPT and it also said to restart Typescript if this fails. I have tried them both and it still does not work.
I have also tried process.env. and that fails too.
I can use string literal, but I have a lot of modules from my library that I include from time to time and using a base path to the Library's folder makes it easier to make changes. Any advice on how to get intellisense to work?