Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

TypeScript Custom Code Transformer does not work #45

Open
unlight opened this issue Jul 12, 2019 · 2 comments
Open

TypeScript Custom Code Transformer does not work #45

unlight opened this issue Jul 12, 2019 · 2 comments

Comments

@unlight
Copy link

unlight commented Jul 12, 2019

Install instruction to setup TypeScript Custom Code Transformer
https://github.com/rimeto/ts-optchain#typescript-custom-code-transformer

  1. Using TTypescript
    Bundle 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;
  1. Same result when using getCustomTransformers of ts-loader
    Part of webpack.config
                            getCustomTransformers: program => ({
                                before: [
                                    require('ts-optchain/transform').default(program),
                                ]
                            }),

Environment

@mmontes11
Copy link

Same problem!

Anyone managed to solve this?

@unlight
Copy link
Author

unlight commented Apr 21, 2020

This is not an issue for me, since typescript 3.7 with optional chaining feature.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants