I am writing a Babel plugin in TypeScript and have been struggling to find a lot of examples or documentation doing so. For example, I am writing a visitor plugin with the following signature:
export default function myPlugin({ types: t }: typeof babel): PluginObj {
I am getting a few types from:
import type { PluginObj, PluginPass } from '@babel/core';
The part that bothers me is the { types: t }: typeof babel
which is coming from
import type * as babel from '@babel/core';
The few examples I found online were using this but is this really how it's supposed to be typed?