typescriptbabeljsts-jesttypescript-decoratorjest-expo

What for incompatibility between babel-proposal-decorators and typescript-decorator?


I recently rewrite CyriacBr/class-fixtures-factory with updating libraries version at https://github.com/MOCHI-inc-JAPAN/class-fixtures-factory. I succeeded running it in ts-jest environment, but switch jest-expo, doesn't work. I suspect decorator's not processed properly in jest-expo for incompatibility of typescript's one. Decorator looks working both environment, but not properly reflect the metadata from property type, in typescript decorator metadata includes typeClassification, but in jest-expo(maybe babel-proposal-decorators) doesn't. Why this difference happens and, how do I adjust jest-expo behavior to ts-jest? In addition, we want to use this library in expo environment because our products have some snapshot tests.

This repository can reproduce it.


Solution

  • module.exports = function(api) {
      api.cache(true);
      return {
        "plugins": [
          ["babel-plugin-transform-typescript-metadata"],
        ],
        presets: ['babel-preset-expo'],
      };
    };
    

    I can work it only to add babel-plugin-transform-typescript-metadata. It enables this to store metadata like typescript compiler.