Skip to content

Commit

Permalink
fix(babel-plugin-jsx-pragmatic): update babel core types
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Feb 19, 2022
1 parent 339a3ef commit 29d6afe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/babel-plugin-jsx-pragmatic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
},
"devDependencies": {
"@babel/core": "^7.13.10",
"@types/babel__core": "^7.1.16"
"@types/babel__core": "^7.1.18"
}
}
27 changes: 9 additions & 18 deletions packages/babel-plugin-jsx-pragmatic/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -16,31 +16,22 @@ const findLast = <T>(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<PluginPass> {
}): PluginObj<PluginPassWithOpts> {
const t = babel.types

function addPragmaImport(
path: NodePath<BabelTypes.Program>,
state: PluginPass
state: PluginPassWithOpts
) {
const importDeclar = t.importDeclaration(
[
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 29d6afe

Please sign in to comment.