circularReferenceInReturnType2.ts(39,7): error TS7022: 'A' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
circularReferenceInReturnType2.ts(41,3): error TS7023: 'fields' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.


==== circularReferenceInReturnType2.ts (2 errors) ====
    type ObjectType<Source> = {
      kind: "object";
      __source: (source: Source) => void;
    };
    
    type Field<Source, Key extends string> = {
      __key: (key: Key) => void;
      __source: (source: Source) => void;
    };
    
    declare const object: <Source>() => <
      Fields extends {
        [Key in keyof Fields]: Field<Source, Key & string>;
      }
    >(config: {
      name: string;
      fields: Fields | (() => Fields);
    }) => ObjectType<Source>;
    
    type InferValueFromObjectType<Type extends ObjectType<any>> =
      Type extends ObjectType<infer Source> ? Source : never;
    
    type FieldResolver<Source, TType extends ObjectType<any>> = (
      source: Source
    ) => InferValueFromObjectType<TType>;
    
    type FieldFuncArgs<Source, Type extends ObjectType<any>> = {
      type: Type;
      resolve: FieldResolver<Source, Type>;
    };
    
    declare const field: <Source, Type extends ObjectType<any>, Key extends string>(
      field: FieldFuncArgs<Source, Type>
    ) => Field<Source, Key>;
    
    type Something = { foo: number };
    
    // inference fails here, but ideally should not
    const A = object<Something>()({
          ~
!!! error TS7022: 'A' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
      name: "A",
      fields: () => ({
      ~~~~~~
!!! error TS7023: 'fields' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
        a: field({
          type: A,
          resolve() {
            return {
              foo: 100,
            };
          },
        }),
      }),
    });
    