Closed wielrls closed 5 years ago
We have built a custom transformer to support optional chaining in TypeScript: https://github.com/rimeto/ts-optchain
{ "transform": "ts-optchain/transform" }
ts-optchain/transform automatically converts the code:
ts-optchain/transform
const obj: T = { /* ... */ }; const value = oc(obj).propA.propB.propC(defaultValue);
...into:
const obj: T = { /* ... */ }; const value = (obj != null && obj.propA != null && obj.propA.propB != null && obj.propA.propB.propC != null) ? obj.propA.propB.propC : defaultValue;
Would appreciate a cross-link!
done!
We have built a custom transformer to support optional chaining in TypeScript: https://github.com/rimeto/ts-optchain
ts-optchain/transform
automatically converts the code:...into:
Would appreciate a cross-link!