mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-09 11:12:52 +00:00
50
package-lock.json
generated
50
package-lock.json
generated
@@ -692,6 +692,12 @@
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
},
|
||||
"conditional-type-checks": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/conditional-type-checks/-/conditional-type-checks-1.0.1.tgz",
|
||||
"integrity": "sha512-+O/IE/QGjXzdk4ttJFLRQm8pofQE0KZZmgcamquUGhHfaZt0UTZMlklqW0J9tWO8HQvC70cPahEAVMwSfeqtuQ==",
|
||||
"dev": true
|
||||
},
|
||||
"conventional-changelog": {
|
||||
"version": "3.1.8",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.8.tgz",
|
||||
@@ -836,9 +842,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"conventional-changelog-writer": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-4.0.5.tgz",
|
||||
"integrity": "sha512-g/Myp4MaJ1A+f7Ai+SnVhkcWtaHk6flw0SYN7A+vQ+MTu0+gSovQWs4Pg4NtcNUcIztYQ9YHsoxHP+GGQplI7Q==",
|
||||
"version": "4.0.6",
|
||||
"resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-4.0.6.tgz",
|
||||
"integrity": "sha512-ou/sbrplJMM6KQpR5rKFYNVQYesFjN7WpNGdudQSWNi6X+RgyFUcSv871YBYkrUYV9EX8ijMohYVzn9RUb+4ag==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"compare-func": "^1.3.1",
|
||||
@@ -848,17 +854,9 @@
|
||||
"json-stringify-safe": "^5.0.1",
|
||||
"lodash": "^4.2.1",
|
||||
"meow": "^4.0.0",
|
||||
"semver": "^5.5.0",
|
||||
"semver": "^6.0.0",
|
||||
"split": "^1.0.0",
|
||||
"through2": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"semver": {
|
||||
"version": "5.7.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz",
|
||||
"integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"conventional-commits-filter": {
|
||||
@@ -872,13 +870,13 @@
|
||||
}
|
||||
},
|
||||
"conventional-commits-parser": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-3.0.2.tgz",
|
||||
"integrity": "sha512-y5eqgaKR0F6xsBNVSQ/5cI5qIF3MojddSUi1vKIggRkqUTbkqFKH9P5YX/AT1BVZp9DtSzBTIkvjyVLotLsVog==",
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-3.0.3.tgz",
|
||||
"integrity": "sha512-KaA/2EeUkO4bKjinNfGUyqPTX/6w9JGshuQRik4r/wJz7rUw3+D3fDG6sZSEqJvKILzKXFQuFkpPLclcsAuZcg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"JSONStream": "^1.0.4",
|
||||
"is-text-path": "^1.0.0",
|
||||
"is-text-path": "^2.0.0",
|
||||
"lodash": "^4.2.1",
|
||||
"meow": "^4.0.0",
|
||||
"split2": "^2.0.0",
|
||||
@@ -1884,12 +1882,12 @@
|
||||
}
|
||||
},
|
||||
"is-text-path": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz",
|
||||
"integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-2.0.0.tgz",
|
||||
"integrity": "sha512-+oDTluR6WEjdXEJMnC2z6A4FRwFoYuvShVVEGsS7ewc0UTi2QtAKMDJuL4BDEVt+5T7MjFo12RP8ghOM75oKJw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"text-extensions": "^1.0.0"
|
||||
"text-extensions": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"is-utf8": {
|
||||
@@ -3490,9 +3488,9 @@
|
||||
}
|
||||
},
|
||||
"text-extensions": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz",
|
||||
"integrity": "sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ==",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-2.0.0.tgz",
|
||||
"integrity": "sha512-F91ZqLgvi1E0PdvmxMgp+gcf6q8fMH7mhdwWfzXnl1k+GbpQDmi8l7DzLC5JTASKbwpY3TfxajAUzAXcv2NmsQ==",
|
||||
"dev": true
|
||||
},
|
||||
"through": {
|
||||
@@ -3702,9 +3700,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"uglify-js": {
|
||||
"version": "3.5.12",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.12.tgz",
|
||||
"integrity": "sha512-KeQesOpPiZNgVwJj8Ge3P4JYbQHUdZzpx6Fahy6eKAYRSV4zhVmLXoC+JtOeYxcHCHTve8RG1ZGdTvpeOUM26Q==",
|
||||
"version": "3.5.14",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.14.tgz",
|
||||
"integrity": "sha512-dgyjIw8KFK6AyVl5vm2tEqPewv5TKGEiiVFLI1LbF+oHua/Njd8tZk3lIbF1AWU1rNdEg7scaceADb4zqCcWXg==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
"@types/rimraf": "2.0.2",
|
||||
"chai": "4.2.0",
|
||||
"commander": "2.20.0",
|
||||
"conditional-type-checks": "1.0.1",
|
||||
"conventional-changelog-cli": "2.0.21",
|
||||
"mocha": "6.1.4",
|
||||
"mocha-typescript": "1.1.17",
|
||||
|
||||
344
test/Type.spec.ts
Normal file
344
test/Type.spec.ts
Normal file
@@ -0,0 +1,344 @@
|
||||
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, T> = E extends T ? true : false;
|
||||
|
||||
/**
|
||||
* Get type of array elements up to nesting level 3
|
||||
*/
|
||||
type ElementType<T> = 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<T> = Extract<ElementType<T extends object ?
|
||||
(IsAny<T[keyof T]> extends true ?
|
||||
never : T[keyof T]) : never>
|
||||
, object>;
|
||||
|
||||
/**
|
||||
* Get nested property types
|
||||
*/
|
||||
type PropertyTypesNested<T> = PropertyTypes<T> extends object ? PropertyTypes<PropertyTypes<T>> : PropertyTypes<T>;
|
||||
|
||||
/**
|
||||
* Types of properties of SCDiff
|
||||
*/
|
||||
type SCDiffPropertyTypes = PropertyTypesNested<SCDiff>;
|
||||
assert<NotHas<SCDiffPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCDiffPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCDiffPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCDiffPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCDiffWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCDiff, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCAcademicEvent
|
||||
*/
|
||||
type SCAcademicEventPropertyTypes = PropertyTypesNested<SCAcademicEvent>;
|
||||
assert<NotHas<SCAcademicEventPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCAcademicEventPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCAcademicEventPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCAcademicEventPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCAcademicEventWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCAcademicEvent, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCArticle
|
||||
*/
|
||||
type SCArticlePropertyTypes = PropertyTypesNested<SCArticle>;
|
||||
assert<NotHas<SCArticlePropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCArticlePropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCArticlePropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCArticlePropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCArticleWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCArticle, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCBook
|
||||
*/
|
||||
type SCBookPropertyTypes = PropertyTypesNested<SCBook>;
|
||||
assert<NotHas<SCBookPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCBookPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCBookPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCBookPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCBookWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCBook, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCBuilding
|
||||
*/
|
||||
type SCBuildingPropertyTypes = PropertyTypesNested<SCBuilding>;
|
||||
assert<NotHas<SCBuildingPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCBuildingPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCBuildingPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCBuildingPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCBuildingWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCBuilding, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCCatalog
|
||||
*/
|
||||
type SCCatalogPropertyTypes = PropertyTypesNested<SCCatalog>;
|
||||
assert<NotHas<SCCatalogPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCCatalogPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCCatalogPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCCatalogPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCCatalogWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCCatalog, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCCourseOfStudies
|
||||
*/
|
||||
type SCCourseOfStudiesPropertyTypes = PropertyTypesNested<SCCourseOfStudies>;
|
||||
assert<NotHas<SCCourseOfStudiesPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCCourseOfStudiesPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCCourseOfStudiesPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCCourseOfStudiesPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCCourseOfStudiesWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCCourseOfStudies, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCDateSeries
|
||||
*/
|
||||
type SCDateSeriesPropertyTypes = PropertyTypesNested<SCDateSeries>;
|
||||
assert<NotHas<SCDateSeriesPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCDateSeriesPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCDateSeriesPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCDateSeriesPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCDateSeriesWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCDateSeries, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCDish
|
||||
*/
|
||||
type SCDishPropertyTypes = PropertyTypesNested<SCDish>;
|
||||
assert<NotHas<SCDishPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCDishPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCDishPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCDishPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCDishWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCDish, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCFavorite
|
||||
*/
|
||||
type SCFavoritePropertyTypes = PropertyTypesNested<SCFavorite>;
|
||||
assert<NotHas<SCFavoritePropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCFavoritePropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCFavoritePropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCFavoritePropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCFavoriteWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCFavorite, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCFloor
|
||||
*/
|
||||
type SCFloorPropertyTypes = PropertyTypesNested<SCFloor>;
|
||||
assert<NotHas<SCFloorPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCFloorPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCFloorPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCFloorPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCFloorWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCFloor, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCMessage
|
||||
*/
|
||||
type SCMessagePropertyTypes = PropertyTypesNested<SCMessage>;
|
||||
assert<NotHas<SCMessagePropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCMessagePropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCMessagePropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCMessagePropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCMessageWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCMessage, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCOrganization
|
||||
*/
|
||||
type SCOrganizationPropertyTypes = PropertyTypesNested<SCOrganization>;
|
||||
assert<NotHas<SCOrganizationPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCOrganizationPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCOrganizationPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCOrganizationPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCOrganizationWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCOrganization, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCPerson
|
||||
*/
|
||||
type SCPersonPropertyTypes = PropertyTypesNested<SCPerson>;
|
||||
assert<NotHas<SCPersonPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCPersonPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCPersonPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCPersonPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCPersonWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCPerson, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCPointOfInterest
|
||||
*/
|
||||
type SCPointOfInterestPropertyTypes = PropertyTypesNested<SCPointOfInterest>;
|
||||
assert<NotHas<SCPointOfInterestPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCPointOfInterestPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCPointOfInterestPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCPointOfInterestPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCPointOfInterestWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCPointOfInterest, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCRoom
|
||||
*/
|
||||
type SCRoomPropertyTypes = PropertyTypesNested<SCRoom>;
|
||||
assert<NotHas<SCRoomPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCRoomPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCRoomPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCRoomPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCRoomWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCRoom, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCSemester
|
||||
*/
|
||||
type SCSemesterPropertyTypes = PropertyTypesNested<SCSemester>;
|
||||
assert<NotHas<SCSemesterPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCSemesterPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCSemesterPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCSemesterPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCSemesterWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCSemester, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCSetting
|
||||
*/
|
||||
type SCSettingPropertyTypes = PropertyTypesNested<SCSetting>;
|
||||
assert<NotHas<SCSettingPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCSettingPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCSettingPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCSettingPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCSettingWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCSetting, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCSportCourse
|
||||
*/
|
||||
type SCSportCoursePropertyTypes = PropertyTypesNested<SCSportCourse>;
|
||||
assert<NotHas<SCSportCoursePropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCSportCoursePropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCSportCoursePropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCSportCoursePropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCSportCourseWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCSportCourse, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCStudyModule
|
||||
*/
|
||||
type SCStudyModulePropertyTypes = PropertyTypesNested<SCStudyModule>;
|
||||
assert<NotHas<SCStudyModulePropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCStudyModulePropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCStudyModulePropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCStudyModulePropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCStudyModuleWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCStudyModule, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCTicket
|
||||
*/
|
||||
type SCTicketPropertyTypes = PropertyTypesNested<SCTicket>;
|
||||
assert<NotHas<SCTicketPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCTicketPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCTicketPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCTicketPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCTicketWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCTicket, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCToDo
|
||||
*/
|
||||
type SCToDoPropertyTypes = PropertyTypesNested<SCToDo>;
|
||||
assert<NotHas<SCToDoPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCToDoPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCToDoPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCToDoPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCToDoWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCToDo, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCToDo
|
||||
*/
|
||||
type SCTourPropertyTypes = PropertyTypesNested<SCTour>;
|
||||
assert<NotHas<SCTourPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCTourPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCTourPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCTourPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCTourWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCTour, SCThing>>(true);
|
||||
|
||||
/**
|
||||
* Types of properties of SCVideo
|
||||
*/
|
||||
type SCVideoPropertyTypes = PropertyTypesNested<SCVideo>;
|
||||
assert<NotHas<SCVideoPropertyTypes, SCThingWithoutReferences>>(false);
|
||||
assert<Has<SCVideoPropertyTypes, SCThingWithoutReferences>>(true);
|
||||
assert<NotHas<SCVideoPropertyTypes, SCThing>>(true);
|
||||
assert<Has<SCVideoPropertyTypes, SCThing>>(false);
|
||||
assert<Extends<SCVideoWithoutReferences, SCThing>>(false);
|
||||
assert<Extends<SCVideo, SCThing>>(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<Foo>;
|
||||
assert<IsNever<UnfortunatelyNever>>(true);
|
||||
|
||||
/**
|
||||
* Flat property types
|
||||
*/
|
||||
type FlatPropertyTypes<T> = T[keyof T];
|
||||
|
||||
/**
|
||||
* Type that is unfortunately any - blame TypeScript
|
||||
*/
|
||||
type UnfortunatelyAny = FlatPropertyTypes<Foo>;
|
||||
assert<IsAny<UnfortunatelyAny>>(true);
|
||||
Reference in New Issue
Block a user