import {assert, Has, IsAny, IsNever, NotHas} from 'conditional-type-checks'; import {SCThing, SCThingWithoutReferences} from '../src/core/Thing'; import {SCAcademicEvent, SCAcademicEventWithoutReferences} from '../src/core/things/AcademicEvent'; import {SCArticle, SCArticleWithoutReferences} from '../src/core/things/Article'; import {SCBook, SCBookWithoutReferences} from '../src/core/things/Book'; import {SCBuilding, SCBuildingWithoutReferences} from '../src/core/things/Building'; import {SCCatalog, SCCatalogWithoutReferences} from '../src/core/things/Catalog'; import {SCCourseOfStudies, SCCourseOfStudiesWithoutReferences} from '../src/core/things/CourseOfStudies'; import {SCDateSeries, SCDateSeriesWithoutReferences} from '../src/core/things/DateSeries'; import {SCDiff, SCDiffWithoutReferences} from '../src/core/things/Diff'; import {SCDish, SCDishWithoutReferences} from '../src/core/things/Dish'; import {SCFavorite, SCFavoriteWithoutReferences} from '../src/core/things/Favorite'; import {SCFloor, SCFloorWithoutReferences} from '../src/core/things/Floor'; import {SCMessage, SCMessageWithoutReferences} from '../src/core/things/Message'; import {SCOrganization, SCOrganizationWithoutReferences} from '../src/core/things/Organization'; import {SCPerson, SCPersonWithoutReferences} from '../src/core/things/Person'; import {SCPointOfInterest, SCPointOfInterestWithoutReferences} from '../src/core/things/PointOfInterest'; import {SCRoom, SCRoomWithoutReferences} from '../src/core/things/Room'; import {SCSemester, SCSemesterWithoutReferences} from '../src/core/things/Semester'; import {SCSetting, SCSettingWithoutReferences} from '../src/core/things/Setting'; import {SCSportCourse, SCSportCourseWithoutReferences} from '../src/core/things/SportCourse'; import {SCStudyModule, SCStudyModuleWithoutReferences} from '../src/core/things/StudyModule'; import {SCTicket, SCTicketWithoutReferences} from '../src/core/things/Ticket'; import {SCToDo, SCToDoWithoutReferences} from '../src/core/things/ToDo'; import {SCTour, SCTourWithoutReferences} from '../src/core/things/Tour'; import {SCVideo, SCVideoWithoutReferences} from '../src/core/things/Video'; /** * Check if E extends T */ type Extends = E extends T ? true : false; /** * Get type of array elements up to nesting level 3 */ type ElementType = T extends any[] ? (T[0] extends any[] ? (T[0][0] extends any[] ? T[0][0][0] : T[0][0]) : T[0]) : T; /** * Get types of properties * * - Extracts only the properties which extend object and are not any. * - If type is an array it returns the type of the elements. */ type PropertyTypes = Extract extends true ? never : T[keyof T]) : never> , object>; /** * Get nested property types */ type PropertyTypesNested = PropertyTypes extends object ? PropertyTypes> : PropertyTypes; /** * Types of properties of SCDiff */ type SCDiffPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCAcademicEvent */ type SCAcademicEventPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCArticle */ type SCArticlePropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCBook */ type SCBookPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCBuilding */ type SCBuildingPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCCatalog */ type SCCatalogPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCCourseOfStudies */ type SCCourseOfStudiesPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCDateSeries */ type SCDateSeriesPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCDish */ type SCDishPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCFavorite */ type SCFavoritePropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCFloor */ type SCFloorPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCMessage */ type SCMessagePropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCOrganization */ type SCOrganizationPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCPerson */ type SCPersonPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCPointOfInterest */ type SCPointOfInterestPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCRoom */ type SCRoomPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCSemester */ type SCSemesterPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCSetting */ type SCSettingPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCSportCourse */ type SCSportCoursePropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCStudyModule */ type SCStudyModulePropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCTicket */ type SCTicketPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCToDo */ type SCToDoPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCToDo */ type SCTourPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Types of properties of SCVideo */ type SCVideoPropertyTypes = PropertyTypesNested; assert>(false); assert>(true); assert>(true); assert>(false); assert>(false); assert>(true); /** * Dummy interface, to check if union types still resolve to any if one of the members is any */ interface Foo { bar: SCPerson; foo: any; } /** * Type that is unfortunately never - blame TypeScript */ type UnfortunatelyNever = PropertyTypesNested; assert>(true); /** * Flat property types */ type FlatPropertyTypes = T[keyof T]; /** * Type that is unfortunately any - blame TypeScript */ type UnfortunatelyAny = FlatPropertyTypes; assert>(true);