checkKey = (val, check) => {
  if (isAtom(val)) {
    return true;
  }
  // @ts-expect-error narrowed
  if (keyMemo.has(val)) {
    return true;
  }
  // eslint-disable-next-line no-use-before-define
  const result = checkKeyInternal(val, check);
  if (result) {
    // Don't cache the undefined cases, so that if it is tried again
    // with `assertChecker` it'll throw a diagnostic again
    // @ts-expect-error narrowed
    keyMemo.add(val);
  }
  // Note that we do not memoize a negative judgement, so that if it is tried
  // again with a checker, it will still produce a useful diagnostic.
  return result;
}
@param {unknown} val
@param {Checker} check
@returns {boolean}