import { RetortPrimitiveSchema, RetortObjectSchema, RetortSchemaToType } from "../src/tooling"; type Assert = T; type AreEqual = T extends Expected ? (Expected extends T ? true : false) : false type StringTest1 = RetortSchemaToType<{ type: StringConstructor }>; type StringTest1Assertion = Assert>; type StringTest2 = RetortSchemaToType; type StringTest2Assertion = Assert>; type NumberTest1 = RetortSchemaToType<{ type: NumberConstructor }>; type NumberTest1Assertion = Assert>; type NumberTest2 = RetortSchemaToType; type NumberTest2Assertion = Assert>; type ObjectTest = RetortSchemaToType<{ type: ObjectConstructor }>; type ObjectTestAssertion = Assert>; type ArrayTest = RetortSchemaToType<{ type: ArrayConstructor }>; type ArrayTestAssertion = Assert>; type BooleanTest = RetortSchemaToType<{ type: BooleanConstructor }>; // Test doesn't work for some reason // type BooleanTestAssertion = Assert>; type AddressTest = RetortSchemaToType<{ street: { type: StringConstructor } }>; type AddressTestAssertion = Assert>; type StringArraytest = RetortSchemaToType<{ type: [StringConstructor] }>; type StringArraytestAssertion = Assert>; type ComplexTest = RetortSchemaToType<{ name: { type: StringConstructor }, age: { type: NumberConstructor }, address: { street: { type: StringConstructor } }, children: { type: [{ name: { type: StringConstructor } }] } }>; type ComplexTestAssertion = Assert>; // Enum property test type EnumTest = RetortSchemaToType<{ status: { type: StringConstructor, enum: ['open', 'closed', 'pending'] } }>; type EnumTestAssertion = Assert>; // Nullable property test type NullableTest = RetortSchemaToType<{ age: { type: NumberConstructor, nullable: true } }>; type NullableTestAssertion = Assert>; // Optional property test type OptionalTest = RetortSchemaToType<{ email: { type: StringConstructor, optional: true } }>; type OptionalTestAssertion = Assert>; // Combined nullable and optional property test type CombinedNullableOptionalTest = RetortSchemaToType<{ phone: { type: StringConstructor, nullable: true, optional: true } }>; type CombinedNullableOptionalTestAssertion = Assert>; // Tests for the special case where "type" is an object an object with a "type" property. // This is because mongoose-style schemas treate the type field in a special way type NestedTypeTest = RetortSchemaToType<{ type: { type: StringConstructor } }>; type NestedTypeTestAssertion = Assert>; type NestedTypeTest2 = RetortSchemaToType<{ type: { type: {type: StringConstructor} } }>; // Known limitation of type mapping. // @ts-ignore type NestedTypeTest2Assertion = Assert>;