import StratumFromTraits from "../../lib/Models/Definition/StratumFromTraits"; import TraitsForTesting from "./TraitsForTesting"; import { expectFalse, expectTrue } from "./TypeChecks"; import { Equals, IsWritable, AllowsUndefined, IsWritableArray } from "../../lib/Core/TypeConditionals"; import { JsonObject } from "../../lib/Core/Json"; type Stratum = StratumFromTraits; const stratum: Stratum = {} as any; // Simple properties allow undefined, whether they have a default or not. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue< Equals >(); expectTrue>(); // All properties can be modified. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue>(); expectTrue>(); // Properties that are nested traits allow undefined. expectTrue>(); expectTrue>(); const nested = stratum.nestedWithDefault; if (nested) { // All nested properties allow undefined. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue< Equals >(); expectTrue>(); // All nested properties can be modified. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue>(); expectTrue>(); } // Properties that are arrays of traits allow undefined. expectTrue>(); expectTrue>(); // Array traits are writable. expectTrue< IsWritableArray> >(); expectTrue< IsWritableArray> >(); const array = stratum.nestedArrayWithDefault; if (array) { const _first = array[0]; // Arrays may not _contain_ undefineds. expectFalse>(); // Properties in traits in arrays allow undefined. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue< Equals >(); expectTrue>(); // Properties in traits in arrays can be modified. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue>(); expectTrue>(); }