Hacky way to implement elvis operator (aka safe navigation) with typescript plugin.
If you want to just get the corresponding JavaScript output given TypeScript sources. For this you can use ts.transpileModule to get a string => string transformation like below.
If you want get custom compiler only in addition to native tsc that's run custom transformer before compilation. Custom compiler that will take a list of TypeScript files and compile down to their corresponding JavaScript files.
console.log(a.test?.way?.dd.cc?.uu);
console.log(ac?.test?.test2);
console.log(ac?.test[3]?.test2);
console.log(a?.test);
console.log(a.test?a.c?4:32:3)
console.log((((a.test || {}).way || {}).dd.cc || {}).uu);
console.log(((ac || {}).test || {}).test2);
console.log(((ac || {}).test[3] || {}).test2);
console.log((a || {}).test);
console.log(a.test ? a.c ? 4 : 32 : 3);
yarn add ts-safe-access
npm i ts-safe-access --save --dev
ttsc <input_file_name>.ts
Module transpiler example can be found here
Custom compiler example can be found here