import { JsonObject } from "../../lib/Core/Json"; import { AllowsUndefined, Equals, IsWritable, IsWritableArray } from "../../lib/Core/TypeConditionals"; import FlattenedFromTraits from "../../lib/Models/Definition/FlattenedFromTraits"; import TraitsForTesting from "./TraitsForTesting"; import { expectFalse, expectTrue } from "./TypeChecks"; type Flattened = FlattenedFromTraits; const flattened: Flattened = {} as any; // Simple properties allow undefined, whether they have a default or not. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue< Equals >(); expectTrue>(); // Properties may not be modified. expectFalse>(); expectFalse>(); // Properties that are nested traits allow undefined. expectTrue>(); expectTrue>(); const nested = flattened.nestedWithDefault; if (nested) { // All nested properties allow undefined. expectTrue>(); expectTrue>(); expectTrue>(); expectTrue< Equals >(); expectTrue>(); // All nested properties can _not_ be modified. expectFalse>(); expectFalse>(); } // Properties that are arrays of traits allow undefined. expectTrue>(); expectTrue>(); // Array traits are _not_ writable. expectFalse< IsWritableArray> >(); expectFalse< IsWritableArray> >(); const array = flattened.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 _not_ be modified. expectFalse>(); expectFalse>(); }