/
githubmirror
/
babel
Обзор
Документация
Войти
/
githubmirror
/
babel
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
codemods/babel-plugin-codemod-optional-catch-binding/src/index.ts
22 строки
616 B
liuxingbaoyu
Enable `strictNullChecks` for more packages (#17828)
27 фев 2026, 20:06
Не верифицирован
27 фев 2026, 20:06
4fcbae7
Код
Авторство
О чём код?
import type { PluginAPI, PluginObject } from "@babel/core"; export default function ({ types: t }: PluginAPI): PluginObject { return { manipulateOptions: undefined, visitor: { CatchClause(path) { if (path.node.param === null || !t.isIdentifier(path.node.param)) { return; } const binding = path.scope.getOwnBinding(path.node.param.name)!; if (binding.constantViolations.length > 0) { return; } if (!binding.referenced) { const paramPath = path.get("param"); paramPath.remove(); } }, }, }; }