Repository: babel/babel
File: packages/babel-preset-env/src/normalize-options.ts (TypeScript)

Code before:
    }
  } else if (typeof corejs === "object" && corejs !== null) {
    rawVersion = corejs.version;
    proposals = Boolean(corejs.proposals);
  } else {
    rawVersion = corejs as false | string | number | undefined | null;
  }

  const version = rawVersion ? semver.coerce(String(rawVersion)) : false;

  if (version) {
    if (useBuiltIns) {
      if (process.env.BABEL_8_BREAKING) {
        if (version.major !== 3) {
          throw new RangeError(
            "Invalid Option: The version passed to `corejs` is invalid. Currently, " +
              "only core-js@3 is supported.",
          );
        }

        if (
          typeof rawVersion === "number" ||
          !String(rawVersion).includes(".")
        ) {
          throw new Error(
            "Invalid Option: The version passed to `corejs` is invalid. It must be a string with minor version, like `3.10` or `3.10.1`.",
          );
        }
      } else {
        if (version.major < 2 || version.major > 3) {
          throw new RangeError(
            "Invalid Option: The version passed to `corejs` is invalid. Currently, " +
              "only core-js@2 and core-js@3 are supported.",
          );
        }
      }
    } else {
      console.warn(
        "\nWARNING (@babel/preset-env): The `corejs` option only has an effect when the `useBuiltIns` option is not `false`\n",
      );
    }
  }

  return { version, proposals };
}

export default function normalizeOptions(opts: Options) {
  v.validateTopLevelOptions(opts, TopLevelOptions);

  const useBuiltIns = validateUseBuiltInsOption(opts.useBuiltIns);


Review comment (suggestion):
```suggestion
            "Invalid Option: The version passed to `corejs` is invalid. Please use string and specify the minor version, such as `\"3.30\"`."
```

Since we do not differentiate the patch versions, it suffices to put minor version here.

Code after:
    }
  } else if (typeof corejs === "object" && corejs !== null) {
    rawVersion = corejs.version;
    proposals = Boolean(corejs.proposals);
  } else {
    rawVersion = corejs as false | string | number | undefined | null;
  }

  const version = rawVersion ? semver.coerce(String(rawVersion)) : false;

  if (version) {
    if (useBuiltIns) {
      if (process.env.BABEL_8_BREAKING) {
        if (version.major !== 3) {
          throw new RangeError(
            "Invalid Option: The version passed to `corejs` is invalid. Currently, " +
              "only core-js@3 is supported.",
          );
        }

        if (
          typeof rawVersion !== "string" ||
          !String(rawVersion).includes(".")
        ) {
          throw new Error(
            'Invalid Option: The version passed to `corejs` is invalid. Please use string and specify the minor version, such as `"3.33"`.',
          );
        }
      } else {
        if (version.major < 2 || version.major > 3) {
          throw new RangeError(
            "Invalid Option: The version passed to `corejs` is invalid. Currently, " +
              "only core-js@2 and core-js@3 are supported.",
          );
        }
      }
    } else {
      console.warn(
        "\nWARNING (@babel/preset-env): The `corejs` option only has an effect when the `useBuiltIns` option is not `false`\n",
      );
    }
  }

  return { version, proposals };
}

export default function normalizeOptions(opts: Options) {
  v.validateTopLevelOptions(opts, TopLevelOptions);

  const useBuiltIns = validateUseBuiltInsOption(opts.useBuiltIns);