TypeScript 'declare' fields must first be transformed by @babel/plugin-transform-typescript

Solution 1:

I got this same error when I upgraded my React Native project to 0.64.2. To fix it, I had to change the babel.config.js file as follows:

module.exports = {
  presets: [
    'module:metro-react-native-babel-preset',
    ['@babel/preset-typescript', {allowDeclareFields: true}],
  ],
};

I'd guess in your craco.config.js this would map to the following (though I don't know what craco is, so just a guess based on the similarity to babel.config.js):

    presets: [
      ["@babel/preset-typescript", {allowDeclareFields: true}],
      "@babel/preset-react",
      "@babel/preset-env",
    ],
  },