import { If } from "../../Core/TypeConditionals"; import { Complete, NotUndefined } from "../../Core/TypeModifiers"; import ModelTraits, { IsValidSimpleTraitType } from "../../Traits/ModelTraits"; type SingleTrait = If< IsValidSimpleTraitType>, TTrait, TTrait extends ModelTraits ? StratumFromTraits : never >; type ArrayTrait<_TTrait, TElement> = Array>; /** * Transforms a {@link ModelTraits} class into a type usable as a stratum. * All properties of the new type: * * * Can be both GET and SET. * * May be undefined even if the traits class property has a default or is otherwise not allowed to be undefined. * * Nested traits classes follow the rules above. */ type StratumFromTraits = Complete<{ [P in keyof TDefinition]: NotUndefined extends Array< infer TElement > ? ArrayTrait | undefined : SingleTrait | undefined; }>; export default StratumFromTraits;