mirror of
https://github.com/hanzoai/babel.git
synced 2026-10-30 14:46:06 +00:00
* refactor: split virtual types validators * move type predicates to interface * fix: nodeIsBlockScoped only accept one argument * fix: virtual types validators should validate types first * fix: register virtual types validators after base types * remove virtual-types from gulpfile jsdoc comment * simplify virtual types
28 lines
708 B
JavaScript
28 lines
708 B
JavaScript
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";
|
|
|
|
interface BaseNodePathValidators {
|
|
`;
|
|
|
|
for (const type of [...t.TYPES].sort()) {
|
|
output += `is${type}<T extends t.Node>(this: NodePath<T>, opts?: object): this is NodePath<T & t.${type}>;`;
|
|
}
|
|
|
|
output += `
|
|
}
|
|
|
|
export interface NodePathValidators
|
|
extends BaseNodePathValidators, VirtualTypeNodePathValidators {}
|
|
`;
|
|
|
|
return output;
|
|
}
|