src/language-js/parser-babel.js/rethrowSomeRecoveredErrors
function rethrowSomeRecoveredErrors(ast) {
  if (ast.errors) {
    for (const error of ast.errors) {
      if (
        typeof error.message === "string" &&
        (error.message.startsWith(
          // UnexpectedTypeAnnotation
          // https://github.com/babel/babel/blob/2f31ecf85d85cb100fa08d4d9a09de0fe4a117e4/packages/babel-parser/src/plugins/typescript/index.js#L88
          "Did not expect a type annotation here."
        ) ||
          error.message.startsWith(
            // ModuleAttributeDifferentFromType
            // https://github.com/babel/babel/blob/bda759ac3dce548f021ca24e9182b6e6f7c218e3/packages/babel-parser/src/parser/location.js#L99
            "The only accepted module attribute is `type`"
          ))
      ) {
        throw error;
      }
    }
  }
  return ast;
}