Repository: babel/babel
File: packages/babel-types/src/definitions/core.ts (TypeScript)

Code before:
      optional: true,
    },
    kind: {
      validate: assertOneOf(
        "var",
        "let",
        "const",
        // https://github.com/tc39/proposal-explicit-resource-management
        "using",
        // https://github.com/tc39/proposal-async-explicit-resource-management
        "await using",
      ),
    },
    declarations: validateArrayOfType("VariableDeclarator"),
  },
  validate:
    process.env.BABEL_8_BREAKING || process.env.BABEL_TYPES_8_BREAKING
      ? (() => {
          const withoutInit = assertNodeType("Identifier", "Placeholder");
          const constOrLetOrVar = assertNodeType(
            "Identifier",
            "ArrayPattern",
            "ObjectPattern",
            "Placeholder",
          );
          const usingOrAwaitUsing = assertNodeType("Identifier", "Placeholder");

          return function (parent, key, node: t.VariableDeclaration) {
            const { kind, declarations } = node;
            const parentIsForX = is("ForXStatement", parent, { left: node });
            if (parentIsForX) {
              if (declarations.length !== 1) {
                throw new TypeError(
                  `Exactly one VariableDeclarator is required in the VariableDeclaration of a ${parent.type}`,
                );
              }
            }
            for (const decl of declarations) {
              if (kind === "const" || kind === "let" || kind === "var") {
                if (!parentIsForX && !decl.init) {
                  withoutInit(decl, "id", decl.id);
                } else {
                  constOrLetOrVar(decl, "id", decl.id);
                }
              } else {
                usingOrAwaitUsing(decl, "id", decl.id);
              }
            }
          };
        })()
      : undefined,

Review comment (suggestion):
```suggestion
          const usingOrAwaitUsing = withoutInit;
```

They are the same, we can avoid creating two separate functions.

Code after:
      optional: true,
    },
    kind: {
      validate: assertOneOf(
        "var",
        "let",
        "const",
        // https://github.com/tc39/proposal-explicit-resource-management
        "using",
        // https://github.com/tc39/proposal-async-explicit-resource-management
        "await using",
      ),
    },
    declarations: validateArrayOfType("VariableDeclarator"),
  },
  validate:
    process.env.BABEL_8_BREAKING || process.env.BABEL_TYPES_8_BREAKING
      ? (() => {
          const withoutInit = assertNodeType("Identifier", "Placeholder");
          const constOrLetOrVar = assertNodeType(
            "Identifier",
            "ArrayPattern",
            "ObjectPattern",
            "Placeholder",
          );
          const usingOrAwaitUsing = withoutInit;

          return function (parent, key, node: t.VariableDeclaration) {
            const { kind, declarations } = node;
            const parentIsForX = is("ForXStatement", parent, { left: node });
            if (parentIsForX) {
              if (declarations.length !== 1) {
                throw new TypeError(
                  `Exactly one VariableDeclarator is required in the VariableDeclaration of a ${parent.type}`,
                );
              }
            }
            for (const decl of declarations) {
              if (kind === "const" || kind === "let" || kind === "var") {
                if (!parentIsForX && !decl.init) {
                  withoutInit(decl, "id", decl.id);
                } else {
                  constOrLetOrVar(decl, "id", decl.id);
                }
              } else {
                usingOrAwaitUsing(decl, "id", decl.id);
              }
            }
          };
        })()
      : undefined,