保誠-保戶業務員媒合平台
HelenHuang
2022-06-09 23b60dc1975db38c280d8a123aff97544d1673e0
PAMapp/node_modules/@babel/traverse/scripts/generators/validators.js
@@ -1,6 +1,5 @@
import t from "@babel/types";
import virtualTypes from "../../lib/path/lib/virtual-types.js";
import definitions from "@babel/types/lib/definitions/index.js";
export default function generateValidators() {
  let output = `/*
@@ -21,10 +20,12 @@
  for (const type of Object.keys(virtualTypes)) {
    const { types } = virtualTypes[type];
    if (type[0] === "_") continue;
    if (definitions.NODE_FIELDS[type] || definitions.FLIPPED_ALIAS_KEYS[type]) {
    if (t.NODE_FIELDS[type] || t.FLIPPED_ALIAS_KEYS[type]) {
      output += `is${type}(opts?: object): this is NodePath<t.${type}>;`;
    } else if (types /* in VirtualTypeAliases */) {
      output += `is${type}(opts?: object): this is NodePath<VirtualTypeAliases["${type}"]>;`;
    } else if (type === "Pure") {
      output += `isPure(constantsOnly?: boolean): boolean;`;
    } else {
      // if it don't have types, then VirtualTypeAliases[type] is t.Node
      // which TS marked as always true