"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const attest_1 = require("@ark/attest");
const attest_2 = require("@ark/attest");
const expect_type_1 = require("expect-type");
(0, attest_2.setup)({
    updateSnapshots: !process.env.CI,
});
function test(name, fn) {
    fn(name + ": ");
}
test("unmasks deeply nested fragments", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([5, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        (0, expect_type_1.expectTypeOf)().toEqualTypeOf();
    });
});
test("unmasks deeply nested fragments", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([5, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        (0, expect_type_1.expectTypeOf)().toEqualTypeOf();
    });
});
test("unmasks deeply nested nullable fragments", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([5, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        (0, expect_type_1.expectTypeOf)().toEqualTypeOf();
    });
});
test("unmasks DeepPartial types", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([5, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        (0, expect_type_1.expectTypeOf)().toEqualTypeOf();
    });
});
test("Unmasked handles odd types", (prefix) => {
    (0, attest_1.bench)(prefix + "empty type instantiations", () => {
        (0, attest_1.attest)();
    }).types([111, "instantiations"]);
    (0, attest_1.bench)(prefix + "empty type functionality", () => {
        (0, expect_type_1.expectTypeOf)().toEqualTypeOf();
    });
    (0, attest_1.bench)(prefix + "generic record type instantiations", () => {
        (0, attest_1.attest)();
    }).types([115, "instantiations"]);
    (0, attest_1.bench)(prefix + "generic record type functionality", () => {
        (0, expect_type_1.expectTypeOf)().toEqualTypeOf();
    });
    (0, attest_1.bench)(prefix + "unknown instantiations", () => {
        (0, attest_1.attest)();
    }).types([47, "instantiations"]);
    (0, attest_1.bench)(prefix + "unknown functionality", () => {
        (0, expect_type_1.expectTypeOf)().toBeUnknown();
    });
    (0, attest_1.bench)(prefix + "any instantiations", () => {
        (0, attest_1.attest)();
    }).types([48, "instantiations"]);
    (0, attest_1.bench)(prefix + "any functionality", () => {
        (0, expect_type_1.expectTypeOf)().toBeAny();
    });
});
test("MaybeMasked handles odd types", (prefix) => {
    (0, attest_1.bench)(prefix + "empty type instantiations", () => {
        (0, attest_1.attest)();
    }).types([41, "instantiations"]);
    (0, attest_1.bench)(prefix + "empty type functionality", () => {
        (0, expect_type_1.expectTypeOf)().toEqualTypeOf();
    });
    (0, attest_1.bench)(prefix + "generic record type instantiations", () => {
        (0, attest_1.attest)();
    }).types([46, "instantiations"]);
    (0, attest_1.bench)(prefix + "generic record type functionality", () => {
        (0, expect_type_1.expectTypeOf)().toEqualTypeOf();
    });
    (0, attest_1.bench)(prefix + "unknown instantiations", () => {
        (0, attest_1.attest)();
    }).types([41, "instantiations"]);
    (0, attest_1.bench)(prefix + "unknown functionality", () => {
        (0, expect_type_1.expectTypeOf)().toBeUnknown();
    });
    (0, attest_1.bench)(prefix + "any instantiations", () => {
        (0, attest_1.attest)();
    }).types([43, "instantiations"]);
    (0, attest_1.bench)(prefix + "any functionality", () => {
        (0, expect_type_1.expectTypeOf)().toBeAny();
    });
});
test("distributed members on MaybeMasked", (prefix) => {
    (function unresolvedGeneric() {
        (0, attest_1.bench)(prefix + "one unresolved generic mixed with null|undefined", () => {
            (0, attest_1.attest)();
        }).types([49, "instantiations"]);
    })();
    (function unresolvedGenerics() {
        (0, attest_1.bench)(prefix + "two unresolved generics distribute", () => {
            (0, attest_1.attest)();
        }).types([50, "instantiations"]);
    })();
});
test("deals with overlapping array from parent fragment", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([5, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        const x = {};
        // some fields for hovering
        x.id;
        x.artists;
        x.artists?.[0]?.id;
        x.artists?.[0]?.birthdate;
        x.artists?.[0]?.lastname;
        (0, expect_type_1.expectTypeOf)(x).branded.toEqualTypeOf();
    });
});
test("base type, multiple fragments on sub-types", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([5, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        const x = {};
        (0, expect_type_1.expectTypeOf)(x).branded.toEqualTypeOf();
    });
});
test("does not detect `$fragmentRefs` if type contains `any`", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([1, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        const x = {};
        (0, expect_type_1.expectTypeOf)(x).branded.toEqualTypeOf();
    });
});
test("leaves tuples alone", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([5, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        const x = {};
        (0, expect_type_1.expectTypeOf)(x).branded.toEqualTypeOf();
    });
});
test("does not detect `$fragmentRefs` if type is a record type", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([1, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        const x = {};
        (0, expect_type_1.expectTypeOf)(x).branded.toEqualTypeOf();
    });
});
test("does not detect `$fragmentRefs` on types with index signatures", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([1, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        const x = {};
        (0, expect_type_1.expectTypeOf)(x).branded.toEqualTypeOf();
    });
});
test("detects `$fragmentRefs` on types with index signatures", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([1, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        const x = {};
        const y = {};
        (0, expect_type_1.expectTypeOf)(x).branded.toEqualTypeOf();
        (0, expect_type_1.expectTypeOf)(y).toEqualTypeOf();
    });
});
test("recursive types: no error 'Type instantiation is excessively deep and possibly infinite.'", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([1, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        const x = {};
        (0, expect_type_1.expectTypeOf)(x).branded.toEqualTypeOf();
    });
});
test("MaybeMasked can be called with a generic if `mode` is not set to `unmask`", (prefix) => {
    function withGenericResult(arg) {
        (0, attest_1.bench)(prefix + "Result generic - instantiations", () => {
            const maybeMasked = arg;
            return maybeMasked;
        }).types([1, "instantiations"]);
        (0, attest_1.bench)(prefix + "Result generic - functionality", () => {
            const maybeMasked = arg;
            (0, expect_type_1.expectTypeOf)(maybeMasked).toEqualTypeOf(arg);
        });
    }
    function withGenericDocument(arg) {
        (0, attest_1.bench)(prefix + "Result generic - instantiations", () => {
            const maybeMasked = arg;
            return maybeMasked;
        }).types([1, "instantiations"]);
        (0, attest_1.bench)(prefix + "Result generic - functionality", () => {
            const maybeMasked = arg;
            // cannot use unresolved generic with `expectTypeOf` here so we just try an assignment the other way round
            const test = maybeMasked;
            return test;
        });
    }
    withGenericResult({});
    withGenericDocument({});
});
test("Unmasked handles branded primitive types", (prefix) => {
    (0, attest_1.bench)(prefix + "instantiations", () => {
        return {};
    }).types([5, "instantiations"]);
    (0, attest_1.bench)(prefix + "functionality", () => {
        const x = {};
        (0, expect_type_1.expectTypeOf)(x).branded.toEqualTypeOf();
    });
});
//# sourceMappingURL=types.bench.cjs.map
