Files
e4178c50bd chore: Use Gulpfile.mts (#17579)
* Gulpfile.ts

* fix

* chore: remove ts-node and patch interpret

The patched version now recognizes the gulp config `Gulpfile.mts` and the built in node type stripping will then kick in.

* fix

---------

Co-authored-by: Huáng Jùnliàng <[email protected]>
2025-11-25 22:58:07 +01:00

38 lines
1.0 KiB
TypeScript

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;
}