asserts.js 485 B

12345678910111213141516171819202122232425
  1. import t from "@babel/types";
  2. export default function generateAsserts() {
  3. let output = `/*
  4. * This file is auto-generated! Do not modify it directly.
  5. * To re-generate run 'make build'
  6. */
  7. import * as t from "@babel/types";
  8. import NodePath from "../index";
  9. export interface NodePathAssetions {`;
  10. for (const type of [...t.TYPES].sort()) {
  11. output += `
  12. assert${type}(
  13. opts?: object,
  14. ): asserts this is NodePath<t.${type}>;`;
  15. }
  16. output += `
  17. }`;
  18. return output;
  19. }