From 29d6afea4f736bc32d24dcec881649a50bf69fa9 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sun, 20 Feb 2022 11:55:39 +1300 Subject: [PATCH] fix(babel-plugin-jsx-pragmatic): update babel core types --- .../babel-plugin-jsx-pragmatic/package.json | 2 +- .../babel-plugin-jsx-pragmatic/src/index.ts | 27 +++++++------------ yarn.lock | 8 +++--- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/packages/babel-plugin-jsx-pragmatic/package.json b/packages/babel-plugin-jsx-pragmatic/package.json index b88076a9a..40c97472f 100644 --- a/packages/babel-plugin-jsx-pragmatic/package.json +++ b/packages/babel-plugin-jsx-pragmatic/package.json @@ -24,6 +24,6 @@ }, "devDependencies": { "@babel/core": "^7.13.10", - "@types/babel__core": "^7.1.16" + "@types/babel__core": "^7.1.18" } } diff --git a/packages/babel-plugin-jsx-pragmatic/src/index.ts b/packages/babel-plugin-jsx-pragmatic/src/index.ts index 4a95dcf3d..2315326e7 100644 --- a/packages/babel-plugin-jsx-pragmatic/src/index.ts +++ b/packages/babel-plugin-jsx-pragmatic/src/index.ts @@ -1,7 +1,7 @@ import type { NodePath, PluginObj, - PluginPass as BabelPluginPass, + PluginPass, types as BabelTypes } from '@babel/core' import syntaxJsx from '@babel/plugin-syntax-jsx' @@ -16,31 +16,22 @@ const findLast = (arr: T[], predicate: (item: T) => boolean): T | null => { return null } -// todo: PR these to @types/babel__core - PluginPass should extend Store -// https://github.com/babel/babel/blob/4e50b2d9d9c376cee7a2cbf56553fe5b982ea53c/packages/babel-core/src/transformation/store.js -interface BabelStore { - setDynamic(key: string, fn: () => unknown): void - set(key: string, val: unknown): void - get(key: string): unknown -} - -type PluginPass = BabelPluginPass & - BabelStore & { - opts: { - module: string - import: string - export?: string - } +interface PluginPassWithOpts extends PluginPass { + opts: { + module: string + import: string + export?: string } +} export default function jsxPragmatic(babel: { types: typeof BabelTypes -}): PluginObj { +}): PluginObj { const t = babel.types function addPragmaImport( path: NodePath, - state: PluginPass + state: PluginPassWithOpts ) { const importDeclar = t.importDeclaration( [ diff --git a/yarn.lock b/yarn.lock index a8ef3c601..bcb31ea06 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5594,10 +5594,10 @@ "@types/babel__template" "*" "@types/babel__traverse" "*" -"@types/babel__core@^7.1.16": - version "7.1.16" - resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.16.tgz#bc12c74b7d65e82d29876b5d0baf5c625ac58702" - integrity sha512-EAEHtisTMM+KaKwfWdC3oyllIqswlznXCIVCt7/oRNrh+DhgT4UEBNC/jlADNjvw7UnfbcdkGQcPVZ1xYiLcrQ== +"@types/babel__core@^7.1.18": + version "7.1.18" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.18.tgz#1a29abcc411a9c05e2094c98f9a1b7da6cdf49f8" + integrity sha512-S7unDjm/C7z2A2R9NzfKCK1I+BAALDtxEmsJBwlB3EzNfb929ykjL++1CK9LO++EIp2fQrC8O+BwjKvz6UeDyQ== dependencies: "@babel/parser" "^7.1.0" "@babel/types" "^7.0.0"