I’m looking for a tool that could help me to do the following operation:
Given that code:
const before = (arg1: string, arg2: string) => null;
I would like to have the following result:
const after = ({ arg1, arg2 }: { arg1: string; arg2: string }) => null;
Is it possible to do that with a snippet ? (for exemple, i select my args and it directly transform them)
2
Answers
Define the following Typescript snippet
()
conarg
and select the snippetAs I generally need to execute a considerably big list of changes, I tend to use Tasks (Ctrl+Shift+P/Run Task/[task name])
https://code.visualstudio.com/docs/editor/tasks
My scripts read the file, make fixes (mostly with
string.replace(/regex/g, callback)
), and overwrite the fileI only use
${file}
, but if you can also add line number or selection as script argumentshttps://code.visualstudio.com/docs/editor/variables-reference
self-made somple replacer library