Fix: You gave us a visitor for the node type TSInstantiationExpression but it’s not a valid type

After one of recent bablejs update, when I am trying to run the project using bablejs and expo, below error is shown:

You gave us a visitor for the node type TSInstantiationExpression but it's not a valid type

I am sharing the solution below that worked for me to run the project without any error.

Why You gave us a visitor for the node type TSInstantiationExpression but it’s not a valid type Error Occurred?

Why You gave us a visitor for the node type TSInstantiationExpression but it’s not a valid type error occurred because of recent babel-core: 7.18.0 version update. This error basically happens when expo and bablejs have compatibility issue with different versions. Either you have updated bablejs version recently or still using old expo version.

How to fix You gave us a visitor for the node type TSInstantiationExpression but it’s not a valid type Error?

To Fix the error, delete the node_modules folder and then delete yarn.lock file and then upgrade the expo-cli using command yarn global add expo-cli.

Below is the step by step process to fix the You gave us a visitor for the node type TSInstantiationExpression but it’s not a valid type Error:

Fix 1: Delete npm-modules and re-install

Step 1: Delete npm-modules

Run the below command to delete the npm-modules

rm -rf node_modules 

Step 2: Delete the yarn.lock file

Use the below command to delete the yarn.lock file

rm yarn.lock && yarn

Step 3: Or Run the below command to Delete yarn.lock and npm_module file

rm -rf ./node_modules && rm yarn.lock && yarn

Step 4: Run npm install command

Use the below command to install the npm module again:

npm install

Above steps must fix the You gave us a visitor for the node type TSInstantiationExpression but it’s not a valid type Error.

Fix 2: Update the expo-cli

Just update the expo cli to the latest version and it would solve the error. Run the below command to update the expo-cli to the latest version:

yarn global add expo-cli

Once expo-cli has been updated to the latest version, You gave us a visitor for the node type TSInstantiationExpression but it’s not a valid type Error would be fixed.

Conclusion

To Fix the error, delete the node_modules folder, then delete yarn.lock file and install the npm module again.

OR Upgrade the expo-cli to latest version using command yarn global add expo-cli and it would fix the You gave us a visitor for the node type TSInstantiationExpression but it’s not a valid type Error.