From 2e628809347c444538ad4153c2b165f0bf62ef81 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 1 Nov 2020 02:16:34 +0100 Subject: [PATCH] get rid of ts ignore --- packages/babel-plugin-jest-hoist/src/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/babel-plugin-jest-hoist/src/index.ts b/packages/babel-plugin-jest-hoist/src/index.ts index a4a89723d8b5..f952746674e6 100644 --- a/packages/babel-plugin-jest-hoist/src/index.ts +++ b/packages/babel-plugin-jest-hoist/src/index.ts @@ -142,11 +142,10 @@ FUNCTIONS.mock = args => { if (!isAllowedIdentifier) { const binding = scope.bindings[name]; - if (binding) { - // @ts-expect-error `init` does not exist + if (binding?.path.isVariableDeclarator()) { const initNode = binding.path.node.init; - if (binding.constant && scope.isPure(initNode, true)) { + if (initNode && binding.constant && scope.isPure(initNode, true)) { // replace the reference with its constant value id.replaceWith(initNode);