ts-optchain
ts-optchain copied to clipboard
TypeScript Custom Code Transformer does not work
trafficstars
Install instruction to setup TypeScript Custom Code Transformer https://github.com/rimeto/ts-optchain#typescript-custom-code-transformer
- Using
TTypescriptBundle contains
/***/ "./node_modules/ts-optchain/dist/proxy/index.js":
/*!******************************************************!*\
!*** ./node_modules/ts-optchain/dist/proxy/index.js ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (C) 2019-present, Rimeto, LLC.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Proxy based implementation of optional chaining w/ default values.
*/
function oc(data) {
return new Proxy((function (defaultValue) { return (data == null ? defaultValue : data); }), {
get: function (target, key) {
var obj = target();
return oc(typeof obj === 'object' ? obj[key] : undefined);
},
});
}
exports.oc = oc;
I do not see transformed result, e.g.
const value =
(obj != null && obj.propA != null && obj.propA.propB != null && obj.propA.propB.propC != null)
? obj.propA.propB.propC
: defaultValue;
- Same result when using
getCustomTransformersofts-loaderPart of webpack.config
getCustomTransformers: program => ({
before: [
require('ts-optchain/transform').default(program),
]
}),
Environment
node 12.6
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]
Same problem!
Anyone managed to solve this?
This is not an issue for me, since typescript 3.7 with optional chaining feature.