diff --git a/src/masking/__benches__/types.bench.ts b/src/masking/__benches__/types.bench.ts index 621fb29dfaf..562ece9838e 100644 --- a/src/masking/__benches__/types.bench.ts +++ b/src/masking/__benches__/types.bench.ts @@ -299,7 +299,7 @@ test("MaybeMasked handles odd types", (prefix) => { bench(prefix + "unknown instantiations", () => { attest>(); - }).types([52, "instantiations"]); + }).types([54, "instantiations"]); bench(prefix + "unknown functionality", () => { expectTypeOf>().toBeUnknown(); }); @@ -464,3 +464,19 @@ test("base type, multiple fragments on sub-types", (prefix) => { }>(); }); }); + +test("does not detect `$fragmentRefs` if type contains `any`", (prefix) => { + interface Source { + foo: { bar: any[] }; + } + + bench(prefix + "instantiations", () => { + return {} as MaybeMasked; + }).types([6, "instantiations"]); + + bench(prefix + "functionality", () => { + const x = {} as MaybeMasked; + + expectTypeOf(x).branded.toEqualTypeOf(); + }); +}); diff --git a/src/masking/internal/types.ts b/src/masking/internal/types.ts index ead6b64abdf..1c6150555ae 100644 --- a/src/masking/internal/types.ts +++ b/src/masking/internal/types.ts @@ -184,7 +184,8 @@ export type RemoveFragmentName = T extends any ? Omit : T; export type ContainsFragmentsRefs = - TData extends object ? + true extends IsAny ? false + : TData extends object ? " $fragmentRefs" extends keyof TData ? true : ContainsFragmentsRefs