Skip to content

Instantly share code, notes, and snippets.

@retyui
Last active Oct 9, 2019
Embed
What would you like to do?
Fix plugin-transform-typescript for fbt

In file node_modules/@babel/plugin-transform-typescript/lib/index.js

For a function isImportTypeOnly add code:

  function isImportTypeOnly({
    binding,
    programPath,
    jsxPragma
  }) {
    for (const path of binding.referencePaths) {
      if (!isInType(path)) {
        return false;
      }
    }

+    // Small fix to stop removing `import fbt from 'fbt';`
+    if (binding.identifier.name === 'fbt') {
+      return false;
+    }

    if (binding.identifier.name !== jsxPragma) {
      return true;
    }
// ...

And add postinstall script to package.json

{
  "name": "fbtDemo",
  "scripts": {
+    "postinstall": "git checkout -f -- :/node_modules",
    "start": "react-native start",
  },
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment