/
githubmirror
/
babel
Обзор
Документация
Войти
/
githubmirror
/
babel
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/babel-traverse/scripts/generators/validators.ts
37 строк
1 KB
liuxingbaoyu
chore: Use Gulpfile.mts (#17579)
26 ноя 2025, 00:58
Не верифицирован
26 ноя 2025, 00:58
aac2c37
Код
Авторство
О чём код?
import * as t from "@babel/types"; export default function generateValidators() { let output = `/* * This file is auto-generated! Do not modify it directly. * To re-generate run 'make build' */ import type * as t from "@babel/types"; import type NodePath from "../index"; import type { VirtualTypeNodePathValidators } from "../lib/virtual-types-validator"; type Options<Obj> = Partial<{ [Prop in Exclude<keyof Obj, "type">]: Obj[Prop] extends t.Node ? t.Node : Obj[Prop] extends t.Node[] ? t.Node[] : Obj[Prop]; }>; interface BaseNodePathValidators { `; for (const type of [...t.TYPES].sort()) { output += `is${type}(this: NodePath<t.Node | null>): this is NodePath<t.${type}>;`; output += `is${type}<Opts extends Options<t.${type}>>(this: NodePath<t.Node | null>, opts: Opts): this is NodePath<t.${type} & Opts>;`; } output += ` } export interface NodePathValidators extends Omit<BaseNodePathValidators, keyof VirtualTypeNodePathValidators>, VirtualTypeNodePathValidators {} `; return output; }