sfmc-devtools
sfmc-devtools copied to clipboard
[TASK] rewrite util/** to static classes to improve IntelliSense (outline) / CSCLSROZ-404
turn this
into
for every file in lib/util
@JoernBerkefeld when writting it to static classes, what should i do with the defined var?
move them to a constructor as in here?
or is there a better aproach?
If it was part of the object, just define it as a static property with whatever initial value we had before. Constructors are for non-static classes only, as in classes that have methods that are not marked as static. Here we want all methods to be declared static and hence avoid creating an instance of the class when using it (which is where the constructor could be used)
@JoernBerkefeld in a test bench it works, but in sfmc the value comes as undefined. writing the static property also gives me eslint errors.
any ideas?
Check out the the error&warning log in vscode. It will have at least one item for you to fix. Alternatively, check your screenshot for Red underlines and hover that in vscode (hint: line 2)
the problem arises from File.js after the class is static exporting both modules doesnt work with File only fs functions are being passed
cons FileFs = { ...File, ...fs }; // also tried consFileFs = { File, ...fs };
FileFs.prettierConfig = null;
module.exports = FileFs;
i can pass the module for File like this. and import fs separately.
module.exports = File;
and rewrite File.pathExists(Util.configFileName) to fs.pathExists(Util.configFileName)
and all other from the fs library.
should i do it like this?, Ana recommended me this solution