From 86b1a9042f44faea81dd560feb01df3d3bc86e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 19 May 2022 21:46:37 +0200 Subject: [PATCH] Fix TypeScript plugin compat with `@babel/types` versions --- packages/babel-plugin-transform-typescript/src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/babel-plugin-transform-typescript/src/index.ts b/packages/babel-plugin-transform-typescript/src/index.ts index b881f48e9151..ef57f17e9e34 100644 --- a/packages/babel-plugin-transform-typescript/src/index.ts +++ b/packages/babel-plugin-transform-typescript/src/index.ts @@ -573,7 +573,12 @@ export default declare((api, opts: Options) => { path.replaceWith(node); }, - "TSNonNullExpression|TSInstantiationExpression"( + [process.env.BABEL_8_BREAKING + ? "TSNonNullExpression|TSInstantiationExpression" + : // This has been introduced in Babel 7.18.0 + t.tsInstantiationExpression + ? "TSNonNullExpression|TSInstantiationExpression" + : "TSNonNullExpression"]( path: NodePath, ) { path.replaceWith(path.node.expression);