sfmc-devtools icon indicating copy to clipboard operation
sfmc-devtools copied to clipboard

[TASK] rewrite util/** to static classes to improve IntelliSense (outline) / CSCLSROZ-404

Open SarikaBhosale11 opened this issue 2 years ago • 5 comments

turn this image

into image

for every file in lib/util

SarikaBhosale11 avatar Aug 02 '21 16:08 SarikaBhosale11

@JoernBerkefeld when writting it to static classes, what should i do with the defined var?

move them to a constructor as in here? image

or is there a better aproach?

tuliodnw avatar Jul 25 '22 11:07 tuliodnw

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 avatar Jul 25 '22 12:07 JoernBerkefeld

image 2022-07-25_17h45_52

@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?

tuliodnw avatar Jul 25 '22 15:07 tuliodnw

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)

JoernBerkefeld avatar Jul 26 '22 11:07 JoernBerkefeld

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

tuliodnw avatar Aug 03 '22 10:08 tuliodnw