mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
* 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]>
33 lines
716 B
TypeScript
33 lines
716 B
TypeScript
import * as t from "@babel/types";
|
|
|
|
export default function generateAsserts() {
|
|
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";
|
|
|
|
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];
|
|
}>;
|
|
|
|
export interface NodePathAssertions {`;
|
|
|
|
for (const type of [...t.TYPES].sort()) {
|
|
output += `
|
|
assert${type}<Opts extends Options<t.${type}>>(
|
|
opts?: Opts,
|
|
): asserts this is NodePath<t.${type} & Opts>;`;
|
|
}
|
|
|
|
output += `
|
|
}`;
|
|
|
|
return output;
|
|
}
|