@fluidframework/core-interfaces 2.41.0 → 2.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/exposedInternalUtilityTypes.d.ts +56 -4
  3. package/dist/exposedInternalUtilityTypes.d.ts.map +1 -1
  4. package/dist/exposedInternalUtilityTypes.js.map +1 -1
  5. package/dist/exposedUtilityTypes.d.ts +1 -0
  6. package/dist/exposedUtilityTypes.d.ts.map +1 -1
  7. package/dist/exposedUtilityTypes.js.map +1 -1
  8. package/dist/internal.d.ts +10 -0
  9. package/dist/internal.d.ts.map +1 -1
  10. package/dist/internal.js.map +1 -1
  11. package/dist/jsonSerializable.d.ts +2 -2
  12. package/dist/jsonSerializable.js.map +1 -1
  13. package/dist/jsonUtils.d.ts +70 -0
  14. package/dist/jsonUtils.d.ts.map +1 -0
  15. package/dist/jsonUtils.js +7 -0
  16. package/dist/jsonUtils.js.map +1 -0
  17. package/dist/opaqueJson.d.ts +60 -0
  18. package/dist/opaqueJson.d.ts.map +1 -0
  19. package/dist/opaqueJson.js +8 -0
  20. package/dist/opaqueJson.js.map +1 -0
  21. package/lib/exposedInternalUtilityTypes.d.ts +56 -4
  22. package/lib/exposedInternalUtilityTypes.d.ts.map +1 -1
  23. package/lib/exposedInternalUtilityTypes.js.map +1 -1
  24. package/lib/exposedUtilityTypes.d.ts +1 -0
  25. package/lib/exposedUtilityTypes.d.ts.map +1 -1
  26. package/lib/exposedUtilityTypes.js.map +1 -1
  27. package/lib/internal.d.ts +10 -0
  28. package/lib/internal.d.ts.map +1 -1
  29. package/lib/internal.js.map +1 -1
  30. package/lib/jsonSerializable.d.ts +2 -2
  31. package/lib/jsonSerializable.js.map +1 -1
  32. package/lib/jsonUtils.d.ts +70 -0
  33. package/lib/jsonUtils.d.ts.map +1 -0
  34. package/lib/jsonUtils.js +6 -0
  35. package/lib/jsonUtils.js.map +1 -0
  36. package/lib/opaqueJson.d.ts +60 -0
  37. package/lib/opaqueJson.d.ts.map +1 -0
  38. package/lib/opaqueJson.js +6 -0
  39. package/lib/opaqueJson.js.map +1 -0
  40. package/package.json +2 -2
  41. package/src/exposedInternalUtilityTypes.ts +186 -80
  42. package/src/exposedUtilityTypes.ts +1 -0
  43. package/src/internal.ts +24 -0
  44. package/src/jsonSerializable.ts +2 -2
  45. package/src/jsonUtils.ts +90 -0
  46. package/src/opaqueJson.ts +87 -0
@@ -1 +1 @@
1
- {"version":3,"file":"exposedInternalUtilityTypes.js","sourceRoot":"","sources":["../src/exposedInternalUtilityTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH;;GAEG;AACH,MAAM,qBAAqB,GAAkB,MAAM,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @rushstack/no-new-null */\n\nimport type { ErasedType } from \"./erasedType.js\";\nimport type { IFluidHandle } from \"./handles.js\";\nimport type {\n\tSerializationErrorPerNonPublicProperties,\n\tSerializationErrorPerUndefinedArrayElement,\n} from \"./jsonSerializationErrors.js\";\nimport type { JsonTypeWith, NonNullJsonObjectWith, ReadonlyJsonTypeWith } from \"./jsonType.js\";\n\n/**\n * Unique symbol for recursion meta-typing.\n */\nconst RecursionMarkerSymbol: unique symbol = Symbol(\"recursion here\");\n\n/**\n * Union of types that {@link DeepReadonly} and {@link ShallowReadonly}\n * recognize to generate immutable form and optionally can alter their\n * type parameters.\n *\n * @privateRemarks\n * WeakRef should be added when lib is updated to ES2021 or later.\n *\n * @beta\n */\nexport type ReadonlySupportedGenerics =\n\t| IFluidHandle\n\t| Map<unknown, unknown>\n\t| Promise<unknown>\n\t| Set<unknown>\n\t| WeakMap<object, unknown>\n\t| WeakSet<object>;\n\n/**\n * Limit on processing recursive types.\n * Use of `\"NoLimit\"` may result in error:\n * \"ts(2589): Type instantiation is excessively deep and possibly infinite\".\n * In such cases, use string literal with some prefix series of `+`\n * characters. The length of `+` character sequence indicates the recursion\n * depth limit when a recursive type is found. Use of `0` will stop applying\n * `DeepReadonly` at the first point recursion is detected.\n *\n * @beta\n * @system\n */\nexport type DeepReadonlyRecursionLimit = \"NoLimit\" | 0 | `+${string}`;\n\n/**\n * Collection of utility types that are not intended to be used/imported\n * directly outside of this package.\n *\n * @privateRemarks\n * There are ony three intentional exports from this module:\n * - {@link InternalUtilityTypes.IfSameType | IfSameType}\n * - {@link InternalUtilityTypes.JsonDeserializedImpl | JsonDeserializedImpl }\n * - {@link InternalUtilityTypes.JsonSerializableImpl | JsonSerializableImpl }\n *\n * api-extractor will allow `export` to be removed from others but generates\n * api-report a little oddly with a rogue `{};` floating at end of namespace\n * in api.md file. It will promote all of the support types to appear as\n * exported anyway. All in namespace are left exported to avoid api-extractor\n * potentially failing to validate other modules correctly.\n *\n * @beta\n * @system\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace InternalUtilityTypes {\n\t/**\n\t * Meta-type for controlling filtering utilities.\n\t *\n\t * @system\n\t */\n\texport interface FilterControls {\n\t\t/**\n\t\t * Tuple of exact types that are managed by custom serialization/deserialization\n\t\t * logic (beyond JSON.stringify and JSON.parse without replacers/revivers).\n\t\t * Only exact types matching specification will be preserved unaltered.\n\t\t */\n\t\tAllowExactly: unknown[];\n\n\t\t/**\n\t\t * General types that are managed by custom serialization/deserialization\n\t\t * logic (beyond JSON.stringify and JSON.parse without replacers/revivers).\n\t\t * Any type satisfying specification will be preserved unaltered.\n\t\t */\n\t\tAllowExtensionOf: unknown;\n\t}\n\n\t/**\n\t * Meta-type for controlling filtering utilities that additionally supplies\n\t * a substitute type for degenerate cases.\n\t *\n\t * @system\n\t */\n\tinterface FilterControlsWithSubstitution extends FilterControls {\n\t\t/**\n\t\t * Type to use for degenerate cases like `unknown` or `any`.\n\t\t * Typically this will be `JsonTypeWith<TupleToUnion<AllowExactly> | AllowExtensionOf>`.\n\t\t */\n\t\tDegenerateSubstitute: unknown;\n\t}\n\n\t/**\n\t * Meta-type for controlling deserialized filtering utilities.\n\t *\n\t * @system\n\t */\n\tinterface DeserializedFilterControls extends FilterControlsWithSubstitution {\n\t\t/**\n\t\t * Type to use for degenerate `object` case.\n\t\t * Typically this will be `NonNullJsonObjectWith<TupleToUnion<AllowExactly> | AllowExtensionOf>`.\n\t\t */\n\t\tDegenerateNonNullObjectSubstitute: unknown;\n\t}\n\n\t/**\n\t * Returns non-symbol keys for optional properties of an object type.\n\t * This excludes indexed properties that are inherently _optional_.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as OptionalNonSymbolKeysOf<T, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type OptionalNonSymbolKeysOf<\n\t\tT extends object,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: T extends Record<K, T[K]> ? never : K;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Returns non-symbol keys for required properties of an object type.\n\t * This includes indexed properties that are inherently _optional_.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as RequiredNonSymbolKeysOf<T, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type RequiredNonSymbolKeysOf<\n\t\tT extends object,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: T extends Record<K, T[K]> ? K : never;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Returns Result.WhenSomethingDeserializable if T is sometimes at least a\n\t * partially deserializable type, otherwise Result.WhenNeverDeserializable.\n\t * Fully not deserializable (bigints, symbols, undefined and functions without\n\t * other properties less overlap with T*Exception) produce Result.WhenNeverDeserializable.\n\t * An object would have a defined result even if parts of its content are\n\t * not deserializable.\n\t *\n\t * @param Result - Result type with two properties. One property must always\n\t * be `never` as `T` maybe a union of never deserializable and at least\n\t * partially deserializable types and the result is a union of Result.*.\n\t *\n\t * @privateRemarks\n\t * If `Result.WhenSomethingDeserializable` was `true` and\n\t * `Result.WhenNeverDeserializable` was `false`, then the return type\n\t * for type `T` would be `boolean` for a sometimes deserializable type.\n\t *\n\t * @system\n\t */\n\texport type TestDeserializabilityOf<\n\t\tT,\n\t\tTExactExceptions extends unknown[],\n\t\tTExtendsException,\n\t\tResult extends\n\t\t\t| { WhenSomethingDeserializable: unknown; WhenNeverDeserializable: never }\n\t\t\t| { WhenSomethingDeserializable: never; WhenNeverDeserializable: unknown },\n\t> = /* ensure working with more than never */ T extends never\n\t\t? /* never => */ Result[\"WhenNeverDeserializable\"]\n\t\t: /* check for extends exception */ T extends TExtendsException\n\t\t\t? /* extends exception => */ Result[\"WhenSomethingDeserializable\"]\n\t\t\t: /* no extends exception => check for exact exception */ IfExactTypeInTuple<\n\t\t\t\t\tT,\n\t\t\t\t\tTExactExceptions,\n\t\t\t\t\t/* exact exception => */ Result[\"WhenSomethingDeserializable\"],\n\t\t\t\t\t/* no exception => check for only non-serializable value types */ T extends\n\t\t\t\t\t\t| bigint\n\t\t\t\t\t\t| symbol\n\t\t\t\t\t\t| undefined\n\t\t\t\t\t\t? /* not serializable => */ Result[\"WhenNeverDeserializable\"]\n\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\tT extends Function\n\t\t\t\t\t\t\t? ExtractFunctionFromIntersection<T> extends {\n\t\t\t\t\t\t\t\t\tclassification: \"exactly Function\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t? /* not serializable => */ Result[\"WhenNeverDeserializable\"]\n\t\t\t\t\t\t\t\t: /* at least partially serializable */ Result[\"WhenSomethingDeserializable\"]\n\t\t\t\t\t\t\t: /* at least partially serializable */ Result[\"WhenSomethingDeserializable\"]\n\t\t\t\t>;\n\n\t/**\n\t * Similar to `Exclude` but only excludes exact `U`s from `T`\n\t * rather than any type that extends `U`.\n\t *\n\t * @system\n\t */\n\texport type ExcludeExactly<T, U> = IfSameType<T, U, never, T>;\n\n\t/**\n\t * Similar to `Exclude` but only excludes exact members of `U` from `T`\n\t * rather than any type that extends members of `U`.\n\t *\n\t * @system\n\t */\n\texport type ExcludeExactlyInTuple<T, TupleOfU extends unknown[]> = IfExactTypeInTuple<\n\t\tT,\n\t\tTupleOfU,\n\t\tnever,\n\t\tT\n\t>;\n\n\t/**\n\t * Similar to `Omit` but operates on tuples.\n\t * Removes elements of `Tuple` that extend `U`.\n\t *\n\t * @system\n\t */\n\texport type OmitFromTuple<\n\t\tTuple extends unknown[],\n\t\tU,\n\t\tAccumulated extends unknown[] = [],\n\t> = Tuple extends [infer First, ...infer Rest]\n\t\t? OmitFromTuple<Rest, U, First extends U ? Accumulated : [...Accumulated, First]>\n\t\t: Accumulated;\n\n\t/**\n\t * Similar to `OmitFromTuple` but removes only exact matches of U.\n\t * Removes elements of `Tuple` that are exactly `U`.\n\t *\n\t * @remarks If `U` is a union, then only exactly matching union elements of `Tuple` are removed.\n\t * @system\n\t */\n\texport type OmitExactlyFromTuple<\n\t\tTuple extends unknown[],\n\t\tU,\n\t\tAccumulated extends unknown[] = [],\n\t> = Tuple extends [infer First, ...infer Rest]\n\t\t? OmitExactlyFromTuple<Rest, U, IfSameType<First, U, Accumulated, [...Accumulated, First]>>\n\t\t: Accumulated;\n\n\t/**\n\t * Returns non-symbol keys for defined, (likely) serializable properties of an\n\t * object type. Keys with fully unsupported properties (undefined, symbol, and\n\t * bigint) and sometimes unsupported (functions) are excluded. An exception to\n\t * that is when there are supported types in union with just bigint.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as NonSymbolWithDeserializablePropertyOf<T, [], never, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type NonSymbolWithDeserializablePropertyOf<\n\t\tT extends object,\n\t\tTExactExceptions extends unknown[],\n\t\tTExtendsException,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: /* all possible types that aren't already allowed, with the exception of `unknown` */\n\t\t\tExcludeExactlyInTuple<\n\t\t\t\tExclude<T[K], TExtendsException>,\n\t\t\t\tOmitExactlyFromTuple<TExactExceptions, unknown>\n\t\t\t> extends infer PossibleTypeLessAllowed\n\t\t\t\t? IfSameType<\n\t\t\t\t\t\tPossibleTypeLessAllowed,\n\t\t\t\t\t\tunknown,\n\t\t\t\t\t\t/* value might not be supported => exclude K */ never,\n\t\t\t\t\t\t/* extract types that might lead to missing property */ Extract<\n\t\t\t\t\t\t\tPossibleTypeLessAllowed,\n\t\t\t\t\t\t\t/* types that might lead to missing property, except `bigint` */\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\tundefined | symbol | Function\n\t\t\t\t\t\t> extends never\n\t\t\t\t\t\t\t? /* all types are supported plus possibly `bigint` => */\n\t\t\t\t\t\t\t\t/* check for only `bigint` remaining */ IfSameType<\n\t\t\t\t\t\t\t\t\tPossibleTypeLessAllowed,\n\t\t\t\t\t\t\t\t\tbigint,\n\t\t\t\t\t\t\t\t\t/* only `bigint` => nothing supported */ never,\n\t\t\t\t\t\t\t\t\t/* exclusively supported types (and maybe `bigint`) or exactly `never` */\n\t\t\t\t\t\t\t\t\t/* => check for `never` */ T[K] extends never ? never : K\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t: /* value might not be supported => exclude K */ never\n\t\t\t\t\t>\n\t\t\t\t: never;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Returns non-symbol keys for partially supported properties of an object type.\n\t * Keys with only unsupported properties (undefined, symbol, bigint, and\n\t * functions without other properties) are excluded.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as NonSymbolWithPossiblyDeserializablePropertyOf<T, [], never, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type NonSymbolWithPossiblyDeserializablePropertyOf<\n\t\tT extends object,\n\t\tTExactExceptions extends unknown[],\n\t\tTExtendsException,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: /* all possible types that aren't already allowed, with the exception of `unknown` */\n\t\t\tExcludeExactlyInTuple<\n\t\t\t\tExclude<T[K], TExtendsException>,\n\t\t\t\tOmitExactlyFromTuple<TExactExceptions, unknown>\n\t\t\t> extends infer PossibleTypeLessAllowed\n\t\t\t\t? Extract<\n\t\t\t\t\t\tIfSameType<PossibleTypeLessAllowed, unknown, undefined, PossibleTypeLessAllowed>,\n\t\t\t\t\t\t/* types that might lead to missing property */\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\tundefined | symbol | Function\n\t\t\t\t\t> extends never\n\t\t\t\t\t? /* exclusively supported types or exactly `never` */ never\n\t\t\t\t\t: /* at least some unsupported type => check for any supported */ TestDeserializabilityOf<\n\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\tOmitExactlyFromTuple<TExactExceptions, unknown>,\n\t\t\t\t\t\t\tTExtendsException,\n\t\t\t\t\t\t\t{ WhenSomethingDeserializable: K; WhenNeverDeserializable: never }\n\t\t\t\t\t\t>\n\t\t\t\t: never;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Filters a type `T` for `undefined` that is not viable in an array (or tuple) that\n\t * must go through JSON serialization.\n\t * If `T` is `undefined`, then error type {@link SerializationErrorPerUndefinedArrayElement}\n\t * is returned with hopes of being informative.\n\t *\n\t * @system\n\t */\n\texport type JsonForSerializableArrayItem<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tTAncestorTypes extends unknown[],\n\t\tTBlessed,\n\t> = /* Some initial filtering must be provided before a test for undefined. */\n\t/* These tests are expected to match those in JsonSerializableImpl. */\n\t/* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ TBlessed\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ TBlessed\n\t\t\t: /* test for exact recursion */ IfExactTypeInTuple<\n\t\t\t\t\tT,\n\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t/* recursion; stop here => */ T,\n\t\t\t\t\t/* test for JSON primitive types or given alternative */ T extends\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t| number\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t\t? /* primitive types or alternative => */ T\n\t\t\t\t\t\t: /* test for exact alternative */ IfExactTypeInTuple<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t/* test for undefined possibility */ undefined extends T\n\t\t\t\t\t\t\t\t\t? /* undefined | ... => */ SerializationErrorPerUndefinedArrayElement\n\t\t\t\t\t\t\t\t\t: TBlessed\n\t\t\t\t\t\t\t>\n\t\t\t\t>;\n\n\t/**\n\t * Filters a type `T` for types that become null through JSON serialization.\n\t *\n\t * @system\n\t */\n\texport type JsonForDeserializedArrayItem<\n\t\tT,\n\t\tControls extends DeserializedFilterControls,\n\t\tTBlessed,\n\t> = /* Some initial filtering must be provided before a test for undefined, symbol, or function. */\n\t/* These tests are expected to match those in JsonDeserializedImpl. */\n\t/* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ TBlessed\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ TBlessed\n\t\t\t: /* test for JSON primitive types or general alternative */ T extends\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t| number\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t? /* primitive or replaced types => */ T\n\t\t\t\t: /* test for exact alternative */ IfExactTypeInTuple<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t/* exactly replaced => */ T,\n\t\t\t\t\t\t/* test for known types that become null */ T extends undefined | symbol\n\t\t\t\t\t\t\t? /* => */ null\n\t\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\t\tT extends Function\n\t\t\t\t\t\t\t\t? ExtractFunctionFromIntersection<T> extends {\n\t\t\t\t\t\t\t\t\t\tclassification: \"exactly Function\";\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t: null | TBlessed\n\t\t\t\t\t\t\t\t: TBlessed\n\t\t\t\t\t>;\n\n\t/**\n\t * Checks for a type that is simple class of number and string indexed types to numbers and strings.\n\t *\n\t * @system\n\t */\n\texport type IfEnumLike<\n\t\tT extends object,\n\t\tEnumLike = never,\n\t\tNotEnumLike = unknown,\n\t> = T extends readonly (infer _)[]\n\t\t? /* array => */ NotEnumLike\n\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\tT extends Function\n\t\t\t? /* function => */ NotEnumLike\n\t\t\t: T extends {\n\t\t\t\t\t\t// all numerical indices should refer to a string\n\t\t\t\t\t\treadonly [i: number]: string;\n\t\t\t\t\t\t// string indices may be string or number\n\t\t\t\t\t\treadonly [p: string]: number | string;\n\t\t\t\t\t\t// no symbol indices are allowed\n\t\t\t\t\t\treadonly [s: symbol]: never;\n\t\t\t\t\t}\n\t\t\t\t? /* test for a never or any property */ true extends {\n\t\t\t\t\t\t[K in keyof T]: T[K] extends never ? true : never;\n\t\t\t\t\t}[keyof T]\n\t\t\t\t\t? NotEnumLike\n\t\t\t\t\t: EnumLike\n\t\t\t\t: NotEnumLike;\n\n\t/**\n\t * Test for type equality\n\t *\n\t * @returns IfSame if identical and IfDifferent otherwise.\n\t *\n\t * Implementation derived from https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650\n\t *\n\t * @remarks Use caution when one of the type might be `{}`. That type is\n\t * special and produces unexpected results. This includes variability\n\t * on past usages.\n\t *\n\t * @system\n\t */\n\texport type IfSameType<X, Y, IfSame = unknown, IfDifferent = never> = (<T>() => T extends X\n\t\t? 1\n\t\t: 2) extends <T>() => T extends Y ? 1 : 2\n\t\t? IfSame\n\t\t: IfDifferent;\n\n\t/**\n\t * Test for type equality with tuple of other types.\n\t *\n\t * @typeParam T - Type to find in Tuple.\n\t * @typeParam Tuple - Tuple of types to test against.\n\t * @typeParam IfMatch - Type to return if match is found.\n\t * @typeParam IfNoMatch - Type to return if no match is found.\n\t *\n\t * @privateRemarks\n\t * Tests for an exact match of `T` in `Tuple[0]`. If not found,\n\t * recurses with the remainder of the tuple.\n\t */\n\texport type IfExactTypeInTuple<\n\t\tT,\n\t\tTuple extends unknown[],\n\t\tIfMatch = unknown,\n\t\tIfNoMatch = never,\n\t> = Tuple extends [infer First, ...infer Rest]\n\t\t? IfSameType<T, First, IfMatch, IfExactTypeInTuple<T, Rest, IfMatch, IfNoMatch>>\n\t\t: IfNoMatch;\n\n\t/**\n\t * Test for type equality with union of other types.\n\t *\n\t * @typeParam T - Type to find in Union. If this is itself a union, then all types must be found in Union.\n\t * @typeParam Union - Union of types to test against.\n\t * @typeParam IfMatch - Type to return if match is found.\n\t * @typeParam IfNoMatch - Type to return if no match is found.\n\t *\n\t * @remarks\n\t * In a recursive context, use {@link InternalUtilityTypes.IfExactTypeInTuple} to manage ancestry.\n\t *\n\t * @privateRemarks\n\t * Perhaps it is a Typescript defect but a simple check that `T` is `never`\n\t * via `T extends never` does not work as expected in this context.\n\t * Workaround using `IfSameType<..., never,...>`.\n\t * @system\n\t */\n\texport type IfExactTypeInUnion<T, Union, IfMatch = unknown, IfNoMatch = never> = IfSameType<\n\t\tT,\n\t\tnever,\n\t\t/* T is never => */ IfSameType<Union, never, IfMatch, IfNoMatch>,\n\t\t/* T is NOT never => */ IfSameType<T, Extract<Union, T>, IfMatch, IfNoMatch>\n\t>;\n\n\t/**\n\t * Test for type equality\n\t *\n\t * @returns `true` if identical and `false` otherwise.\n\t *\n\t * @remarks Use caution when one of the type might be `{}`. That type is\n\t * special and produces unexpected results. This includes variability\n\t * on past usages.\n\t *\n\t * @system\n\t */\n\texport type IsSameType<X, Y> = IfSameType<X, Y, true, false>;\n\n\t/**\n\t * Checks that type is exactly `object`.\n\t *\n\t * @system\n\t */\n\texport type IsExactlyObject<T extends object> = IsSameType<T, object>;\n\n\t/**\n\t * Any Record type.\n\t *\n\t * @system\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- `any` for property types is required to avoid \"Index signature for type 'string' is missing in type\" in some outside `FlattenIntersection` uses.\n\texport type AnyRecord = Record<keyof any, any>;\n\n\t/**\n\t * Creates a simple object type from an intersection of multiple.\n\t * @privateRemarks\n\t * `T extends AnyRecord` within the implementation encourages tsc to process\n\t * intersections within unions.\n\t *\n\t * @system\n\t */\n\texport type FlattenIntersection<T extends AnyRecord> = T extends AnyRecord\n\t\t? {\n\t\t\t\t[K in keyof T]: T[K];\n\t\t\t}\n\t\t: T;\n\n\t/**\n\t * Extracts Function portion from an intersection (&) type returning\n\t * the extracted portion in the `function` property or `unknown` if\n\t * no function is found.\n\t * The returned `classification` property has one of three values:\n\t * - \"no Function\" if the type is not a function.\n\t * - \"exactly Function\" if the type is exactly a function.\n\t * - \"Function and more\" if the type is a function and has other properties.\n\t *\n\t * @system\n\t */\n\texport type ExtractFunctionFromIntersection<T extends object> = (T extends new (\n\t\t...args: infer A\n\t) => infer R\n\t\t? new (\n\t\t\t\t...args: A\n\t\t\t) => R\n\t\t: unknown) &\n\t\t(T extends (...args: infer A) => infer R\n\t\t\t? (...args: A) => R\n\t\t\t: unknown) extends infer Functional\n\t\t? {\n\t\t\t\tclassification: unknown extends Functional\n\t\t\t\t\t? \"no Function\"\n\t\t\t\t\t: Functional extends Required<T>\n\t\t\t\t\t\t? \"exactly Function\"\n\t\t\t\t\t\t: \"Function and more\";\n\t\t\t\tfunction: Functional;\n\t\t\t}\n\t\t: never;\n\n\t/**\n\t * Returns `Filtered` & any Function intersection from `Original`.\n\t * If `Original` is exactly a Function, then `Filtered` is left out\n\t * under the assumption that it is not useful/applicable.\n\t *\n\t * @system\n\t */\n\texport type FilterPreservingFunction<\n\t\tOriginal extends object,\n\t\tFiltered,\n\t> = ExtractFunctionFromIntersection<Original> extends {\n\t\tclassification: infer TClassification;\n\t\tfunction: infer TFunction;\n\t}\n\t\t? TClassification extends \"exactly Function\"\n\t\t\t? TFunction\n\t\t\t: TFunction & Filtered\n\t\t: never;\n\n\t/**\n\t * Replaces any instance where a type T recurses into itself or a portion of\n\t * itself with TRecursionMarker.\n\t *\n\t * @typeParam T - Type to process.\n\t * @typeParam TRecursionMarker - Replacement marker type.\n\t * @typeParam Controls - Allowances are preserved as-is.\n\t * @typeParam TAncestorTypes - Tuple of types that are ancestors of T.\n\t * @typeParam TNextAncestor - Set exactly to T. This is passed separately\n\t * such that T union types remain intact as exact ancestors.\n\t *\n\t * @remarks\n\t * Filtering applied to class instances with non-public properties will not\n\t * preserve the class instance unless those classes are known and listed as\n\t * allowances via `Controls`.\n\t *\n\t * @privateRemarks\n\t * This implementation handles functions including function with properties.\n\t * There are no known cases where replacing recursion under such types make\n\t * a difference. Either the function (whole type) is allowed by the Json\n\t * filters or function is not allowed at all.\n\t * If the function portion is found to be problematic later, then could use\n\t * `T extends Function ? T : ...` to ignore function objects.\n\t *\n\t * @system\n\t */\n\texport type ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\tT,\n\t\tTRecursionMarker,\n\t\tControls extends FilterControls,\n\t\tTAncestorTypes extends unknown[] = [],\n\t\tTNextAncestor = T,\n\t> = /* test for recursion */\n\tIfExactTypeInTuple<T, TAncestorTypes, true, \"no match\"> extends true\n\t\t? /* recursion => use replacement */ TRecursionMarker\n\t\t: /* force union separation hereafter */ T extends infer _\n\t\t\t? /* test for recursion among union elements */\n\t\t\t\tIfExactTypeInTuple<T, TAncestorTypes, true, \"no match\"> extends true\n\t\t\t\t? TRecursionMarker\n\t\t\t\t: /* test for general allowance */ T extends Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t? /* allowed extension type => */ T\n\t\t\t\t\t: /* test for exact allowance */ IfExactTypeInTuple<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t\t\t> extends true\n\t\t\t\t\t\t? /* exact allowed type => */ T\n\t\t\t\t\t\t: T extends object\n\t\t\t\t\t\t\t? FilterPreservingFunction<\n\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t[K in keyof T]: ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\tTRecursionMarker,\n\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t: /* non-object => T as is */ T\n\t\t\t: never;\n\n\t/**\n\t * Replaces any instances of \"allowed\" types and recursion within with `never`.\n\t *\n\t * @typeParam T - Type to process.\n\t * @typeParam Controls - Allowances to replace.\n\t * @typeParam TAncestorTypes - Tuple of types that are ancestors of T.\n\t * @typeParam TNextAncestor - Set exactly to T. This is passed separately\n\t * such that T union types remain intact as exact ancestors.\n\t *\n\t * @system\n\t */\n\texport type ReplaceAllowancesAndRecursionWithNever<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tTAncestorTypes extends unknown[] = [],\n\t\tTNextAncestor = T,\n\t> = /* test for exact recursion first */ IfExactTypeInTuple<\n\t\tT,\n\t\tTAncestorTypes,\n\t\ttrue,\n\t\t\"no match\"\n\t> extends true\n\t\t? /* recursion => */ never\n\t\t: /* test for general allowance (also forces union separation) */ T extends Controls[\"AllowExtensionOf\"]\n\t\t\t? /* allowed extension type => */ never\n\t\t\t: /* test for exact allowance */ IfExactTypeInTuple<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t> extends true\n\t\t\t\t? /* exact allowed type => */ never\n\t\t\t\t: /* test for recursion among union elements */ IfExactTypeInTuple<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t\t> extends true\n\t\t\t\t\t? /* recursion => */ never\n\t\t\t\t\t: T extends object\n\t\t\t\t\t\t? FilterPreservingFunction<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t[K in keyof T]: ReplaceAllowancesAndRecursionWithNever<\n\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t: /* non-object => T as is */ T;\n\n\t/**\n\t * Test for non-public properties (which can only exist on class instance types).\n\t *\n\t * Returns `HasNonPublic` if `T` deeply may contain a private or protected field\n\t * and `OnlyPublics` otherwise.\n\t *\n\t * @remarks\n\t * Compare original (unprocessed) to filtered case that has `never` where\n\t * recursing or where allowed exception types are used.\n\t *\n\t * Note that this a test of the type and not the actual data. So, if an\n\t * interface is given as `T` where implemented by a class, any private or\n\t * protected fields within the class will not be detected.\n\t *\n\t * @system\n\t */\n\texport type IfNonPublicProperties<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tHasNonPublic = never,\n\t\tOnlyPublics = unknown,\n\t> = ReplaceAllowancesAndRecursionWithNever<T, Controls> extends T\n\t\t? OnlyPublics\n\t\t: HasNonPublic;\n\n\t/**\n\t * Union of all types in a tuple.\n\t *\n\t * @system\n\t */\n\texport type TupleToUnion<T extends unknown[]> = T[number];\n\n\t// #region JsonSerializable implementation\n\n\t/**\n\t * Outer implementation of {@link JsonSerializable} handling meta cases\n\t * like classes (with non-public properties).\n\t *\n\t * @system\n\t */\n\texport type JsonSerializableImpl<\n\t\tT,\n\t\tOptions extends Partial<FilterControls> & {\n\t\t\tIgnoreInaccessibleMembers?: \"ignore-inaccessible-members\";\n\t\t},\n\t\tTAncestorTypes extends unknown[] = [],\n\t\tTNextAncestor = T,\n\t> = /* Build Controls from Options filling in defaults for any missing properties */\n\t{\n\t\tAllowExactly: Options extends { AllowExactly: unknown[] } ? Options[\"AllowExactly\"] : [];\n\t\tAllowExtensionOf: Options extends { AllowExtensionOf: unknown }\n\t\t\t? Options[\"AllowExtensionOf\"]\n\t\t\t: never;\n\t\t// There Substitute type could be extracted to helper type, but are kept explicit here\n\t\t// to make JsonTypeWith show explicitly in results for users, rather\n\t\t// than either the helper type name or a partially unrolled version.\n\t\tDegenerateSubstitute: JsonTypeWith<\n\t\t\t| (Options extends { AllowExactly: unknown[] }\n\t\t\t\t\t? TupleToUnion<Options[\"AllowExactly\"]>\n\t\t\t\t\t: never)\n\t\t\t| (Options extends { AllowExtensionOf: unknown } ? Options[\"AllowExtensionOf\"] : never)\n\t\t>;\n\t} extends infer Controls\n\t\t? /* Controls should always satisfy FilterControlsWithSubstitution, but Typescript wants a check */\n\t\t\tControls extends FilterControlsWithSubstitution\n\t\t\t? /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t\t\t? /* 'any' => */ Controls[\"DegenerateSubstitute\"]\n\t\t\t\t: Options[\"IgnoreInaccessibleMembers\"] extends \"ignore-inaccessible-members\"\n\t\t\t\t\t? JsonSerializableFilter<T, Controls, TAncestorTypes, TNextAncestor>\n\t\t\t\t\t: /* test for non-public properties (class instance type) */\n\t\t\t\t\t\tIfNonPublicProperties<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tAllowExactly: Controls[\"AllowExactly\"];\n\t\t\t\t\t\t\t\t\t// Add in primitives that may be branded to ignore intersection classes\n\t\t\t\t\t\t\t\t\tAllowExtensionOf: Controls[\"AllowExtensionOf\"] | boolean | number | string;\n\t\t\t\t\t\t\t\t\tDegenerateSubstitute: Controls[\"DegenerateSubstitute\"];\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"found non-publics\",\n\t\t\t\t\t\t\t\t\"only publics\"\n\t\t\t\t\t\t\t> extends \"found non-publics\"\n\t\t\t\t\t\t? /* hidden props => test if it is array properties that are the problem */ T extends readonly (infer _)[]\n\t\t\t\t\t\t\t? /* array => */ {\n\t\t\t\t\t\t\t\t\t/* use homomorphic mapped type to preserve tuple type */\n\t\t\t\t\t\t\t\t\t[K in keyof T]: JsonSerializableImpl<\n\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: /* test for potentially branded primitive (intersection with a supported primitive) */\n\t\t\t\t\t\t\t\tT extends boolean | number | string\n\t\t\t\t\t\t\t\t? /* assume intersection is branding and allow as-is => */ T\n\t\t\t\t\t\t\t\t: /* not array => error */ SerializationErrorPerNonPublicProperties\n\t\t\t\t\t\t: /* no hidden properties => apply filtering => */ JsonSerializableFilter<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\t\t\tTNextAncestor\n\t\t\t\t\t\t\t>\n\t\t\t: never /* FilterControlsWithSubstitution assert else; should never be reached */\n\t\t: never /* unreachable else for infer */;\n\n\t/**\n\t * Essentially a check for a template literal that has $\\{string\\} or\n\t * $\\{number\\} in the pattern. Just `string` and/or `number` also match.\n\t *\n\t * @remarks This works recursively looking at first elements when not\n\t * `string` or `number`. `first` will just be a single character if\n\t * not $\\{string\\} or $\\{number\\}.\n\t *\n\t * @system\n\t */\n\texport type IfIndexKey<T, IfIndex, IfLiteral> = `${string}` extends T\n\t\t? IfIndex\n\t\t: number extends T\n\t\t\t? IfIndex\n\t\t\t: T extends `${infer first}${infer rest}`\n\t\t\t\t? string extends first\n\t\t\t\t\t? IfIndex\n\t\t\t\t\t: `${number}` extends first\n\t\t\t\t\t\t? IfIndex\n\t\t\t\t\t\t: IfIndexKey<rest, IfIndex, IfLiteral>\n\t\t\t\t: IfLiteral;\n\n\t/**\n\t * Helper for {@link JsonSerializableFilter} to determine if a property may\n\t * be `undefined` and selects from options for result.\n\t * Since `unknown` is a superset of `undefined`, it is given a special case.\n\t * Additionally since index signatures are inherently optional, `unknown` typed\n\t * values are treated as not undefined (`Result[\"Otherwise\"]`).\n\t *\n\t * @system\n\t */\n\texport type IfPossiblyUndefinedProperty<\n\t\tTKey,\n\t\tTValue,\n\t\tResult extends {\n\t\t\tIfPossiblyUndefined: unknown;\n\t\t\tIfUnknownNonIndexed: unknown;\n\t\t\tOtherwise: unknown;\n\t\t},\n\t> = undefined extends TValue\n\t\t? unknown extends TValue\n\t\t\t? IfIndexKey<TKey, Result[\"Otherwise\"], Result[\"IfUnknownNonIndexed\"]>\n\t\t\t: Result[\"IfPossiblyUndefined\"]\n\t\t: Result[\"Otherwise\"];\n\n\t/**\n\t * Core implementation of {@link JsonSerializable}.\n\t *\n\t * @privateRemarks\n\t * Filtering through a single layer of recursion is all that is required\n\t * when using in prescribed filter scenario.\n\t *\n\t * @system\n\t */\n\texport type JsonSerializableFilter<\n\t\tT,\n\t\tControls extends FilterControlsWithSubstitution,\n\t\tTAncestorTypes extends unknown[],\n\t\tTNextAncestor = T,\n\t> = /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ Controls[\"DegenerateSubstitute\"]\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ Controls[\"DegenerateSubstitute\"]\n\t\t\t: /* test for recursion */ IfExactTypeInTuple<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t> extends true\n\t\t\t\t? /* exact recursion; stop here => */ T\n\t\t\t\t: /* test for JSON Encodable primitive types or given alternate base */ T extends\n\t\t\t\t\t\t\t| null\n\t\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t\t| number\n\t\t\t\t\t\t\t| string\n\t\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t? /* primitive types or alternate => */ T\n\t\t\t\t\t: /* test for exact alternate */ IfExactTypeInTuple<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t\t\t> extends true\n\t\t\t\t\t\t? /* exact alternate type => */ T\n\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\t/* test for not a function */ Extract<T, Function> extends never\n\t\t\t\t\t\t\t? /* not a function => test for object */ T extends object\n\t\t\t\t\t\t\t\t? /* object => test for array */ T extends readonly (infer _)[]\n\t\t\t\t\t\t\t\t\t? /* array => */ {\n\t\t\t\t\t\t\t\t\t\t\t/* array items may not not allow undefined */\n\t\t\t\t\t\t\t\t\t\t\t/* use homomorphic mapped type to preserve tuple type */\n\t\t\t\t\t\t\t\t\t\t\t[K in keyof T]: JsonForSerializableArrayItem<\n\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\t\t\t\t\t\t\tJsonSerializableFilter<\n\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: /* not an array => test for exactly `object` */ IsExactlyObject<T> extends true\n\t\t\t\t\t\t\t\t\t\t? /* `object` => */ NonNullJsonObjectWith<\n\t\t\t\t\t\t\t\t\t\t\t\tTupleToUnion<Controls[\"AllowExactly\"]> | Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t: /* test for enum like types */ IfEnumLike<T> extends never\n\t\t\t\t\t\t\t\t\t\t\t? /* enum or similar simple type (return as-is) => */ T\n\t\t\t\t\t\t\t\t\t\t\t: /* property bag => */ FlattenIntersection<\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* required properties are recursed and may not have undefined values. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as RequiredNonSymbolKeysOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>]-?: IfPossiblyUndefinedProperty<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tK,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIfPossiblyUndefined: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\"error required property may not allow `undefined` value\"]: never;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIfUnknownNonIndexed: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\"error required property may not allow `unknown` value\"]: never;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOtherwise: JsonSerializableFilter<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t\t} & {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* optional properties are recursed and, when exactOptionalPropertyTypes is\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t false, are allowed to preserve undefined value type. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as OptionalNonSymbolKeysOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>]?: JsonSerializableFilter<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t\t} & {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* symbol properties are rejected */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T & symbol]: never;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t: /* not an object => */ never\n\t\t\t\t\t\t\t: /* function => */ never;\n\n\t// #endregion\n\n\t/**\n\t * Sentinel type for use when marking points of recursion (in a recursive type).\n\t * Type is expected to be unique, though no lengths are taken to ensure that.\n\t *\n\t * @system\n\t */\n\texport interface RecursionMarker {\n\t\t[RecursionMarkerSymbol]: typeof RecursionMarkerSymbol;\n\t}\n\n\t/**\n\t * Recursion limit is the count of `+` that prefix it when string.\n\t *\n\t * @system\n\t */\n\texport type RecursionLimit = `+${string}` | 0;\n\n\t// #region JsonDeserialized implementation\n\n\t/**\n\t * Outer implementation of {@link JsonDeserialized} handling meta cases\n\t * like recursive types.\n\t *\n\t * @privateRemarks\n\t * This utility is reentrant and will process a type `T` up to `RecurseLimit`.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedImpl<\n\t\tT,\n\t\tOptions extends Partial<FilterControls>,\n\t\tRecurseLimit extends RecursionLimit = \"++++\" /* 4 */,\n\t> = /* Build Controls from Options filling in defaults for any missing properties */\n\t{\n\t\tAllowExactly: Options extends { AllowExactly: unknown[] } ? Options[\"AllowExactly\"] : [];\n\t\tAllowExtensionOf: Options extends { AllowExtensionOf: unknown }\n\t\t\t? Options[\"AllowExtensionOf\"]\n\t\t\t: never;\n\t\t// There Substitute types could be extracted to helper type, but are kept explicit here\n\t\t// to make JsonTypeWith/NonNullJsonObjectWith show explicitly in results for users, rather\n\t\t// than either the helper type name or a partially unrolled version.\n\t\tDegenerateSubstitute: JsonTypeWith<\n\t\t\t| (Options extends { AllowExactly: unknown[] }\n\t\t\t\t\t? TupleToUnion<Options[\"AllowExactly\"]>\n\t\t\t\t\t: never)\n\t\t\t| (Options extends { AllowExtensionOf: unknown } ? Options[\"AllowExtensionOf\"] : never)\n\t\t>;\n\t\tDegenerateNonNullObjectSubstitute: NonNullJsonObjectWith<\n\t\t\t| (Options extends { AllowExactly: unknown[] }\n\t\t\t\t\t? TupleToUnion<Options[\"AllowExactly\"]>\n\t\t\t\t\t: never)\n\t\t\t| (Options extends { AllowExtensionOf: unknown } ? Options[\"AllowExtensionOf\"] : never)\n\t\t>;\n\t} extends infer Controls\n\t\t? /* Controls should always satisfy DeserializedFilterControls, but Typescript wants a check */\n\t\t\tControls extends DeserializedFilterControls\n\t\t\t? /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t\t\t? /* 'any' => */ Controls[\"DegenerateSubstitute\"]\n\t\t\t\t: /* infer non-recursive version of T */ ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tRecursionMarker,\n\t\t\t\t\t\t\tControls\n\t\t\t\t\t\t> extends infer TNoRecursionAndOnlyPublics\n\t\t\t\t\t? /* test for no change from filtered type */ IsSameType<\n\t\t\t\t\t\t\tTNoRecursionAndOnlyPublics,\n\t\t\t\t\t\t\tJsonDeserializedFilter<\n\t\t\t\t\t\t\t\tTNoRecursionAndOnlyPublics,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tAllowExactly: [...Controls[\"AllowExactly\"], RecursionMarker];\n\t\t\t\t\t\t\t\t\tAllowExtensionOf: Controls[\"AllowExtensionOf\"];\n\t\t\t\t\t\t\t\t\tDegenerateSubstitute: Controls[\"DegenerateSubstitute\"];\n\t\t\t\t\t\t\t\t\tDegenerateNonNullObjectSubstitute: Controls[\"DegenerateNonNullObjectSubstitute\"];\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t> extends true\n\t\t\t\t\t\t? /* same (no filtering needed) => test for non-public\n\t\t\t\t\t\t properties (class instance type) */\n\t\t\t\t\t\t\tIfNonPublicProperties<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t// Note: no extra allowance is made here for possible branded\n\t\t\t\t\t\t\t\t// primitives as JsonDeserializedFilter will allow them as\n\t\t\t\t\t\t\t\t// extensions of the primitives. Should there need a need to\n\t\t\t\t\t\t\t\t// explicit allow them here, see JsonSerializableImpl's use.\n\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\"found non-publics\",\n\t\t\t\t\t\t\t\t\"only publics\"\n\t\t\t\t\t\t\t> extends \"found non-publics\"\n\t\t\t\t\t\t\t? /* hidden props => apply filtering to avoid retaining\n\t\t\t\t\t\t\t exact class except for any classes in allowances => */\n\t\t\t\t\t\t\t\tJsonDeserializedFilter<\n\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t// Note that use of RecurseLimit may not be needed here\n\t\t\t\t\t\t\t\t\t// could have an adverse effect on correctness if there\n\t\t\t\t\t\t\t\t\t// several ancestor types that require modification and\n\t\t\t\t\t\t\t\t\t// are peeling away the limit. In such a case, the limit\n\t\t\t\t\t\t\t\t\t// will be used for the problems and result is already\n\t\t\t\t\t\t\t\t\t// messy; so deferring full understanding of the problems\n\t\t\t\t\t\t\t\t\t// that could arise from a reset and being conservative.\n\t\t\t\t\t\t\t\t\tRecurseLimit\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t: /* no hidden properties => deserialized T is just T */\n\t\t\t\t\t\t\t\tT\n\t\t\t\t\t\t: /* filtering is needed => */ JsonDeserializedFilter<T, Controls, RecurseLimit>\n\t\t\t\t\t: /* unreachable else for infer */ never\n\t\t\t: never /* DeserializedFilterControls assert else; should never be reached */\n\t\t: never /* unreachable else for infer */;\n\n\t/**\n\t * Recurses `T` applying {@link InternalUtilityTypes.JsonDeserializedFilter} up to `RecurseLimit` times.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedRecursion<\n\t\tT,\n\t\tControls extends DeserializedFilterControls,\n\t\tRecurseLimit extends RecursionLimit,\n\t\tTAncestorTypes,\n\t> = T extends TAncestorTypes\n\t\t? RecurseLimit extends `+${infer RecursionRemainder}`\n\t\t\t? /* Now that specific recursion is found, process that recursive type\n\t\t\t directly to avoid any collateral damage from ancestor type that\n\t\t\t required modification. */\n\t\t\t\tJsonDeserializedImpl<\n\t\t\t\t\tT,\n\t\t\t\t\tControls,\n\t\t\t\t\tRecursionRemainder extends RecursionLimit ? RecursionRemainder : 0\n\t\t\t\t>\n\t\t\t: Controls[\"DegenerateSubstitute\"]\n\t\t: JsonDeserializedFilter<T, Controls, RecurseLimit, TAncestorTypes | T>;\n\n\t/**\n\t * Core implementation of {@link JsonDeserialized}.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedFilter<\n\t\tT,\n\t\tControls extends DeserializedFilterControls,\n\t\tRecurseLimit extends RecursionLimit,\n\t\tTAncestorTypes = T /* Always start with self as ancestor; otherwise recursion limit appears one greater */,\n\t> = /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ Controls[\"DegenerateSubstitute\"]\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ Controls[\"DegenerateSubstitute\"]\n\t\t\t: /* test for deserializable primitive types or given alternate base */ T extends\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t| number\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t? /* primitive types or alternate => */ T\n\t\t\t\t: /* test for given exact alternate */ IfExactTypeInTuple<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\"not found\"\n\t\t\t\t\t\t> extends true\n\t\t\t\t\t? /* exact alternate type => */ T\n\t\t\t\t\t: /* test for object */ T extends object\n\t\t\t\t\t\t? /* object => */ ExtractFunctionFromIntersection<T> extends {\n\t\t\t\t\t\t\t\tclassification: \"exactly Function\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t? /* exactly function => */ never\n\t\t\t\t\t\t\t: /* not exactly a function (Function portion, if any, is omitted) */\n\t\t\t\t\t\t\t\t/* => test for array */ T extends readonly (infer _)[]\n\t\t\t\t\t\t\t\t? /* array => */ {\n\t\t\t\t\t\t\t\t\t\t/* array items may not not allow undefined */\n\t\t\t\t\t\t\t\t\t\t/* use homomorphic mapped type to preserve tuple type */\n\t\t\t\t\t\t\t\t\t\t[K in keyof T]: JsonForDeserializedArrayItem<\n\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\tJsonDeserializedRecursion<T[K], Controls, RecurseLimit, TAncestorTypes>\n\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: /* not an array => test for exactly `object` */ IsExactlyObject<T> extends true\n\t\t\t\t\t\t\t\t\t? /* `object` => */ Controls[\"DegenerateNonNullObjectSubstitute\"]\n\t\t\t\t\t\t\t\t\t: /* test for enum like types */ IfEnumLike<T> extends never\n\t\t\t\t\t\t\t\t\t\t? /* enum or similar simple type (return as-is) => */ T\n\t\t\t\t\t\t\t\t\t\t: /* property bag => */ FlattenIntersection<\n\t\t\t\t\t\t\t\t\t\t\t\t/* properties with symbol keys or wholly unsupported values are removed */\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t/* properties with defined values are recursed */\n\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as NonSymbolWithDeserializablePropertyOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExtensionOf\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t>]: JsonDeserializedRecursion<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tRecurseLimit,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tTAncestorTypes\n\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t} & {\n\t\t\t\t\t\t\t\t\t\t\t\t\t/* properties that may have undefined values are optional */\n\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as NonSymbolWithPossiblyDeserializablePropertyOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExtensionOf\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t>]?: JsonDeserializedRecursion<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tRecurseLimit,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tTAncestorTypes\n\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t: /* not an object => */ never;\n\n\t// #endregion\n\n\t// #region *Readonly implementations\n\n\t/**\n\t * If `T` is a `Map<K,V>` or `ReadonlyMap<K,V>`, returns `ReadonlyMap` and,\n\t * if `T` extends `DeepenedGenerics`, {@link DeepReadonly} is applied to\n\t * `K` and `V` generics. `Else` is returned if not a generic map.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInMapIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends ReadonlyMap<infer K, infer V>\n\t\t? Map<K, V> extends DeepenedGenerics\n\t\t\t? ReadonlyMap<\n\t\t\t\t\tReadonlyImpl<K, DeepenedGenerics, NoDepthOrRecurseLimit>,\n\t\t\t\t\tReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>\n\t\t\t\t>\n\t\t\t: ReadonlyMap<K, V>\n\t\t: Else;\n\n\t/**\n\t * If `T` is a `Set<TSet>` or `ReadonlySet<TSet>`, returns `ReadonlySet` and,\n\t * if `T` extends `DeepenedGenerics`, {@link DeepReadonly} is applied to\n\t * `TSet` generic. `Else` is returned if not a generic set.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInSetIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends ReadonlySet<infer V>\n\t\t? Set<V> extends DeepenedGenerics\n\t\t\t? ReadonlySet<ReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>>\n\t\t\t: ReadonlySet<V>\n\t\t: Else;\n\n\t/**\n\t * If `T` is a `IFluidHandle<THandle>` and if `T` extends `DeepenedGenerics`,\n\t * {@link DeepReadonly} is applied to `THandle` generic.\n\t * `Else` is returned if not an `IFluidHandle`.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInFluidHandleIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends Readonly<IFluidHandle<infer V>>\n\t\t? IFluidHandle<V> extends DeepenedGenerics\n\t\t\t? Readonly<IFluidHandle<ReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>>>\n\t\t\t: Readonly<T>\n\t\t: Else;\n\n\t/**\n\t * If `T` is a `Promise<TPromise>` and if `T` extends `DeepenedGenerics`,\n\t * {@link DeepReadonly} is applied to `TPromise` generic.\n\t * `Else` is returned if not a `Promise`.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInPromiseIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends Promise<infer V>\n\t\t? Promise<V> extends DeepenedGenerics\n\t\t\t? Promise<ReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>>\n\t\t\t: T\n\t\t: Else;\n\n\t/**\n\t * If `T` is a `WeakMap<K,V>`, returns immutable `WeakMap` and,\n\t * if `T` extends `DeepenedGenerics`, {@link DeepReadonly} is applied to\n\t * `K` and `V` generics. `Else` is returned if not a generic map.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInWeakMapIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends Omit<WeakMap<infer K, infer V>, \"delete\" | \"set\">\n\t\t? WeakMap<K, V> extends DeepenedGenerics\n\t\t\t? Omit<\n\t\t\t\t\tWeakMap<\n\t\t\t\t\t\tReadonlyImpl<K, DeepenedGenerics, NoDepthOrRecurseLimit>,\n\t\t\t\t\t\tReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>\n\t\t\t\t\t>,\n\t\t\t\t\t\"delete\" | \"set\"\n\t\t\t\t>\n\t\t\t: Omit<WeakMap<K, V>, \"delete\" | \"set\">\n\t\t: Else;\n\n\t/**\n\t * If `T` is a `WeakSet<TSet>`, returns immutable `WeakSet` and,\n\t * if `T` extends `DeepenedGenerics`, {@link DeepReadonly} is applied to\n\t * `TSet` generic. `Else` is returned if not a generic weak set.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInWeakSetIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends Omit<WeakSet<infer V>, \"add\" | \"delete\">\n\t\t? WeakSet<V> extends DeepenedGenerics\n\t\t\t? Omit<\n\t\t\t\t\tWeakSet<ReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>>,\n\t\t\t\t\t\"add\" | \"delete\"\n\t\t\t\t>\n\t\t\t: Omit<WeakSet<V>, \"add\" | \"delete\">\n\t\t: Else;\n\n\t/**\n\t * If `T` is a {@link ReadonlySupportedGenerics}, `T` is returned as\n\t * its immutable version, and if `T` extends `DeepenedGenerics`,\n\t * {@link DeepReadonly} is applied to `T`s generics.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInGenerics<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = DeepenReadonlyInMapIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics,\n\t\tNoDepthOrRecurseLimit,\n\t\tDeepenReadonlyInSetIfEnabled<\n\t\t\tT,\n\t\t\tDeepenedGenerics,\n\t\t\tNoDepthOrRecurseLimit,\n\t\t\tDeepenReadonlyInWeakMapIfEnabled<\n\t\t\t\tT,\n\t\t\t\tDeepenedGenerics,\n\t\t\t\tNoDepthOrRecurseLimit,\n\t\t\t\tDeepenReadonlyInWeakSetIfEnabled<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\tNoDepthOrRecurseLimit,\n\t\t\t\t\tDeepenReadonlyInPromiseIfEnabled<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\tNoDepthOrRecurseLimit,\n\t\t\t\t\t\tDeepenReadonlyInFluidHandleIfEnabled<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\t\tNoDepthOrRecurseLimit,\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t>\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t\t>\n\t\t>\n\t>;\n\n\t/**\n\t * Returns an `ErasedType` or \"branded\" primitive type as-is, or `Else` if not.\n\t * @typeParam T - Type to test.\n\t * @typeParam Else - Type to return if not `ErasedType` or \"branded\" primitive.\n\t *\n\t * @system\n\t */\n\texport type PreserveErasedTypeOrBrandedPrimitive<\n\t\tT extends object,\n\t\tElse,\n\t> = /* Test for erased type */ T extends ErasedType<infer _>\n\t\t? /* erased type => keep as-is */ T\n\t\t: /* Test for branded primitive */ T extends infer Brand &\n\t\t\t\t\t(boolean | number | string | symbol | bigint)\n\t\t\t? // Should just return T here, but TypeScript appears to produce `never` when doing so.\n\t\t\t\t// Workaround by inferring the Primitive type and returning intersection with B.\n\t\t\t\tT extends Brand & infer Primitive\n\t\t\t\t? /* [potentially] branded type => \"as-is\" */ Primitive & Brand\n\t\t\t\t: /* Should never be reached */ T\n\t\t\t: Else;\n\n\t/**\n\t * De-multiplexing implementation of {@link DeepReadonly} and {@link ShallowReadonly}\n\t * selecting behavior based on `NoDepthOrRecurseLimit`.\n\t *\n\t * @privateRemarks\n\t * This utility is reentrant. Its importance is that other utilities common to\n\t * readonly transformation may use `NoDepthOrRecurseLimit` to return the the\n\t * same processing algorithm.\n\t *\n\t * @system\n\t */\n\texport type ReadonlyImpl<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t> = /* test for no depth */ NoDepthOrRecurseLimit extends \"Shallow\"\n\t\t? /* no depth => */ ShallowReadonlyImpl<T, DeepenedGenerics>\n\t\t: /* test for no limit */ NoDepthOrRecurseLimit extends \"NoLimit\"\n\t\t\t? /* no limit => */ DeepReadonlyRecursingInfinitely<T, DeepenedGenerics>\n\t\t\t: /* limited */ DeepReadonlyLimitingRecursion<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\tExtract<NoDepthOrRecurseLimit, RecursionLimit>\n\t\t\t\t>;\n\n\t// #region ShallowReadonly implementation\n\n\t/**\n\t * Outer implementation of {@link ShallowReadonly}.\n\t *\n\t * @privateRemarks\n\t * This utility can be reentrant when generics are deepened.\n\t *\n\t * @system\n\t */\n\texport type ShallowReadonlyImpl<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t> = T extends object\n\t\t? /* object => */ FilterPreservingFunction<\n\t\t\t\tT,\n\t\t\t\tDeepenReadonlyInGenerics<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\"Shallow\",\n\t\t\t\t\tPreserveErasedTypeOrBrandedPrimitive<T, /* basic type => */ Readonly<T>>\n\t\t\t\t>\n\t\t\t>\n\t\t: /* not an object => */ T;\n\n\t// #endregion\n\n\t/**\n\t * Outer implementation of {@link DeepReadonly}.\n\t *\n\t * @privateRemarks\n\t * This utility is reentrant and will process a type `T` up to `RecurseLimit`.\n\t *\n\t * @system\n\t */\n\texport type DeepReadonlyImpl<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tRecurseLimit extends DeepReadonlyRecursionLimit,\n\t> = ReadonlyImpl<T, DeepenedGenerics, RecurseLimit>;\n\n\t// #region DeepReadonly infinite recursion implementation\n\n\t/**\n\t * Simple implementation of {@link DeepReadonly} that may handle limited recursive types.\n\t * In unhandled cases, TypeScript will produce:\n\t * ts(2589): Type instantiation is excessively deep and possibly infinite.\n\t *\n\t * @system\n\t */\n\texport type DeepReadonlyRecursingInfinitely<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t> = T extends object\n\t\t? /* object => */ FilterPreservingFunction<\n\t\t\t\tT,\n\t\t\t\t// test for array of known recursive type: JsonTypeWith\n\t\t\t\tT extends readonly ReadonlyJsonTypeWith<infer Alternates>[]\n\t\t\t\t\t? // Make sure this is exactly that case (many arrays will extend JsonTypeWith)\n\t\t\t\t\t\t// Note that `true extends IfExactTypeInTuple` is used over\n\t\t\t\t\t\t// if-else form as the else branch would be evaluated as input to\n\t\t\t\t\t\t// `IfExactTypeInTuple` and that could lead to infinite recursion.\n\t\t\t\t\t\ttrue extends IfExactTypeInTuple<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t[JsonTypeWith<Alternates>[], readonly ReadonlyJsonTypeWith<Alternates>[]]\n\t\t\t\t\t\t>\n\t\t\t\t\t\t? readonly ReadonlyJsonTypeWith<\n\t\t\t\t\t\t\t\tDeepReadonlyRecursingInfinitely<Alternates, DeepenedGenerics>\n\t\t\t\t\t\t\t>[]\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\treadonly [K in keyof T]: DeepReadonlyRecursingInfinitely<\n\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\tDeepenedGenerics\n\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t: /* not JSON array => */ DeepenReadonlyInGenerics<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\t\t\"NoLimit\",\n\t\t\t\t\t\t\tPreserveErasedTypeOrBrandedPrimitive<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t/* basic type => */ {\n\t\t\t\t\t\t\t\t\treadonly [K in keyof T]: DeepReadonlyRecursingInfinitely<\n\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\tDeepenedGenerics\n\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t>\n\t\t: /* not an object => */ T;\n\n\t// #endregion\n\t// #region DeepReadonly limited recursion implementation\n\n\t/**\n\t * Core implementation of {@link DeepReadonly} handling meta cases\n\t * like recursive types a limited number of times.\n\t *\n\t * @privateRemarks\n\t * This utility is reentrant and will process a type `T` up to `NoDepthOrRecurseLimit`.\n\t *\n\t * @system\n\t */\n\texport type DeepReadonlyLimitingRecursion<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends RecursionLimit,\n\t> = /* infer non-recursive version of T */ ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\tT,\n\t\tRecursionMarker,\n\t\t{ AllowExactly: []; AllowExtensionOf: never }\n\t> extends infer TNoRecursionAndOnlyPublics\n\t\t? /* test for no change from altered type (excluding non-publics) */ IsSameType<\n\t\t\t\tTNoRecursionAndOnlyPublics,\n\t\t\t\tDeepReadonlyWorker<TNoRecursionAndOnlyPublics, DeepenedGenerics, 0>\n\t\t\t> extends true\n\t\t\t? /* same (no filtering needed) => test for non-public properties (class instance type) */\n\t\t\t\tIfNonPublicProperties<\n\t\t\t\t\tT,\n\t\t\t\t\t// Note: no extra allowance is made here for possible branded\n\t\t\t\t\t// primitives as DeepReadonlyWorker will allow them as\n\t\t\t\t\t// extensions of the primitives. Should there need a need to\n\t\t\t\t\t// explicit allow them here, see JsonSerializableImpl's use.\n\t\t\t\t\t{ AllowExactly: []; AllowExtensionOf: never },\n\t\t\t\t\t\"found non-publics\",\n\t\t\t\t\t\"only publics\"\n\t\t\t\t> extends \"found non-publics\"\n\t\t\t\t? /* hidden props => apply filtering => */\n\t\t\t\t\tDeepReadonlyWorker<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\tExtract<NoDepthOrRecurseLimit, RecursionLimit>\n\t\t\t\t\t>\n\t\t\t\t: /* no hidden properties => readonly T is just T */\n\t\t\t\t\tT\n\t\t\t: /* filtering is needed => */ DeepReadonlyWorker<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\tExtract<NoDepthOrRecurseLimit, RecursionLimit>\n\t\t\t\t>\n\t\t: /* unreachable else for infer */ never;\n\n\t/**\n\t * Recurses `T` applying {@link InternalUtilityTypes.DeepReadonlyWorker} up to `RecurseLimit` times.\n\t *\n\t * @system\n\t */\n\texport type DeepReadonlyRecursion<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tRecurseLimit extends RecursionLimit,\n\t\tTAncestorTypes = T /* Always start with self as ancestor; otherwise recursion limit appears one greater */,\n\t> = T extends TAncestorTypes\n\t\t? RecurseLimit extends `+${infer RecursionRemainder}`\n\t\t\t? /* Now that specific recursion is found, process that recursive type\n\t\t\t directly to avoid any collateral damage from ancestor type that\n\t\t\t required modification. */\n\t\t\t\tDeepReadonlyLimitingRecursion<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\tRecursionRemainder extends RecursionLimit ? RecursionRemainder : 0\n\t\t\t\t>\n\t\t\t: T\n\t\t: DeepReadonlyWorker<T, DeepenedGenerics, RecurseLimit, TAncestorTypes | T>;\n\n\t/**\n\t * Core implementation of {@link InternalUtilityTypes.DeepReadonlyLimitingRecursion}.\n\t *\n\t * @system\n\t */\n\texport type DeepReadonlyWorker<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tRecurseLimit extends RecursionLimit,\n\t\tTAncestorTypes = T /* Always start with self as ancestor; otherwise recursion limit appears one greater */,\n\t> = /* test for object */ T extends object\n\t\t? /* object => */ FilterPreservingFunction<\n\t\t\t\tT,\n\t\t\t\tDeepenReadonlyInGenerics<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\tRecurseLimit,\n\t\t\t\t\tPreserveErasedTypeOrBrandedPrimitive<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\t/* basic type => */ {\n\t\t\t\t\t\t\treadonly [K in keyof T]: DeepReadonlyRecursion<\n\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\t\t\tRecurseLimit,\n\t\t\t\t\t\t\t\tTAncestorTypes\n\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t\t>\n\t\t: /* not an object => */ T;\n\n\t// #endregion\n\t// #endregion\n}\n"]}
1
+ {"version":3,"file":"exposedInternalUtilityTypes.js","sourceRoot":"","sources":["../src/exposedInternalUtilityTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH;;GAEG;AACH,MAAM,qBAAqB,GAAkB,MAAM,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @rushstack/no-new-null */\n\nimport type { ErasedType } from \"./erasedType.js\";\nimport type { IFluidHandle } from \"./handles.js\";\nimport type {\n\tSerializationErrorPerNonPublicProperties,\n\tSerializationErrorPerUndefinedArrayElement,\n} from \"./jsonSerializationErrors.js\";\nimport type { JsonTypeWith, NonNullJsonObjectWith, ReadonlyJsonTypeWith } from \"./jsonType.js\";\nimport type { OpaqueJsonDeserialized, OpaqueJsonSerializable } from \"./opaqueJson.js\";\n\n/**\n * Unique symbol for recursion meta-typing.\n */\nconst RecursionMarkerSymbol: unique symbol = Symbol(\"recursion here\");\n\n/**\n * Union of types that {@link DeepReadonly} and {@link ShallowReadonly}\n * recognize to generate immutable form and optionally can alter their\n * type parameters.\n *\n * @privateRemarks\n * WeakRef should be added when lib is updated to ES2021 or later.\n *\n * @beta\n */\nexport type ReadonlySupportedGenerics =\n\t| IFluidHandle\n\t| Map<unknown, unknown>\n\t| Promise<unknown>\n\t| Set<unknown>\n\t| WeakMap<object, unknown>\n\t| WeakSet<object>;\n\n/**\n * Limit on processing recursive types.\n * Use of `\"NoLimit\"` may result in error:\n * \"ts(2589): Type instantiation is excessively deep and possibly infinite\".\n * In such cases, use string literal with some prefix series of `+`\n * characters. The length of `+` character sequence indicates the recursion\n * depth limit when a recursive type is found. Use of `0` will stop applying\n * `DeepReadonly` at the first point recursion is detected.\n *\n * @beta\n * @system\n */\nexport type DeepReadonlyRecursionLimit = \"NoLimit\" | 0 | `+${string}`;\n\n/**\n * Collection of utility types that are not intended to be used/imported\n * directly outside of this package.\n *\n * @privateRemarks\n * There are ony three intentional exports from this module:\n * - {@link InternalUtilityTypes.IfSameType | IfSameType}\n * - {@link InternalUtilityTypes.JsonDeserializedImpl | JsonDeserializedImpl }\n * - {@link InternalUtilityTypes.JsonSerializableImpl | JsonSerializableImpl }\n *\n * api-extractor will allow `export` to be removed from others but generates\n * api-report a little oddly with a rogue `{};` floating at end of namespace\n * in api.md file. It will promote all of the support types to appear as\n * exported anyway. All in namespace are left exported to avoid api-extractor\n * potentially failing to validate other modules correctly.\n *\n * @beta\n * @system\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace InternalUtilityTypes {\n\t/**\n\t * Meta-type for controlling filtering utilities.\n\t *\n\t * @system\n\t */\n\texport interface FilterControls {\n\t\t/**\n\t\t * Tuple of exact types that are managed by custom serialization/deserialization\n\t\t * logic (beyond JSON.stringify and JSON.parse without replacers/revivers).\n\t\t * Only exact types matching specification will be preserved unaltered.\n\t\t */\n\t\tAllowExactly: unknown[];\n\n\t\t/**\n\t\t * General types that are managed by custom serialization/deserialization\n\t\t * logic (beyond JSON.stringify and JSON.parse without replacers/revivers).\n\t\t * Any type satisfying specification will be preserved unaltered.\n\t\t */\n\t\tAllowExtensionOf: unknown;\n\t}\n\n\t/**\n\t * Meta-type for controlling filtering utilities that additionally supplies\n\t * a substitute type for degenerate cases.\n\t *\n\t * @system\n\t */\n\tinterface FilterControlsWithSubstitution extends FilterControls {\n\t\t/**\n\t\t * Type to use for degenerate cases like `unknown` or `any`.\n\t\t * Typically this will be `JsonTypeWith<TupleToUnion<AllowExactly> | AllowExtensionOf>`.\n\t\t */\n\t\tDegenerateSubstitute: unknown;\n\t}\n\n\t/**\n\t * Meta-type for controlling deserialized filtering utilities.\n\t *\n\t * @system\n\t */\n\tinterface DeserializedFilterControls extends FilterControlsWithSubstitution {\n\t\t/**\n\t\t * Type to use for degenerate `object` case.\n\t\t * Typically this will be `NonNullJsonObjectWith<TupleToUnion<AllowExactly> | AllowExtensionOf>`.\n\t\t */\n\t\tDegenerateNonNullObjectSubstitute: unknown;\n\t}\n\n\t/**\n\t * Returns non-symbol keys for optional properties of an object type.\n\t * This excludes indexed properties that are inherently _optional_.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as OptionalNonSymbolKeysOf<T, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type OptionalNonSymbolKeysOf<\n\t\tT extends object,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: T extends Record<K, T[K]> ? never : K;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Returns non-symbol keys for required properties of an object type.\n\t * This includes indexed properties that are inherently _optional_.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as RequiredNonSymbolKeysOf<T, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type RequiredNonSymbolKeysOf<\n\t\tT extends object,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: T extends Record<K, T[K]> ? K : never;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Returns Result.WhenSomethingDeserializable if T is sometimes at least a\n\t * partially deserializable type, otherwise Result.WhenNeverDeserializable.\n\t * Fully not deserializable (bigints, symbols, undefined and functions without\n\t * other properties less overlap with T*Exception) produce Result.WhenNeverDeserializable.\n\t * An object would have a defined result even if parts of its content are\n\t * not deserializable.\n\t *\n\t * @param Result - Result type with two properties. One property must always\n\t * be `never` as `T` maybe a union of never deserializable and at least\n\t * partially deserializable types and the result is a union of Result.*.\n\t *\n\t * @privateRemarks\n\t * If `Result.WhenSomethingDeserializable` was `true` and\n\t * `Result.WhenNeverDeserializable` was `false`, then the return type\n\t * for type `T` would be `boolean` for a sometimes deserializable type.\n\t *\n\t * @system\n\t */\n\texport type TestDeserializabilityOf<\n\t\tT,\n\t\tTExactExceptions extends unknown[],\n\t\tTExtendsException,\n\t\tResult extends\n\t\t\t| { WhenSomethingDeserializable: unknown; WhenNeverDeserializable: never }\n\t\t\t| { WhenSomethingDeserializable: never; WhenNeverDeserializable: unknown },\n\t> = /* ensure working with more than never */ T extends never\n\t\t? /* never => */ Result[\"WhenNeverDeserializable\"]\n\t\t: /* check for extends exception */ T extends TExtendsException\n\t\t\t? /* extends exception => */ Result[\"WhenSomethingDeserializable\"]\n\t\t\t: /* no extends exception => check for exact exception */ IfExactTypeInTuple<\n\t\t\t\t\tT,\n\t\t\t\t\tTExactExceptions,\n\t\t\t\t\t/* exact exception => */ Result[\"WhenSomethingDeserializable\"],\n\t\t\t\t\t/* no exception => check for only non-serializable value types */ T extends\n\t\t\t\t\t\t| bigint\n\t\t\t\t\t\t| symbol\n\t\t\t\t\t\t| undefined\n\t\t\t\t\t\t? /* not serializable => */ Result[\"WhenNeverDeserializable\"]\n\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\tT extends Function\n\t\t\t\t\t\t\t? ExtractFunctionFromIntersection<T> extends {\n\t\t\t\t\t\t\t\t\tclassification: \"exactly Function\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t? /* not serializable => */ Result[\"WhenNeverDeserializable\"]\n\t\t\t\t\t\t\t\t: /* at least partially serializable */ Result[\"WhenSomethingDeserializable\"]\n\t\t\t\t\t\t\t: /* at least partially serializable */ Result[\"WhenSomethingDeserializable\"]\n\t\t\t\t>;\n\n\t/**\n\t * Similar to `Exclude` but only excludes exact `U`s from `T`\n\t * rather than any type that extends `U`.\n\t *\n\t * @system\n\t */\n\texport type ExcludeExactly<T, U> = IfSameType<T, U, never, T>;\n\n\t/**\n\t * Similar to `Exclude` but only excludes exact members of `U` from `T`\n\t * rather than any type that extends members of `U`.\n\t *\n\t * @system\n\t */\n\texport type ExcludeExactlyInTuple<T, TupleOfU extends unknown[]> = IfExactTypeInTuple<\n\t\tT,\n\t\tTupleOfU,\n\t\tnever,\n\t\tT\n\t>;\n\n\t/**\n\t * Similar to `Omit` but operates on tuples.\n\t * Removes elements of `Tuple` that extend `U`.\n\t *\n\t * @system\n\t */\n\texport type OmitFromTuple<\n\t\tTuple extends unknown[],\n\t\tU,\n\t\tAccumulated extends unknown[] = [],\n\t> = Tuple extends [infer First, ...infer Rest]\n\t\t? OmitFromTuple<Rest, U, First extends U ? Accumulated : [...Accumulated, First]>\n\t\t: Accumulated;\n\n\t/**\n\t * Similar to `OmitFromTuple` but removes only exact matches of U.\n\t * Removes elements of `Tuple` that are exactly `U`.\n\t *\n\t * @remarks If `U` is a union, then only exactly matching union elements of `Tuple` are removed.\n\t * @system\n\t */\n\texport type OmitExactlyFromTuple<\n\t\tTuple extends unknown[],\n\t\tU,\n\t\tAccumulated extends unknown[] = [],\n\t> = Tuple extends [infer First, ...infer Rest]\n\t\t? OmitExactlyFromTuple<Rest, U, IfSameType<First, U, Accumulated, [...Accumulated, First]>>\n\t\t: Accumulated;\n\n\t/**\n\t * Returns non-symbol keys for defined, (likely) serializable properties of an\n\t * object type. Keys with fully unsupported properties (undefined, symbol, and\n\t * bigint) and sometimes unsupported (functions) are excluded. An exception to\n\t * that is when there are supported types in union with just bigint.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as NonSymbolWithDeserializablePropertyOf<T, [], never, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type NonSymbolWithDeserializablePropertyOf<\n\t\tT extends object,\n\t\tTExactExceptions extends unknown[],\n\t\tTExtendsException,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: /* all possible types that aren't already allowed, with the exception of `unknown` */\n\t\t\tExcludeExactlyInTuple<\n\t\t\t\tExclude<T[K], TExtendsException>,\n\t\t\t\tOmitExactlyFromTuple<TExactExceptions, unknown>\n\t\t\t> extends infer PossibleTypeLessAllowed\n\t\t\t\t? IfSameType<\n\t\t\t\t\t\tPossibleTypeLessAllowed,\n\t\t\t\t\t\tunknown,\n\t\t\t\t\t\t/* value might not be supported => exclude K */ never,\n\t\t\t\t\t\t/* extract types that might lead to missing property */ Extract<\n\t\t\t\t\t\t\tPossibleTypeLessAllowed,\n\t\t\t\t\t\t\t/* types that might lead to missing property, except `bigint` */\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\tundefined | symbol | Function\n\t\t\t\t\t\t> extends never\n\t\t\t\t\t\t\t? /* all types are supported plus possibly `bigint` => */\n\t\t\t\t\t\t\t\t/* check for only `bigint` remaining */ IfSameType<\n\t\t\t\t\t\t\t\t\tPossibleTypeLessAllowed,\n\t\t\t\t\t\t\t\t\tbigint,\n\t\t\t\t\t\t\t\t\t/* only `bigint` => nothing supported */ never,\n\t\t\t\t\t\t\t\t\t/* exclusively supported types (and maybe `bigint`) or exactly `never` */\n\t\t\t\t\t\t\t\t\t/* => check for `never` */ T[K] extends never ? never : K\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t: /* value might not be supported => exclude K */ never\n\t\t\t\t\t>\n\t\t\t\t: never;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Returns non-symbol keys for partially supported properties of an object type.\n\t * Keys with only unsupported properties (undefined, symbol, bigint, and\n\t * functions without other properties) are excluded.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as NonSymbolWithPossiblyDeserializablePropertyOf<T, [], never, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type NonSymbolWithPossiblyDeserializablePropertyOf<\n\t\tT extends object,\n\t\tTExactExceptions extends unknown[],\n\t\tTExtendsException,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: /* all possible types that aren't already allowed, with the exception of `unknown` */\n\t\t\tExcludeExactlyInTuple<\n\t\t\t\tExclude<T[K], TExtendsException>,\n\t\t\t\tOmitExactlyFromTuple<TExactExceptions, unknown>\n\t\t\t> extends infer PossibleTypeLessAllowed\n\t\t\t\t? Extract<\n\t\t\t\t\t\tIfSameType<PossibleTypeLessAllowed, unknown, undefined, PossibleTypeLessAllowed>,\n\t\t\t\t\t\t/* types that might lead to missing property */\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\tundefined | symbol | Function\n\t\t\t\t\t> extends never\n\t\t\t\t\t? /* exclusively supported types or exactly `never` */ never\n\t\t\t\t\t: /* at least some unsupported type => check for any supported */ TestDeserializabilityOf<\n\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\tOmitExactlyFromTuple<TExactExceptions, unknown>,\n\t\t\t\t\t\t\tTExtendsException,\n\t\t\t\t\t\t\t{ WhenSomethingDeserializable: K; WhenNeverDeserializable: never }\n\t\t\t\t\t\t>\n\t\t\t\t: never;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Filters a type `T` for `undefined` that is not viable in an array (or tuple) that\n\t * must go through JSON serialization.\n\t * If `T` is `undefined`, then error type {@link SerializationErrorPerUndefinedArrayElement}\n\t * is returned with hopes of being informative.\n\t *\n\t * @system\n\t */\n\texport type JsonForSerializableArrayItem<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tTAncestorTypes extends unknown[],\n\t\tTBlessed,\n\t> = /* Some initial filtering must be provided before a test for undefined. */\n\t/* These tests are expected to match those in JsonSerializableImpl. */\n\t/* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ TBlessed\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ TBlessed\n\t\t\t: /* test for exact recursion */ IfExactTypeInTuple<\n\t\t\t\t\tT,\n\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t/* recursion; stop here => */ T,\n\t\t\t\t\t/* test for JSON primitive types or given alternative */ T extends\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t| number\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t\t? /* primitive types or alternative => */ T\n\t\t\t\t\t\t: /* test for exact alternative */ IfExactTypeInTuple<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t/* test for undefined possibility */ undefined extends T\n\t\t\t\t\t\t\t\t\t? /* undefined | ... => */ SerializationErrorPerUndefinedArrayElement\n\t\t\t\t\t\t\t\t\t: TBlessed\n\t\t\t\t\t\t\t>\n\t\t\t\t>;\n\n\t/**\n\t * Filters a type `T` for types that become null through JSON serialization.\n\t *\n\t * @system\n\t */\n\texport type JsonForDeserializedArrayItem<\n\t\tT,\n\t\tControls extends DeserializedFilterControls,\n\t\tTBlessed,\n\t> = /* Some initial filtering must be provided before a test for undefined, symbol, or function. */\n\t/* These tests are expected to match those in JsonDeserializedImpl. */\n\t/* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ TBlessed\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ TBlessed\n\t\t\t: /* test for JSON primitive types or general alternative */ T extends\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t| number\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t? /* primitive or replaced types => */ T\n\t\t\t\t: /* test for exact alternative */ IfExactTypeInTuple<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t/* exactly replaced => */ T,\n\t\t\t\t\t\t/* test for known types that become null */ T extends undefined | symbol\n\t\t\t\t\t\t\t? /* => */ null\n\t\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\t\tT extends Function\n\t\t\t\t\t\t\t\t? ExtractFunctionFromIntersection<T> extends {\n\t\t\t\t\t\t\t\t\t\tclassification: \"exactly Function\";\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t: null | TBlessed\n\t\t\t\t\t\t\t\t: TBlessed\n\t\t\t\t\t>;\n\n\t/**\n\t * Checks for a type that is simple class of number and string indexed types to numbers and strings.\n\t *\n\t * @system\n\t */\n\texport type IfEnumLike<\n\t\tT extends object,\n\t\tEnumLike = never,\n\t\tNotEnumLike = unknown,\n\t> = T extends readonly (infer _)[]\n\t\t? /* array => */ NotEnumLike\n\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\tT extends Function\n\t\t\t? /* function => */ NotEnumLike\n\t\t\t: T extends {\n\t\t\t\t\t\t// all numerical indices should refer to a string\n\t\t\t\t\t\treadonly [i: number]: string;\n\t\t\t\t\t\t// string indices may be string or number\n\t\t\t\t\t\treadonly [p: string]: number | string;\n\t\t\t\t\t\t// no symbol indices are allowed\n\t\t\t\t\t\treadonly [s: symbol]: never;\n\t\t\t\t\t}\n\t\t\t\t? /* test for a never or any property */ true extends {\n\t\t\t\t\t\t[K in keyof T]: T[K] extends never ? true : never;\n\t\t\t\t\t}[keyof T]\n\t\t\t\t\t? NotEnumLike\n\t\t\t\t\t: EnumLike\n\t\t\t\t: NotEnumLike;\n\n\t/**\n\t * Test for type equality\n\t *\n\t * @returns IfSame if identical and IfDifferent otherwise.\n\t *\n\t * Implementation derived from https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650\n\t *\n\t * @remarks Use caution when one of the type might be `{}`. That type is\n\t * special and produces unexpected results. This includes variability\n\t * on past usages.\n\t *\n\t * @system\n\t */\n\texport type IfSameType<X, Y, IfSame = unknown, IfDifferent = never> = (<T>() => T extends X\n\t\t? 1\n\t\t: 2) extends <T>() => T extends Y ? 1 : 2\n\t\t? IfSame\n\t\t: IfDifferent;\n\n\t/**\n\t * Test for type equality with tuple of other types.\n\t *\n\t * @typeParam T - Type to find in Tuple.\n\t * @typeParam Tuple - Tuple of types to test against.\n\t * @typeParam IfMatch - Type to return if match is found.\n\t * @typeParam IfNoMatch - Type to return if no match is found.\n\t *\n\t * @privateRemarks\n\t * Tests for an exact match of `T` in `Tuple[0]`. If not found,\n\t * recurses with the remainder of the tuple.\n\t */\n\texport type IfExactTypeInTuple<\n\t\tT,\n\t\tTuple extends unknown[],\n\t\tIfMatch = unknown,\n\t\tIfNoMatch = never,\n\t> = Tuple extends [infer First, ...infer Rest]\n\t\t? IfSameType<T, First, IfMatch, IfExactTypeInTuple<T, Rest, IfMatch, IfNoMatch>>\n\t\t: IfNoMatch;\n\n\t/**\n\t * Test for type equality with union of other types.\n\t *\n\t * @typeParam T - Type to find in Union. If this is itself a union, then all types must be found in Union.\n\t * @typeParam Union - Union of types to test against.\n\t * @typeParam IfMatch - Type to return if match is found.\n\t * @typeParam IfNoMatch - Type to return if no match is found.\n\t *\n\t * @remarks\n\t * In a recursive context, use {@link InternalUtilityTypes.IfExactTypeInTuple} to manage ancestry.\n\t *\n\t * @privateRemarks\n\t * Perhaps it is a Typescript defect but a simple check that `T` is `never`\n\t * via `T extends never` does not work as expected in this context.\n\t * Workaround using `IfSameType<..., never,...>`.\n\t * @system\n\t */\n\texport type IfExactTypeInUnion<T, Union, IfMatch = unknown, IfNoMatch = never> = IfSameType<\n\t\tT,\n\t\tnever,\n\t\t/* T is never => */ IfSameType<Union, never, IfMatch, IfNoMatch>,\n\t\t/* T is NOT never => */ IfSameType<T, Extract<Union, T>, IfMatch, IfNoMatch>\n\t>;\n\n\t/**\n\t * Test for type equality\n\t *\n\t * @returns `true` if identical and `false` otherwise.\n\t *\n\t * @remarks Use caution when one of the type might be `{}`. That type is\n\t * special and produces unexpected results. This includes variability\n\t * on past usages.\n\t *\n\t * @system\n\t */\n\texport type IsSameType<X, Y> = IfSameType<X, Y, true, false>;\n\n\t/**\n\t * Checks that type is exactly `object`.\n\t *\n\t * @system\n\t */\n\texport type IsExactlyObject<T extends object> = IsSameType<T, object>;\n\n\t/**\n\t * Any Record type.\n\t *\n\t * @system\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- `any` for property types is required to avoid \"Index signature for type 'string' is missing in type\" in some outside `FlattenIntersection` uses.\n\texport type AnyRecord = Record<keyof any, any>;\n\n\t/**\n\t * Creates a simple object type from an intersection of multiple.\n\t * @privateRemarks\n\t * `T extends AnyRecord` within the implementation encourages tsc to process\n\t * intersections within unions.\n\t *\n\t * @system\n\t */\n\texport type FlattenIntersection<T extends AnyRecord> = T extends AnyRecord\n\t\t? {\n\t\t\t\t[K in keyof T]: T[K];\n\t\t\t}\n\t\t: T;\n\n\t/**\n\t * Convenience constraint for any Opaque Json type.\n\t *\n\t * @remarks\n\t * Use in extends check: `T extends AnyOpaqueJsonType`\n\t *\n\t * @system\n\t */\n\texport type AnyOpaqueJsonType =\n\t\t/* eslint-disable @typescript-eslint/no-explicit-any -- must use `any` for invariant constraint override */\n\t\t| OpaqueJsonSerializable<unknown, any, unknown>\n\t\t| OpaqueJsonDeserialized<unknown, any, unknown>;\n\t/* eslint-enable @typescript-eslint/no-explicit-any */\n\n\t/**\n\t * Extracts Function portion from an intersection (&) type returning\n\t * the extracted portion in the `function` property or `unknown` if\n\t * no function is found.\n\t * The returned `classification` property has one of three values:\n\t * - \"no Function\" if the type is not a function.\n\t * - \"exactly Function\" if the type is exactly a function.\n\t * - \"Function and more\" if the type is a function and has other properties.\n\t *\n\t * @system\n\t */\n\texport type ExtractFunctionFromIntersection<T extends object> = (T extends new (\n\t\t...args: infer A\n\t) => infer R\n\t\t? new (\n\t\t\t\t...args: A\n\t\t\t) => R\n\t\t: unknown) &\n\t\t(T extends (...args: infer A) => infer R\n\t\t\t? (...args: A) => R\n\t\t\t: unknown) extends infer Functional\n\t\t? {\n\t\t\t\tclassification: unknown extends Functional\n\t\t\t\t\t? \"no Function\"\n\t\t\t\t\t: Functional extends Required<T>\n\t\t\t\t\t\t? \"exactly Function\"\n\t\t\t\t\t\t: \"Function and more\";\n\t\t\t\tfunction: Functional;\n\t\t\t}\n\t\t: never;\n\n\t/**\n\t * Returns `Filtered` & any Function intersection from `Original`.\n\t * If `Original` is exactly a Function, then `Filtered` is left out\n\t * under the assumption that it is not useful/applicable.\n\t *\n\t * @system\n\t */\n\texport type FilterPreservingFunction<\n\t\tOriginal extends object,\n\t\tFiltered,\n\t> = ExtractFunctionFromIntersection<Original> extends {\n\t\tclassification: infer TClassification;\n\t\tfunction: infer TFunction;\n\t}\n\t\t? TClassification extends \"exactly Function\"\n\t\t\t? TFunction\n\t\t\t: TFunction & Filtered\n\t\t: never;\n\n\t/**\n\t * Replaces any instance where a type T recurses into itself or a portion of\n\t * itself with TRecursionMarker.\n\t *\n\t * @typeParam T - Type to process.\n\t * @typeParam TRecursionMarker - Replacement marker type.\n\t * @typeParam Controls - Allowances are preserved as-is.\n\t * @typeParam TAncestorTypes - Tuple of types that are ancestors of T.\n\t * @typeParam TNextAncestor - Set exactly to T. This is passed separately\n\t * such that T union types remain intact as exact ancestors.\n\t *\n\t * @remarks\n\t * Filtering applied to class instances with non-public properties will not\n\t * preserve the class instance unless those classes are known and listed as\n\t * allowances via `Controls`.\n\t *\n\t * @privateRemarks\n\t * This implementation handles functions including function with properties.\n\t * There are no known cases where replacing recursion under such types make\n\t * a difference. Either the function (whole type) is allowed by the Json\n\t * filters or function is not allowed at all.\n\t * If the function portion is found to be problematic later, then could use\n\t * `T extends Function ? T : ...` to ignore function objects.\n\t *\n\t * @system\n\t */\n\texport type ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\tT,\n\t\tTRecursionMarker,\n\t\tControls extends FilterControls,\n\t\tTAncestorTypes extends unknown[] = [],\n\t\tTNextAncestor = T,\n\t> = /* test for recursion */\n\tIfExactTypeInTuple<T, TAncestorTypes, true, \"no match\"> extends true\n\t\t? /* recursion => use replacement */ TRecursionMarker\n\t\t: /* force union separation hereafter */ T extends infer _\n\t\t\t? /* test for recursion among union elements */\n\t\t\t\tIfExactTypeInTuple<T, TAncestorTypes, true, \"no match\"> extends true\n\t\t\t\t? TRecursionMarker\n\t\t\t\t: /* test for general allowance */ T extends Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t? /* allowed extension type => */ T\n\t\t\t\t\t: /* test for exact allowance */ IfExactTypeInTuple<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t\t\t> extends true\n\t\t\t\t\t\t? /* exact allowed type => */ T\n\t\t\t\t\t\t: T extends object\n\t\t\t\t\t\t\t? FilterPreservingFunction<\n\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t[K in keyof T]: ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\tTRecursionMarker,\n\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t: /* non-object => T as is */ T\n\t\t\t: never;\n\n\t/**\n\t * Replaces any instances of \"allowed\" types and recursion within with `never`.\n\t *\n\t * @typeParam T - Type to process.\n\t * @typeParam Controls - Allowances to replace.\n\t * @typeParam TAncestorTypes - Tuple of types that are ancestors of T.\n\t * @typeParam TNextAncestor - Set exactly to T. This is passed separately\n\t * such that T union types remain intact as exact ancestors.\n\t *\n\t * @system\n\t */\n\texport type ReplaceAllowancesAndRecursionWithNever<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tTAncestorTypes extends unknown[] = [],\n\t\tTNextAncestor = T,\n\t> = /* test for exact recursion first */ IfExactTypeInTuple<\n\t\tT,\n\t\tTAncestorTypes,\n\t\ttrue,\n\t\t\"no match\"\n\t> extends true\n\t\t? /* recursion => */ never\n\t\t: /* test for general allowance (also forces union separation) */ T extends Controls[\"AllowExtensionOf\"]\n\t\t\t? /* allowed extension type => */ never\n\t\t\t: /* test for exact allowance */ IfExactTypeInTuple<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t> extends true\n\t\t\t\t? /* exact allowed type => */ never\n\t\t\t\t: /* test for recursion among union elements */ IfExactTypeInTuple<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t\t> extends true\n\t\t\t\t\t? /* recursion => */ never\n\t\t\t\t\t: T extends object\n\t\t\t\t\t\t? FilterPreservingFunction<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t[K in keyof T]: ReplaceAllowancesAndRecursionWithNever<\n\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t: /* non-object => T as is */ T;\n\n\t/**\n\t * Test for non-public properties (which can only exist on class instance types).\n\t *\n\t * Returns `HasNonPublic` if `T` deeply may contain a private or protected field\n\t * and `OnlyPublics` otherwise.\n\t *\n\t * @remarks\n\t * Compare original (unprocessed) to filtered case that has `never` where\n\t * recursing or where allowed exception types are used.\n\t *\n\t * Note that this a test of the type and not the actual data. So, if an\n\t * interface is given as `T` where implemented by a class, any private or\n\t * protected fields within the class will not be detected.\n\t *\n\t * @system\n\t */\n\texport type IfNonPublicProperties<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tHasNonPublic = never,\n\t\tOnlyPublics = unknown,\n\t> = ReplaceAllowancesAndRecursionWithNever<T, Controls> extends T\n\t\t? OnlyPublics\n\t\t: HasNonPublic;\n\n\t/**\n\t * Union of all types in a tuple.\n\t *\n\t * @system\n\t */\n\texport type TupleToUnion<T extends unknown[]> = T[number];\n\n\t// #region JsonSerializable implementation\n\n\t/**\n\t * Outer implementation of {@link JsonSerializable} handling meta cases\n\t * like classes (with non-public properties).\n\t *\n\t * @system\n\t */\n\texport type JsonSerializableImpl<\n\t\tT,\n\t\tOptions extends Partial<FilterControls> & {\n\t\t\tIgnoreInaccessibleMembers?: \"ignore-inaccessible-members\";\n\t\t},\n\t\tTAncestorTypes extends unknown[] = [],\n\t\tTNextAncestor = T,\n\t> = /* Build Controls from Options filling in defaults for any missing properties */\n\t{\n\t\tAllowExactly: Options extends { AllowExactly: unknown[] } ? Options[\"AllowExactly\"] : [];\n\t\tAllowExtensionOf: Options extends { AllowExtensionOf: unknown }\n\t\t\t? Options[\"AllowExtensionOf\"]\n\t\t\t: never;\n\t\t// The Substitute type could be extracted to helper type, but is kept explicit here\n\t\t// to make JsonTypeWith and OpaqueJsonSerializable show explicitly in results for\n\t\t// users, rather than either the helper type name or a partially unrolled version.\n\t\tDegenerateSubstitute:\n\t\t\t| JsonTypeWith<\n\t\t\t\t\t| (Options extends { AllowExactly: unknown[] }\n\t\t\t\t\t\t\t? TupleToUnion<Options[\"AllowExactly\"]>\n\t\t\t\t\t\t\t: never)\n\t\t\t\t\t| (Options extends { AllowExtensionOf: unknown }\n\t\t\t\t\t\t\t? Options[\"AllowExtensionOf\"]\n\t\t\t\t\t\t\t: never)\n\t\t\t >\n\t\t\t| OpaqueJsonSerializable<\n\t\t\t\t\tunknown,\n\t\t\t\t\tOptions extends { AllowExactly: unknown[] } ? Options[\"AllowExactly\"] : [],\n\t\t\t\t\tOptions extends { AllowExtensionOf: unknown } ? Options[\"AllowExtensionOf\"] : never\n\t\t\t >;\n\t} extends infer Controls\n\t\t? /* Controls should always satisfy FilterControlsWithSubstitution, but Typescript wants a check */\n\t\t\tControls extends FilterControlsWithSubstitution\n\t\t\t? /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t\t\t? /* 'any' => */ Controls[\"DegenerateSubstitute\"]\n\t\t\t\t: Options[\"IgnoreInaccessibleMembers\"] extends \"ignore-inaccessible-members\"\n\t\t\t\t\t? JsonSerializableFilter<T, Controls, TAncestorTypes, TNextAncestor>\n\t\t\t\t\t: /* test for non-public properties (class instance type) */\n\t\t\t\t\t\tIfNonPublicProperties<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tAllowExactly: Controls[\"AllowExactly\"];\n\t\t\t\t\t\t\t\t\tAllowExtensionOf:\n\t\t\t\t\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t\t\t\t\t\t// Add in primitives that may be branded to ignore intersection classes\n\t\t\t\t\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t\t\t\t\t| number\n\t\t\t\t\t\t\t\t\t\t| string\n\t\t\t\t\t\t\t\t\t\t// Add in Opaque Json types\n\t\t\t\t\t\t\t\t\t\t| AnyOpaqueJsonType;\n\t\t\t\t\t\t\t\t\tDegenerateSubstitute: Controls[\"DegenerateSubstitute\"];\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\"found non-publics\",\n\t\t\t\t\t\t\t\t\"only publics\"\n\t\t\t\t\t\t\t> extends \"found non-publics\"\n\t\t\t\t\t\t? /* hidden props => test if it is array properties that are the problem */ T extends readonly (infer _)[]\n\t\t\t\t\t\t\t? /* array => */ {\n\t\t\t\t\t\t\t\t\t/* use homomorphic mapped type to preserve tuple type */\n\t\t\t\t\t\t\t\t\t[K in keyof T]: JsonSerializableImpl<\n\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: /* test for potentially branded primitive (intersection with a supported primitive) */\n\t\t\t\t\t\t\t\tT extends boolean | number | string\n\t\t\t\t\t\t\t\t? /* assume intersection is branding and allow as-is => */ T\n\t\t\t\t\t\t\t\t: /* not array => error */ SerializationErrorPerNonPublicProperties\n\t\t\t\t\t\t: /* no hidden properties => apply filtering => */ JsonSerializableFilter<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\t\t\tTNextAncestor\n\t\t\t\t\t\t\t>\n\t\t\t: never /* FilterControlsWithSubstitution assert else; should never be reached */\n\t\t: never /* unreachable else for infer */;\n\n\t/**\n\t * Handle Opaque Json types for {@link JsonSerializable}.\n\t *\n\t * @remarks\n\t * {@link OpaqueJsonSerializable} and {@link OpaqueJsonDeserialized} instances\n\t * are limited to `Controls` given context supports.\n\t * `T` from the original Opaque type is preserved. In the case that this now\n\t * produces an improper type such as a `bigint` being let through that is no\n\t * longer supported, then the variance of `Controls` is expected to raise\n\t * the incompatibility error.\n\t *\n\t * @privateRemarks\n\t * Additional intersections beyond {@link OpaqueJsonSerializable},\n\t * {@link OpaqueJsonDeserialized}, or intersected matching opaque pair are\n\t * not correctly filtered as need is not expected.\n\t *\n\t * @system\n\t */\n\texport type JsonSerializableOpaqueAllowances<\n\t\tT extends AnyOpaqueJsonType,\n\t\tControls extends FilterControlsWithSubstitution,\n\t> = /* eslint-disable @typescript-eslint/no-explicit-any -- must use `any` for invariant constraint override */\n\t/* infer underlying data type */ T extends\n\t\t| OpaqueJsonSerializable<infer TData, any, unknown>\n\t\t| OpaqueJsonDeserialized<infer TData, any, unknown>\n\t\t? T extends OpaqueJsonSerializable<TData, any, unknown> &\n\t\t\t\tOpaqueJsonDeserialized<TData, any, unknown>\n\t\t\t? OpaqueJsonSerializable<TData, Controls[\"AllowExactly\"], Controls[\"AllowExtensionOf\"]> &\n\t\t\t\t\tOpaqueJsonDeserialized<TData, Controls[\"AllowExactly\"], Controls[\"AllowExtensionOf\"]>\n\t\t\t: T extends OpaqueJsonSerializable<TData, any, unknown>\n\t\t\t\t? OpaqueJsonSerializable<TData, Controls[\"AllowExactly\"], Controls[\"AllowExtensionOf\"]>\n\t\t\t\t: T extends OpaqueJsonDeserialized<TData, any, unknown>\n\t\t\t\t\t? OpaqueJsonDeserialized<\n\t\t\t\t\t\t\tTData,\n\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\tControls[\"AllowExtensionOf\"]\n\t\t\t\t\t\t>\n\t\t\t\t\t: \"internal error: failed to determine Opaque Json type\"\n\t\t: never;\n\t/* eslint-enable @typescript-eslint/no-explicit-any */\n\n\t/**\n\t * Essentially a check for a template literal that has $\\{string\\} or\n\t * $\\{number\\} in the pattern. Just `string` and/or `number` also match.\n\t *\n\t * @remarks This works recursively looking at first elements when not\n\t * `string` or `number`. `first` will just be a single character if\n\t * not $\\{string\\} or $\\{number\\}.\n\t *\n\t * @system\n\t */\n\texport type IfIndexKey<T, IfIndex, IfLiteral> = `${string}` extends T\n\t\t? IfIndex\n\t\t: number extends T\n\t\t\t? IfIndex\n\t\t\t: T extends `${infer first}${infer rest}`\n\t\t\t\t? string extends first\n\t\t\t\t\t? IfIndex\n\t\t\t\t\t: `${number}` extends first\n\t\t\t\t\t\t? IfIndex\n\t\t\t\t\t\t: IfIndexKey<rest, IfIndex, IfLiteral>\n\t\t\t\t: IfLiteral;\n\n\t/**\n\t * Helper for {@link JsonSerializableFilter} to determine if a property may\n\t * be `undefined` and selects from options for result.\n\t * Since `unknown` is a superset of `undefined`, it is given a special case.\n\t * Additionally since index signatures are inherently optional, `unknown` typed\n\t * values are treated as not undefined (`Result[\"Otherwise\"]`).\n\t *\n\t * @system\n\t */\n\texport type IfPossiblyUndefinedProperty<\n\t\tTKey,\n\t\tTValue,\n\t\tResult extends {\n\t\t\tIfPossiblyUndefined: unknown;\n\t\t\tIfUnknownNonIndexed: unknown;\n\t\t\tOtherwise: unknown;\n\t\t},\n\t> = undefined extends TValue\n\t\t? unknown extends TValue\n\t\t\t? IfIndexKey<TKey, Result[\"Otherwise\"], Result[\"IfUnknownNonIndexed\"]>\n\t\t\t: Result[\"IfPossiblyUndefined\"]\n\t\t: Result[\"Otherwise\"];\n\n\t/**\n\t * Core implementation of {@link JsonSerializable}.\n\t *\n\t * @privateRemarks\n\t * Filtering through a single layer of recursion is all that is required\n\t * when using in prescribed filter scenario.\n\t *\n\t * @system\n\t */\n\texport type JsonSerializableFilter<\n\t\tT,\n\t\tControls extends FilterControlsWithSubstitution,\n\t\tTAncestorTypes extends unknown[],\n\t\tTNextAncestor = T,\n\t> = /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ Controls[\"DegenerateSubstitute\"]\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ Controls[\"DegenerateSubstitute\"]\n\t\t\t: /* test for recursion */ IfExactTypeInTuple<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t> extends true\n\t\t\t\t? /* exact recursion; stop here => */ T\n\t\t\t\t: /* test for JSON Encodable primitive types or given alternate base */ T extends\n\t\t\t\t\t\t\t| null\n\t\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t\t| number\n\t\t\t\t\t\t\t| string\n\t\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t? /* primitive types or alternate => */ T\n\t\t\t\t\t: /* test for exact alternate */ IfExactTypeInTuple<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t\t\t> extends true\n\t\t\t\t\t\t? /* exact alternate type => */ T\n\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\t/* test for not a function */ Extract<T, Function> extends never\n\t\t\t\t\t\t\t? /* not a function => test for object */ T extends object\n\t\t\t\t\t\t\t\t? /* object => test for array */ T extends readonly (infer _)[]\n\t\t\t\t\t\t\t\t\t? /* array => */ {\n\t\t\t\t\t\t\t\t\t\t\t/* array items may not not allow undefined */\n\t\t\t\t\t\t\t\t\t\t\t/* use homomorphic mapped type to preserve tuple type */\n\t\t\t\t\t\t\t\t\t\t\t[K in keyof T]: JsonForSerializableArrayItem<\n\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\t\t\t\t\t\t\tJsonSerializableFilter<\n\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: /* not an array => test for exactly `object` */ IsExactlyObject<T> extends true\n\t\t\t\t\t\t\t\t\t\t? /* `object` => */ NonNullJsonObjectWith<\n\t\t\t\t\t\t\t\t\t\t\t\tTupleToUnion<Controls[\"AllowExactly\"]> | Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t: /* test for enum like types */ IfEnumLike<T> extends never\n\t\t\t\t\t\t\t\t\t\t\t? /* enum or similar simple type (return as-is) => */ T\n\t\t\t\t\t\t\t\t\t\t\t: /* test for Opaque Json types */ T extends AnyOpaqueJsonType\n\t\t\t\t\t\t\t\t\t\t\t\t? /* Opaque Json type => */ JsonSerializableOpaqueAllowances<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t: /* property bag => */ FlattenIntersection<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* required properties are recursed and may not have undefined values. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as RequiredNonSymbolKeysOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>]-?: IfPossiblyUndefinedProperty<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tK,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIfPossiblyUndefined: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\"error required property may not allow `undefined` value\"]: never;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIfUnknownNonIndexed: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\"error required property may not allow `unknown` value\"]: never;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOtherwise: JsonSerializableFilter<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t} & {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* optional properties are recursed and, when exactOptionalPropertyTypes is\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t false, are allowed to preserve undefined value type. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as OptionalNonSymbolKeysOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>]?: JsonSerializableFilter<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t} & {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* symbol properties are rejected */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T & symbol]: never;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t: /* not an object => */ never\n\t\t\t\t\t\t\t: /* function => */ never;\n\n\t// #endregion\n\n\t/**\n\t * Sentinel type for use when marking points of recursion (in a recursive type).\n\t * Type is expected to be unique, though no lengths are taken to ensure that.\n\t *\n\t * @system\n\t */\n\texport interface RecursionMarker {\n\t\t[RecursionMarkerSymbol]: typeof RecursionMarkerSymbol;\n\t}\n\n\t/**\n\t * Recursion limit is the count of `+` that prefix it when string.\n\t *\n\t * @system\n\t */\n\texport type RecursionLimit = `+${string}` | 0;\n\n\t// #region JsonDeserialized implementation\n\n\t/**\n\t * Outer implementation of {@link JsonDeserialized} handling meta cases\n\t * like recursive types.\n\t *\n\t * @privateRemarks\n\t * This utility is reentrant and will process a type `T` up to `RecurseLimit`.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedImpl<\n\t\tT,\n\t\tOptions extends Partial<FilterControls>,\n\t\tRecurseLimit extends RecursionLimit = \"++++\" /* 4 */,\n\t> = /* Build Controls from Options filling in defaults for any missing properties */\n\t{\n\t\tAllowExactly: Options extends { AllowExactly: unknown[] } ? Options[\"AllowExactly\"] : [];\n\t\tAllowExtensionOf: Options extends { AllowExtensionOf: unknown }\n\t\t\t? Options[\"AllowExtensionOf\"]\n\t\t\t: never;\n\t\t// The Substitute types could be extracted to helper type, but are kept explicit here\n\t\t// to make JsonTypeWith/NonNullJsonObjectWith show explicitly in results for users, rather\n\t\t// than either the helper type name or a partially unrolled version.\n\t\tDegenerateSubstitute: JsonTypeWith<\n\t\t\t| (Options extends { AllowExactly: unknown[] }\n\t\t\t\t\t? TupleToUnion<Options[\"AllowExactly\"]>\n\t\t\t\t\t: never)\n\t\t\t| (Options extends { AllowExtensionOf: unknown } ? Options[\"AllowExtensionOf\"] : never)\n\t\t>;\n\t\tDegenerateNonNullObjectSubstitute: NonNullJsonObjectWith<\n\t\t\t| (Options extends { AllowExactly: unknown[] }\n\t\t\t\t\t? TupleToUnion<Options[\"AllowExactly\"]>\n\t\t\t\t\t: never)\n\t\t\t| (Options extends { AllowExtensionOf: unknown } ? Options[\"AllowExtensionOf\"] : never)\n\t\t>;\n\t} extends infer Controls\n\t\t? /* Controls should always satisfy DeserializedFilterControls, but Typescript wants a check */\n\t\t\tControls extends DeserializedFilterControls\n\t\t\t? /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t\t\t? /* 'any' => */ Controls[\"DegenerateSubstitute\"]\n\t\t\t\t: /* infer non-recursive version of T */ ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tRecursionMarker,\n\t\t\t\t\t\t\tControls\n\t\t\t\t\t\t> extends infer TNoRecursionAndOnlyPublics\n\t\t\t\t\t? /* test for no change from filtered type */ IsSameType<\n\t\t\t\t\t\t\tTNoRecursionAndOnlyPublics,\n\t\t\t\t\t\t\tJsonDeserializedFilter<\n\t\t\t\t\t\t\t\tTNoRecursionAndOnlyPublics,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tAllowExactly: [...Controls[\"AllowExactly\"], RecursionMarker];\n\t\t\t\t\t\t\t\t\tAllowExtensionOf: Controls[\"AllowExtensionOf\"];\n\t\t\t\t\t\t\t\t\tDegenerateSubstitute: Controls[\"DegenerateSubstitute\"];\n\t\t\t\t\t\t\t\t\tDegenerateNonNullObjectSubstitute: Controls[\"DegenerateNonNullObjectSubstitute\"];\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t> extends true\n\t\t\t\t\t\t? /* same (no filtering needed) => test for non-public\n\t\t\t\t\t\t properties (class instance type) */\n\t\t\t\t\t\t\tIfNonPublicProperties<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t// Note: no extra allowance is made here for possible branded\n\t\t\t\t\t\t\t\t// primitives as JsonDeserializedFilter will allow them as\n\t\t\t\t\t\t\t\t// extensions of the primitives. Should there need a need to\n\t\t\t\t\t\t\t\t// explicit allow them here, see JsonSerializableImpl's use.\n\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\"found non-publics\",\n\t\t\t\t\t\t\t\t\"only publics\"\n\t\t\t\t\t\t\t> extends \"found non-publics\"\n\t\t\t\t\t\t\t? /* hidden props => apply filtering to avoid retaining\n\t\t\t\t\t\t\t exact class except for any classes in allowances => */\n\t\t\t\t\t\t\t\tJsonDeserializedFilter<\n\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t// Note that use of RecurseLimit may not be needed here\n\t\t\t\t\t\t\t\t\t// could have an adverse effect on correctness if there\n\t\t\t\t\t\t\t\t\t// several ancestor types that require modification and\n\t\t\t\t\t\t\t\t\t// are peeling away the limit. In such a case, the limit\n\t\t\t\t\t\t\t\t\t// will be used for the problems and result is already\n\t\t\t\t\t\t\t\t\t// messy; so deferring full understanding of the problems\n\t\t\t\t\t\t\t\t\t// that could arise from a reset and being conservative.\n\t\t\t\t\t\t\t\t\tRecurseLimit\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t: /* no hidden properties => deserialized T is just T */\n\t\t\t\t\t\t\t\tT\n\t\t\t\t\t\t: /* filtering is needed => */ JsonDeserializedFilter<T, Controls, RecurseLimit>\n\t\t\t\t\t: /* unreachable else for infer */ never\n\t\t\t: never /* DeserializedFilterControls assert else; should never be reached */\n\t\t: never /* unreachable else for infer */;\n\n\t/**\n\t * Recurses `T` applying {@link InternalUtilityTypes.JsonDeserializedFilter} up to `RecurseLimit` times.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedRecursion<\n\t\tT,\n\t\tControls extends DeserializedFilterControls,\n\t\tRecurseLimit extends RecursionLimit,\n\t\tTAncestorTypes,\n\t> = T extends TAncestorTypes\n\t\t? RecurseLimit extends `+${infer RecursionRemainder}`\n\t\t\t? /* Now that specific recursion is found, process that recursive type\n\t\t\t directly to avoid any collateral damage from ancestor type that\n\t\t\t required modification. */\n\t\t\t\tJsonDeserializedImpl<\n\t\t\t\t\tT,\n\t\t\t\t\tControls,\n\t\t\t\t\tRecursionRemainder extends RecursionLimit ? RecursionRemainder : 0\n\t\t\t\t>\n\t\t\t: Controls[\"DegenerateSubstitute\"]\n\t\t: JsonDeserializedFilter<T, Controls, RecurseLimit, TAncestorTypes | T>;\n\n\t/**\n\t * Handle Opaque Json types for {@link JsonDeserialized}.\n\t *\n\t * @remarks\n\t * {@link OpaqueJsonSerializable} instances are converted to {@link OpaqueJsonDeserialized}.\n\t * The `AllowExactly` and `AllowExtensionOf` properties are set to match the given `Controls`.\n\t * The data type is kept exactly as-is to avoid processing in generic contexts that can't\n\t * produce a meaningful result. The data type should always be filtered through\n\t * {@link JsonDeserialized} when {@link OpaqueJsonDeserialized} is cracked open. So, really\n\t * the filtering is just deferred.\n\t *\n\t * @privateRemarks\n\t * Additional intersections beyond {@link OpaqueJsonSerializable},\n\t * {@link OpaqueJsonDeserialized}, or intersected matching opaque pair are\n\t * not correctly filtered as need is not expected.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedOpaqueConversion<\n\t\tT extends AnyOpaqueJsonType,\n\t\tControls extends FilterControls,\n\t> = /* eslint-disable @typescript-eslint/no-explicit-any -- must use `any` for invariant constraint override */\n\tT extends\n\t\t| OpaqueJsonSerializable<infer TData, any, unknown>\n\t\t| OpaqueJsonDeserialized<infer TData, any, unknown>\n\t\t? OpaqueJsonDeserialized<TData, Controls[\"AllowExactly\"], Controls[\"AllowExtensionOf\"]>\n\t\t: \"internal error: failed to determine Opaque Json type\";\n\t/* eslint-enable @typescript-eslint/no-explicit-any */\n\n\t/**\n\t * Core implementation of {@link JsonDeserialized}.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedFilter<\n\t\tT,\n\t\tControls extends DeserializedFilterControls,\n\t\tRecurseLimit extends RecursionLimit,\n\t\tTAncestorTypes = T /* Always start with self as ancestor; otherwise recursion limit appears one greater */,\n\t> = /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ Controls[\"DegenerateSubstitute\"]\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ Controls[\"DegenerateSubstitute\"]\n\t\t\t: /* test for deserializable primitive types or given alternate base */ T extends\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t| number\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t? /* primitive types or alternate => */ T\n\t\t\t\t: /* test for given exact alternate */ IfExactTypeInTuple<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\"not found\"\n\t\t\t\t\t\t> extends true\n\t\t\t\t\t? /* exact alternate type => */ T\n\t\t\t\t\t: /* test for object */ T extends object\n\t\t\t\t\t\t? /* object => */ ExtractFunctionFromIntersection<T> extends {\n\t\t\t\t\t\t\t\tclassification: \"exactly Function\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t? /* exactly function => */ never\n\t\t\t\t\t\t\t: /* not exactly a function (Function portion, if any, is omitted) */\n\t\t\t\t\t\t\t\t/* => test for array */ T extends readonly (infer _)[]\n\t\t\t\t\t\t\t\t? /* array => */ {\n\t\t\t\t\t\t\t\t\t\t/* array items may not not allow undefined */\n\t\t\t\t\t\t\t\t\t\t/* use homomorphic mapped type to preserve tuple type */\n\t\t\t\t\t\t\t\t\t\t[K in keyof T]: JsonForDeserializedArrayItem<\n\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\tJsonDeserializedRecursion<T[K], Controls, RecurseLimit, TAncestorTypes>\n\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: /* not an array => test for exactly `object` */ IsExactlyObject<T> extends true\n\t\t\t\t\t\t\t\t\t? /* `object` => */ Controls[\"DegenerateNonNullObjectSubstitute\"]\n\t\t\t\t\t\t\t\t\t: /* test for enum like types */ IfEnumLike<T> extends never\n\t\t\t\t\t\t\t\t\t\t? /* enum or similar simple type (return as-is) => */ T\n\t\t\t\t\t\t\t\t\t\t: /* test for matching Opaque Json types */ T extends AnyOpaqueJsonType\n\t\t\t\t\t\t\t\t\t\t\t? /* Opaque Json type => */ JsonDeserializedOpaqueConversion<T, Controls>\n\t\t\t\t\t\t\t\t\t\t\t: /* property bag => */ FlattenIntersection<\n\t\t\t\t\t\t\t\t\t\t\t\t\t/* properties with symbol keys or wholly unsupported values are removed */\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* properties with defined values are recursed */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as NonSymbolWithDeserializablePropertyOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExtensionOf\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>]: JsonDeserializedRecursion<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tRecurseLimit,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tTAncestorTypes\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t\t} & {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* properties that may have undefined values are optional */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as NonSymbolWithPossiblyDeserializablePropertyOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExtensionOf\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>]?: JsonDeserializedRecursion<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tRecurseLimit,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tTAncestorTypes\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t: /* not an object => */ never;\n\n\t// #endregion\n\n\t// #region *Readonly implementations\n\n\t/**\n\t * If `T` is a `Map<K,V>` or `ReadonlyMap<K,V>`, returns `ReadonlyMap` and,\n\t * if `T` extends `DeepenedGenerics`, {@link DeepReadonly} is applied to\n\t * `K` and `V` generics. `Else` is returned if not a generic map.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInMapIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends ReadonlyMap<infer K, infer V>\n\t\t? Map<K, V> extends DeepenedGenerics\n\t\t\t? ReadonlyMap<\n\t\t\t\t\tReadonlyImpl<K, DeepenedGenerics, NoDepthOrRecurseLimit>,\n\t\t\t\t\tReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>\n\t\t\t\t>\n\t\t\t: ReadonlyMap<K, V>\n\t\t: Else;\n\n\t/**\n\t * If `T` is a `Set<TSet>` or `ReadonlySet<TSet>`, returns `ReadonlySet` and,\n\t * if `T` extends `DeepenedGenerics`, {@link DeepReadonly} is applied to\n\t * `TSet` generic. `Else` is returned if not a generic set.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInSetIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends ReadonlySet<infer V>\n\t\t? Set<V> extends DeepenedGenerics\n\t\t\t? ReadonlySet<ReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>>\n\t\t\t: ReadonlySet<V>\n\t\t: Else;\n\n\t/**\n\t * If `T` is a `IFluidHandle<THandle>` and if `T` extends `DeepenedGenerics`,\n\t * {@link DeepReadonly} is applied to `THandle` generic.\n\t * `Else` is returned if not an `IFluidHandle`.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInFluidHandleIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends Readonly<IFluidHandle<infer V>>\n\t\t? IFluidHandle<V> extends DeepenedGenerics\n\t\t\t? Readonly<IFluidHandle<ReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>>>\n\t\t\t: Readonly<T>\n\t\t: Else;\n\n\t/**\n\t * If `T` is a `Promise<TPromise>` and if `T` extends `DeepenedGenerics`,\n\t * {@link DeepReadonly} is applied to `TPromise` generic.\n\t * `Else` is returned if not a `Promise`.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInPromiseIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends Promise<infer V>\n\t\t? Promise<V> extends DeepenedGenerics\n\t\t\t? Promise<ReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>>\n\t\t\t: T\n\t\t: Else;\n\n\t/**\n\t * If `T` is a `WeakMap<K,V>`, returns immutable `WeakMap` and,\n\t * if `T` extends `DeepenedGenerics`, {@link DeepReadonly} is applied to\n\t * `K` and `V` generics. `Else` is returned if not a generic map.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInWeakMapIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends Omit<WeakMap<infer K, infer V>, \"delete\" | \"set\">\n\t\t? WeakMap<K, V> extends DeepenedGenerics\n\t\t\t? Omit<\n\t\t\t\t\tWeakMap<\n\t\t\t\t\t\tReadonlyImpl<K, DeepenedGenerics, NoDepthOrRecurseLimit>,\n\t\t\t\t\t\tReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>\n\t\t\t\t\t>,\n\t\t\t\t\t\"delete\" | \"set\"\n\t\t\t\t>\n\t\t\t: Omit<WeakMap<K, V>, \"delete\" | \"set\">\n\t\t: Else;\n\n\t/**\n\t * If `T` is a `WeakSet<TSet>`, returns immutable `WeakSet` and,\n\t * if `T` extends `DeepenedGenerics`, {@link DeepReadonly} is applied to\n\t * `TSet` generic. `Else` is returned if not a generic weak set.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInWeakSetIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = T extends Omit<WeakSet<infer V>, \"add\" | \"delete\">\n\t\t? WeakSet<V> extends DeepenedGenerics\n\t\t\t? Omit<\n\t\t\t\t\tWeakSet<ReadonlyImpl<V, DeepenedGenerics, NoDepthOrRecurseLimit>>,\n\t\t\t\t\t\"add\" | \"delete\"\n\t\t\t\t>\n\t\t\t: Omit<WeakSet<V>, \"add\" | \"delete\">\n\t\t: Else;\n\n\t/**\n\t * If `T` is a {@link ReadonlySupportedGenerics}, `T` is returned as\n\t * its immutable version, and if `T` extends `DeepenedGenerics`,\n\t * {@link DeepReadonly} is applied to `T`s generics.\n\t *\n\t * @system\n\t */\n\texport type DeepenReadonlyInGenerics<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t\tElse,\n\t> = DeepenReadonlyInMapIfEnabled<\n\t\tT,\n\t\tDeepenedGenerics,\n\t\tNoDepthOrRecurseLimit,\n\t\tDeepenReadonlyInSetIfEnabled<\n\t\t\tT,\n\t\t\tDeepenedGenerics,\n\t\t\tNoDepthOrRecurseLimit,\n\t\t\tDeepenReadonlyInWeakMapIfEnabled<\n\t\t\t\tT,\n\t\t\t\tDeepenedGenerics,\n\t\t\t\tNoDepthOrRecurseLimit,\n\t\t\t\tDeepenReadonlyInWeakSetIfEnabled<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\tNoDepthOrRecurseLimit,\n\t\t\t\t\tDeepenReadonlyInPromiseIfEnabled<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\tNoDepthOrRecurseLimit,\n\t\t\t\t\t\tDeepenReadonlyInFluidHandleIfEnabled<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\t\tNoDepthOrRecurseLimit,\n\t\t\t\t\t\t\tElse\n\t\t\t\t\t\t>\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t\t>\n\t\t>\n\t>;\n\n\t/**\n\t * Returns an `ErasedType` or \"branded\" primitive type as-is, or `Else` if not.\n\t * @typeParam T - Type to test.\n\t * @typeParam Else - Type to return if not `ErasedType` or \"branded\" primitive.\n\t *\n\t * @system\n\t */\n\texport type PreserveErasedTypeOrBrandedPrimitive<\n\t\tT extends object,\n\t\tElse,\n\t> = /* Test for erased type */ T extends ErasedType<infer _>\n\t\t? /* erased type => keep as-is */ T\n\t\t: /* Test for branded primitive */ T extends infer Brand &\n\t\t\t\t\t(boolean | number | string | symbol | bigint)\n\t\t\t? // Should just return T here, but TypeScript appears to produce `never` when doing so.\n\t\t\t\t// Workaround by inferring the Primitive type and returning intersection with B.\n\t\t\t\tT extends Brand & infer Primitive\n\t\t\t\t? /* [potentially] branded type => \"as-is\" */ Primitive & Brand\n\t\t\t\t: /* Should never be reached */ T\n\t\t\t: Else;\n\n\t/**\n\t * De-multiplexing implementation of {@link DeepReadonly} and {@link ShallowReadonly}\n\t * selecting behavior based on `NoDepthOrRecurseLimit`.\n\t *\n\t * @privateRemarks\n\t * This utility is reentrant. Its importance is that other utilities common to\n\t * readonly transformation may use `NoDepthOrRecurseLimit` to return the the\n\t * same processing algorithm.\n\t *\n\t * @system\n\t */\n\texport type ReadonlyImpl<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends \"Shallow\" | DeepReadonlyRecursionLimit,\n\t> = /* test for no depth */ NoDepthOrRecurseLimit extends \"Shallow\"\n\t\t? /* no depth => */ ShallowReadonlyImpl<T, DeepenedGenerics>\n\t\t: /* test for no limit */ NoDepthOrRecurseLimit extends \"NoLimit\"\n\t\t\t? /* no limit => */ DeepReadonlyRecursingInfinitely<T, DeepenedGenerics>\n\t\t\t: /* limited */ DeepReadonlyLimitingRecursion<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\tExtract<NoDepthOrRecurseLimit, RecursionLimit>\n\t\t\t\t>;\n\n\t// #region ShallowReadonly implementation\n\n\t/**\n\t * Outer implementation of {@link ShallowReadonly}.\n\t *\n\t * @privateRemarks\n\t * This utility can be reentrant when generics are deepened.\n\t *\n\t * @system\n\t */\n\texport type ShallowReadonlyImpl<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t> = T extends object\n\t\t? /* object => */ FilterPreservingFunction<\n\t\t\t\tT,\n\t\t\t\tDeepenReadonlyInGenerics<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\"Shallow\",\n\t\t\t\t\tPreserveErasedTypeOrBrandedPrimitive<T, /* basic type => */ Readonly<T>>\n\t\t\t\t>\n\t\t\t>\n\t\t: /* not an object => */ T;\n\n\t// #endregion\n\n\t/**\n\t * Outer implementation of {@link DeepReadonly}.\n\t *\n\t * @privateRemarks\n\t * This utility is reentrant and will process a type `T` up to `RecurseLimit`.\n\t *\n\t * @system\n\t */\n\texport type DeepReadonlyImpl<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tRecurseLimit extends DeepReadonlyRecursionLimit,\n\t> = ReadonlyImpl<T, DeepenedGenerics, RecurseLimit>;\n\n\t// #region DeepReadonly infinite recursion implementation\n\n\t/**\n\t * Simple implementation of {@link DeepReadonly} that may handle limited recursive types.\n\t * In unhandled cases, TypeScript will produce:\n\t * ts(2589): Type instantiation is excessively deep and possibly infinite.\n\t *\n\t * @system\n\t */\n\texport type DeepReadonlyRecursingInfinitely<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t> = T extends object\n\t\t? /* object => */ FilterPreservingFunction<\n\t\t\t\tT,\n\t\t\t\t// test for array of known recursive type: JsonTypeWith\n\t\t\t\tT extends readonly ReadonlyJsonTypeWith<infer Alternates>[]\n\t\t\t\t\t? // Make sure this is exactly that case (many arrays will extend JsonTypeWith)\n\t\t\t\t\t\t// Note that `true extends IfExactTypeInTuple` is used over\n\t\t\t\t\t\t// if-else form as the else branch would be evaluated as input to\n\t\t\t\t\t\t// `IfExactTypeInTuple` and that could lead to infinite recursion.\n\t\t\t\t\t\ttrue extends IfExactTypeInTuple<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t[JsonTypeWith<Alternates>[], readonly ReadonlyJsonTypeWith<Alternates>[]]\n\t\t\t\t\t\t>\n\t\t\t\t\t\t? readonly ReadonlyJsonTypeWith<\n\t\t\t\t\t\t\t\tDeepReadonlyRecursingInfinitely<Alternates, DeepenedGenerics>\n\t\t\t\t\t\t\t>[]\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\treadonly [K in keyof T]: DeepReadonlyRecursingInfinitely<\n\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\tDeepenedGenerics\n\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t: /* not JSON array => */ DeepenReadonlyInGenerics<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\t\t\"NoLimit\",\n\t\t\t\t\t\t\tPreserveErasedTypeOrBrandedPrimitive<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t/* basic type => */ {\n\t\t\t\t\t\t\t\t\treadonly [K in keyof T]: DeepReadonlyRecursingInfinitely<\n\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\tDeepenedGenerics\n\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t>\n\t\t: /* not an object => */ T;\n\n\t// #endregion\n\t// #region DeepReadonly limited recursion implementation\n\n\t/**\n\t * Core implementation of {@link DeepReadonly} handling meta cases\n\t * like recursive types a limited number of times.\n\t *\n\t * @privateRemarks\n\t * This utility is reentrant and will process a type `T` up to `NoDepthOrRecurseLimit`.\n\t *\n\t * @system\n\t */\n\texport type DeepReadonlyLimitingRecursion<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tNoDepthOrRecurseLimit extends RecursionLimit,\n\t> = /* infer non-recursive version of T */ ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\tT,\n\t\tRecursionMarker,\n\t\t{ AllowExactly: []; AllowExtensionOf: never }\n\t> extends infer TNoRecursionAndOnlyPublics\n\t\t? /* test for no change from altered type (excluding non-publics) */ IsSameType<\n\t\t\t\tTNoRecursionAndOnlyPublics,\n\t\t\t\tDeepReadonlyWorker<TNoRecursionAndOnlyPublics, DeepenedGenerics, 0>\n\t\t\t> extends true\n\t\t\t? /* same (no filtering needed) => test for non-public properties (class instance type) */\n\t\t\t\tIfNonPublicProperties<\n\t\t\t\t\tT,\n\t\t\t\t\t// Note: no extra allowance is made here for possible branded\n\t\t\t\t\t// primitives as DeepReadonlyWorker will allow them as\n\t\t\t\t\t// extensions of the primitives. Should there need a need to\n\t\t\t\t\t// explicit allow them here, see JsonSerializableImpl's use.\n\t\t\t\t\t{ AllowExactly: []; AllowExtensionOf: never },\n\t\t\t\t\t\"found non-publics\",\n\t\t\t\t\t\"only publics\"\n\t\t\t\t> extends \"found non-publics\"\n\t\t\t\t? /* hidden props => apply filtering => */\n\t\t\t\t\tDeepReadonlyWorker<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\tExtract<NoDepthOrRecurseLimit, RecursionLimit>\n\t\t\t\t\t>\n\t\t\t\t: /* no hidden properties => readonly T is just T */\n\t\t\t\t\tT\n\t\t\t: /* filtering is needed => */ DeepReadonlyWorker<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\tExtract<NoDepthOrRecurseLimit, RecursionLimit>\n\t\t\t\t>\n\t\t: /* unreachable else for infer */ never;\n\n\t/**\n\t * Recurses `T` applying {@link InternalUtilityTypes.DeepReadonlyWorker} up to `RecurseLimit` times.\n\t *\n\t * @system\n\t */\n\texport type DeepReadonlyRecursion<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tRecurseLimit extends RecursionLimit,\n\t\tTAncestorTypes = T /* Always start with self as ancestor; otherwise recursion limit appears one greater */,\n\t> = T extends TAncestorTypes\n\t\t? RecurseLimit extends `+${infer RecursionRemainder}`\n\t\t\t? /* Now that specific recursion is found, process that recursive type\n\t\t\t directly to avoid any collateral damage from ancestor type that\n\t\t\t required modification. */\n\t\t\t\tDeepReadonlyLimitingRecursion<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\tRecursionRemainder extends RecursionLimit ? RecursionRemainder : 0\n\t\t\t\t>\n\t\t\t: T\n\t\t: DeepReadonlyWorker<T, DeepenedGenerics, RecurseLimit, TAncestorTypes | T>;\n\n\t/**\n\t * Core implementation of {@link InternalUtilityTypes.DeepReadonlyLimitingRecursion}.\n\t *\n\t * @system\n\t */\n\texport type DeepReadonlyWorker<\n\t\tT,\n\t\tDeepenedGenerics extends ReadonlySupportedGenerics,\n\t\tRecurseLimit extends RecursionLimit,\n\t\tTAncestorTypes = T /* Always start with self as ancestor; otherwise recursion limit appears one greater */,\n\t> = /* test for object */ T extends object\n\t\t? /* object => */ FilterPreservingFunction<\n\t\t\t\tT,\n\t\t\t\tDeepenReadonlyInGenerics<\n\t\t\t\t\tT,\n\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\tRecurseLimit,\n\t\t\t\t\tPreserveErasedTypeOrBrandedPrimitive<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\t/* basic type => */ {\n\t\t\t\t\t\t\treadonly [K in keyof T]: DeepReadonlyRecursion<\n\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\tDeepenedGenerics,\n\t\t\t\t\t\t\t\tRecurseLimit,\n\t\t\t\t\t\t\t\tTAncestorTypes\n\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t>\n\t\t\t>\n\t\t: /* not an object => */ T;\n\n\t// #endregion\n\t// #endregion\n}\n"]}
@@ -7,6 +7,7 @@ export type { JsonDeserialized, JsonDeserializedOptions } from "./jsonDeserializ
7
7
  export type { JsonSerializable, JsonSerializableOptions } from "./jsonSerializable.js";
8
8
  export type { SerializationErrorPerNonPublicProperties, SerializationErrorPerUndefinedArrayElement, } from "./jsonSerializationErrors.js";
9
9
  export type { JsonTypeWith, NonNullJsonObjectWith, ReadonlyJsonTypeWith, } from "./jsonType.js";
10
+ export type { OpaqueJsonDeserialized, OpaqueJsonSerializable } from "./opaqueJson.js";
10
11
  export type { ShallowReadonly } from "./shallowReadonly.js";
11
12
  export type { InternalUtilityTypes, ReadonlySupportedGenerics, } from "./exposedInternalUtilityTypes.js";
12
13
  //# sourceMappingURL=exposedUtilityTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exposedUtilityTypes.d.ts","sourceRoot":"","sources":["../src/exposedUtilityTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,YAAY,EACX,wCAAwC,EACxC,0CAA0C,GAC1C,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACX,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,YAAY,EACX,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"exposedUtilityTypes.d.ts","sourceRoot":"","sources":["../src/exposedUtilityTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,YAAY,EACX,wCAAwC,EACxC,0CAA0C,GAC1C,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACX,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACtF,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,YAAY,EACX,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,kCAAkC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"exposedUtilityTypes.js","sourceRoot":"","sources":["../src/exposedUtilityTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// Usage: Access these types via /internal/exposedUtilityTypes import spec when\n// system level but externally exposed version of utilities are needed.\n// Import via /internal when use is not exposed externally.\n// Should a customer need access to these types, export should be relocated to\n// index.ts and retagged export from internal.ts may be removed.\n\nexport type { DeepReadonly } from \"./deepReadonly.js\";\nexport type { JsonDeserialized, JsonDeserializedOptions } from \"./jsonDeserialized.js\";\nexport type { JsonSerializable, JsonSerializableOptions } from \"./jsonSerializable.js\";\nexport type {\n\tSerializationErrorPerNonPublicProperties,\n\tSerializationErrorPerUndefinedArrayElement,\n} from \"./jsonSerializationErrors.js\";\nexport type {\n\tJsonTypeWith,\n\tNonNullJsonObjectWith,\n\tReadonlyJsonTypeWith,\n} from \"./jsonType.js\";\nexport type { ShallowReadonly } from \"./shallowReadonly.js\";\n\nexport type {\n\tInternalUtilityTypes,\n\tReadonlySupportedGenerics,\n} from \"./exposedInternalUtilityTypes.js\";\n"]}
1
+ {"version":3,"file":"exposedUtilityTypes.js","sourceRoot":"","sources":["../src/exposedUtilityTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// Usage: Access these types via /internal/exposedUtilityTypes import spec when\n// system level but externally exposed version of utilities are needed.\n// Import via /internal when use is not exposed externally.\n// Should a customer need access to these types, export should be relocated to\n// index.ts and retagged export from internal.ts may be removed.\n\nexport type { DeepReadonly } from \"./deepReadonly.js\";\nexport type { JsonDeserialized, JsonDeserializedOptions } from \"./jsonDeserialized.js\";\nexport type { JsonSerializable, JsonSerializableOptions } from \"./jsonSerializable.js\";\nexport type {\n\tSerializationErrorPerNonPublicProperties,\n\tSerializationErrorPerUndefinedArrayElement,\n} from \"./jsonSerializationErrors.js\";\nexport type {\n\tJsonTypeWith,\n\tNonNullJsonObjectWith,\n\tReadonlyJsonTypeWith,\n} from \"./jsonType.js\";\nexport type { OpaqueJsonDeserialized, OpaqueJsonSerializable } from \"./opaqueJson.js\";\nexport type { ShallowReadonly } from \"./shallowReadonly.js\";\n\nexport type {\n\tInternalUtilityTypes,\n\tReadonlySupportedGenerics,\n} from \"./exposedInternalUtilityTypes.js\";\n"]}
package/lib/internal.d.ts CHANGED
@@ -3,11 +3,13 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export * from "./index.js";
6
+ export type { JsonTypeToOpaqueJson, OpaqueJsonToJsonType } from "./jsonUtils.js";
6
7
  import type { DeepReadonly as ExposedDeepReadonly } from "./deepReadonly.js";
7
8
  import type { InternalUtilityTypes as ExposedInternalUtilityTypes } from "./exposedInternalUtilityTypes.js";
8
9
  import type { JsonDeserialized as ExposedJsonDeserialized, JsonDeserializedOptions } from "./jsonDeserialized.js";
9
10
  import type { JsonSerializable as ExposedJsonSerializable, JsonSerializableOptions } from "./jsonSerializable.js";
10
11
  import type { JsonTypeWith as ExposedJsonTypeWith, ReadonlyNonNullJsonObjectWith as ExposedReadonlyNonNullJsonObjectWith } from "./jsonType.js";
12
+ import type { OpaqueJsonDeserialized as ExposedOpaqueJsonDeserialized, OpaqueJsonSerializable as ExposedOpaqueJsonSerializable } from "./opaqueJson.js";
11
13
  /**
12
14
  * @internal
13
15
  */
@@ -34,6 +36,14 @@ export type JsonTypeWith<T> = ExposedJsonTypeWith<T>;
34
36
  * @internal
35
37
  */
36
38
  export type ReadonlyNonNullJsonObjectWith<T> = ExposedReadonlyNonNullJsonObjectWith<T>;
39
+ /**
40
+ * @internal
41
+ */
42
+ export type OpaqueJsonDeserialized<T, Option_AllowExactly extends unknown[] = [], Option_AllowExtensionOf = never> = ExposedOpaqueJsonDeserialized<T, Option_AllowExactly, Option_AllowExtensionOf>;
43
+ /**
44
+ * @internal
45
+ */
46
+ export type OpaqueJsonSerializable<T, Option_AllowExactly extends unknown[] = [], Option_AllowExtensionOf = never> = ExposedOpaqueJsonSerializable<T, Option_AllowExactly, Option_AllowExtensionOf>;
37
47
  /**
38
48
  * @internal
39
49
  */
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,YAAY,CAAC;AAU3B,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,IAAI,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC5G,OAAO,KAAK,EACX,gBAAgB,IAAI,uBAAuB,EAC3C,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,gBAAgB,IAAI,uBAAuB,EAC3C,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,YAAY,IAAI,mBAAmB,EACnC,6BAA6B,IAAI,oCAAoC,EACrE,MAAM,eAAe,CAAC;AAOvB;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAC3B,CAAC,EACD,OAAO,SAAS,uBAAuB,GAAG;IACzC,YAAY,EAAE,EAAE,CAAC;IACjB,gBAAgB,EAAE,KAAK,CAAC;CACxB,IACE,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAC3B,CAAC,EACD,OAAO,SAAS,uBAAuB,GAAG;IACzC,YAAY,EAAE,EAAE,CAAC;IACjB,gBAAgB,EAAE,KAAK,CAAC;CACxB,IACE,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,6BAA6B,CAAC,CAAC,IAAI,oCAAoC,CAAC,CAAC,CAAC,CAAC;AAEvF;;GAEG;AAEH,yBAAiB,oBAAoB,CAAC;IAErC,KAAY,mBAAmB,CAAC,CAAC,SAAS,2BAA2B,CAAC,SAAS,IAC9E,2BAA2B,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;IACpD,KAAY,UAAU,CACrB,CAAC,EACD,CAAC,EACD,MAAM,GAAG,OAAO,EAChB,WAAW,GAAG,KAAK,IAChB,2BAA2B,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;CAEtE"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,YAAY,CAAC;AAM3B,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAMjF,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,IAAI,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC5G,OAAO,KAAK,EACX,gBAAgB,IAAI,uBAAuB,EAC3C,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,gBAAgB,IAAI,uBAAuB,EAC3C,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,YAAY,IAAI,mBAAmB,EACnC,6BAA6B,IAAI,oCAAoC,EACrE,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACX,sBAAsB,IAAI,6BAA6B,EACvD,sBAAsB,IAAI,6BAA6B,EACvD,MAAM,iBAAiB,CAAC;AAOzB;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAC3B,CAAC,EACD,OAAO,SAAS,uBAAuB,GAAG;IACzC,YAAY,EAAE,EAAE,CAAC;IACjB,gBAAgB,EAAE,KAAK,CAAC;CACxB,IACE,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAC3B,CAAC,EACD,OAAO,SAAS,uBAAuB,GAAG;IACzC,YAAY,EAAE,EAAE,CAAC;IACjB,gBAAgB,EAAE,KAAK,CAAC;CACxB,IACE,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,6BAA6B,CAAC,CAAC,IAAI,oCAAoC,CAAC,CAAC,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,sBAAsB,CACjC,CAAC,EACD,mBAAmB,SAAS,OAAO,EAAE,GAAG,EAAE,EAC1C,uBAAuB,GAAG,KAAK,IAC5B,6BAA6B,CAAC,CAAC,EAAE,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,sBAAsB,CACjC,CAAC,EACD,mBAAmB,SAAS,OAAO,EAAE,GAAG,EAAE,EAC1C,uBAAuB,GAAG,KAAK,IAC5B,6BAA6B,CAAC,CAAC,EAAE,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;AAEnF;;GAEG;AAEH,yBAAiB,oBAAoB,CAAC;IAErC,KAAY,mBAAmB,CAAC,CAAC,SAAS,2BAA2B,CAAC,SAAS,IAC9E,2BAA2B,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;IACpD,KAAY,UAAU,CACrB,CAAC,EACD,CAAC,EACD,MAAM,GAAG,OAAO,EAChB,WAAW,GAAG,KAAK,IAChB,2BAA2B,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;CAEtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gDAAgD;AAChD,cAAc,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line no-restricted-syntax\nexport * from \"./index.js\";\n\n// Important: all other exports must be type only exports. In package.json exports,\n// index.js is listed as the runtime file. This is done so that all imports are\n// using the same outer runtime file. (Could be changed if needed.)\n\n// Export set of utility types re-tagged as internal for FF client convenience.\n// These types are not intended for direct use by customers and api-extractor will\n// flag misuse. If an externally visible version of these types is needed, import\n// from via /internal/exposedUtilityTypes rather than /internal.\nimport type { DeepReadonly as ExposedDeepReadonly } from \"./deepReadonly.js\";\nimport type { InternalUtilityTypes as ExposedInternalUtilityTypes } from \"./exposedInternalUtilityTypes.js\";\nimport type {\n\tJsonDeserialized as ExposedJsonDeserialized,\n\tJsonDeserializedOptions,\n} from \"./jsonDeserialized.js\";\nimport type {\n\tJsonSerializable as ExposedJsonSerializable,\n\tJsonSerializableOptions,\n} from \"./jsonSerializable.js\";\nimport type {\n\tJsonTypeWith as ExposedJsonTypeWith,\n\tReadonlyNonNullJsonObjectWith as ExposedReadonlyNonNullJsonObjectWith,\n} from \"./jsonType.js\";\n\n// Note: There are no docs for these re-exports. `@inheritdoc` cannot be used as:\n// 1. api-extractor does not support renames.\n// 2. api-extractor does not support package paths. (\"Import paths are not supported\")\n// Also not useful, at least in VS Code, as substitution is not made in place.\n\n/**\n * @internal\n */\nexport type DeepReadonly<T> = ExposedDeepReadonly<T>;\n\n/**\n * @internal\n */\nexport type JsonDeserialized<\n\tT,\n\tOptions extends JsonDeserializedOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = ExposedJsonDeserialized<T, Options>;\n\n/**\n * @internal\n */\nexport type JsonSerializable<\n\tT,\n\tOptions extends JsonSerializableOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = ExposedJsonSerializable<T, Options>;\n\n/**\n * @internal\n */\nexport type JsonTypeWith<T> = ExposedJsonTypeWith<T>;\n\n/**\n * @internal\n */\nexport type ReadonlyNonNullJsonObjectWith<T> = ExposedReadonlyNonNullJsonObjectWith<T>;\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace InternalUtilityTypes {\n\t/* eslint-disable jsdoc/require-jsdoc */\n\texport type FlattenIntersection<T extends ExposedInternalUtilityTypes.AnyRecord> =\n\t\tExposedInternalUtilityTypes.FlattenIntersection<T>;\n\texport type IfSameType<\n\t\tX,\n\t\tY,\n\t\tIfSame = unknown,\n\t\tIfDifferent = never,\n\t> = ExposedInternalUtilityTypes.IfSameType<X, Y, IfSame, IfDifferent>;\n\t/* eslint-enable jsdoc/require-jsdoc */\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gDAAgD;AAChD,cAAc,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line no-restricted-syntax\nexport * from \"./index.js\";\n\n// Important: all other exports must be type only exports. In package.json exports,\n// index.js is listed as the runtime file. This is done so that all imports are\n// using the same outer runtime file. (Could be changed if needed.)\n\nexport type { JsonTypeToOpaqueJson, OpaqueJsonToJsonType } from \"./jsonUtils.js\";\n\n// Export set of utility types re-tagged as internal for FF client convenience.\n// These types are not intended for direct use by customers and api-extractor will\n// flag misuse. If an externally visible version of these types is needed, import\n// from via /internal/exposedUtilityTypes rather than /internal.\nimport type { DeepReadonly as ExposedDeepReadonly } from \"./deepReadonly.js\";\nimport type { InternalUtilityTypes as ExposedInternalUtilityTypes } from \"./exposedInternalUtilityTypes.js\";\nimport type {\n\tJsonDeserialized as ExposedJsonDeserialized,\n\tJsonDeserializedOptions,\n} from \"./jsonDeserialized.js\";\nimport type {\n\tJsonSerializable as ExposedJsonSerializable,\n\tJsonSerializableOptions,\n} from \"./jsonSerializable.js\";\nimport type {\n\tJsonTypeWith as ExposedJsonTypeWith,\n\tReadonlyNonNullJsonObjectWith as ExposedReadonlyNonNullJsonObjectWith,\n} from \"./jsonType.js\";\nimport type {\n\tOpaqueJsonDeserialized as ExposedOpaqueJsonDeserialized,\n\tOpaqueJsonSerializable as ExposedOpaqueJsonSerializable,\n} from \"./opaqueJson.js\";\n\n// Note: There are no docs for these re-exports. `@inheritdoc` cannot be used as:\n// 1. api-extractor does not support renames.\n// 2. api-extractor does not support package paths. (\"Import paths are not supported\")\n// Also not useful, at least in VS Code, as substitution is not made in place.\n\n/**\n * @internal\n */\nexport type DeepReadonly<T> = ExposedDeepReadonly<T>;\n\n/**\n * @internal\n */\nexport type JsonDeserialized<\n\tT,\n\tOptions extends JsonDeserializedOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = ExposedJsonDeserialized<T, Options>;\n\n/**\n * @internal\n */\nexport type JsonSerializable<\n\tT,\n\tOptions extends JsonSerializableOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = ExposedJsonSerializable<T, Options>;\n\n/**\n * @internal\n */\nexport type JsonTypeWith<T> = ExposedJsonTypeWith<T>;\n\n/**\n * @internal\n */\nexport type ReadonlyNonNullJsonObjectWith<T> = ExposedReadonlyNonNullJsonObjectWith<T>;\n\n/**\n * @internal\n */\nexport type OpaqueJsonDeserialized<\n\tT,\n\tOption_AllowExactly extends unknown[] = [],\n\tOption_AllowExtensionOf = never,\n> = ExposedOpaqueJsonDeserialized<T, Option_AllowExactly, Option_AllowExtensionOf>;\n\n/**\n * @internal\n */\nexport type OpaqueJsonSerializable<\n\tT,\n\tOption_AllowExactly extends unknown[] = [],\n\tOption_AllowExtensionOf = never,\n> = ExposedOpaqueJsonSerializable<T, Option_AllowExactly, Option_AllowExtensionOf>;\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace InternalUtilityTypes {\n\t/* eslint-disable jsdoc/require-jsdoc */\n\texport type FlattenIntersection<T extends ExposedInternalUtilityTypes.AnyRecord> =\n\t\tExposedInternalUtilityTypes.FlattenIntersection<T>;\n\texport type IfSameType<\n\t\tX,\n\t\tY,\n\t\tIfSame = unknown,\n\t\tIfDifferent = never,\n\t> = ExposedInternalUtilityTypes.IfSameType<X, Y, IfSame, IfDifferent>;\n\t/* eslint-enable jsdoc/require-jsdoc */\n}\n"]}
@@ -84,8 +84,8 @@ export interface JsonSerializableOptions {
84
84
  * Also, `JsonSerializable<T>` does not prevent the construction of circular references.
85
85
  *
86
86
  * Specifying `JsonSerializable<unknown>` or `JsonSerializable<any>` yields a type
87
- * alias for {@link JsonTypeWith}`<never>` and should not be used if precise type
88
- * safety is desired.
87
+ * alias for {@link JsonTypeWith}`<never>` | {@link OpaqueJsonSerializable}`<unknown>`
88
+ * and should not be used if precise type safety is desired.
89
89
  *
90
90
  * Class instances are indistinguishable from general objects by type checking
91
91
  * unless they have non-public members.
@@ -1 +1 @@
1
- {"version":3,"file":"jsonSerializable.js","sourceRoot":"","sources":["../src/jsonSerializable.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { InternalUtilityTypes } from \"./exposedInternalUtilityTypes.js\";\n\n/**\n * Options for {@link JsonSerializable}.\n *\n * @beta\n */\nexport interface JsonSerializableOptions {\n\t/**\n\t * Tuple of exact types that are managed by custom serialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n\t * without a replacer). Only exact types matching specification will be\n\t * preserved unaltered.\n\t *\n\t * The default value is `[]`.\n\t */\n\tAllowExactly?: unknown[];\n\n\t/**\n\t * General types that are managed by custom serialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n\t * without a replacer). Any type satisfying specification will be preserved\n\t * unaltered.\n\t *\n\t * The default value is `never`.\n\t */\n\tAllowExtensionOf?: unknown;\n\n\t/**\n\t * When set, inaccessible (protected and private) members throughout type T are\n\t * ignored as if not present.\n\t *\n\t * The default value is not present.\n\t */\n\tIgnoreInaccessibleMembers?: \"ignore-inaccessible-members\";\n}\n\n/**\n * Used to constrain a type `T` to types that are serializable as JSON\n * using {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n * (without a replacer) as base model.\n *\n * Under typical use a compile-time error is produced if `T` contains\n * non-JsonSerializable members.\n *\n * @typeParam T - The type to be constrained.\n * @typeParam Options - Options for the filter. See {@link JsonSerializableOptions}.\n *\n * @remarks\n * Before adding use of this utility type, consider using a utility like\n * {@link https://github.com/sinclairzx81/typebox#readme | TypeBox} that allows\n * for runtime validation.\n *\n * Note that this does NOT prevent use of values with non-JSON compatible data,\n * it only prevents using values with types that include non-JSON compatible data.\n * This means that one can, for example, pass in a value typed with JSON compatible\n * interface into this filter, that could actually be a class with lots on non-JSON\n * compatible fields and methods.\n *\n * Important: `T extends JsonSerializable<T>` is incorrect (does not even compile).\n *\n * The optional `Options.Allow*` parameters may be used to permit additional leaf types\n * to support situations where a `replacer` is used to handle special values (e.g.,\n * `JsonSerializable<{ x: IFluidHandle }, { AllowExtensionOf: IFluidHandle }>`).\n *\n * Note that `JsonSerializable<T>` does not protect against the following pitfalls\n * when serializing with JSON.stringify():\n *\n * - Non-finite numbers (`NaN`, `+/-Infinity`) are coerced to `null`.\n *\n * - Prototypes and non-enumerable properties are lost.\n *\n * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.\n *\n * - Getter and setters properties are lost. (Though appear supported.)\n *\n * - Functions with properties may be absent or the properties may be preserved\n * depending on the runtime typo of the value. (If built via Object.assign the\n * target member's type is preserved.) typeof =\\> 'function' is lost whereas when\n * typeof =\\> 'object' the properties are preserved.\n *\n * - Sparse arrays are filled with `null`.\n *\n * Also, `JsonSerializable<T>` does not prevent the construction of circular references.\n *\n * Specifying `JsonSerializable<unknown>` or `JsonSerializable<any>` yields a type\n * alias for {@link JsonTypeWith}`<never>` and should not be used if precise type\n * safety is desired.\n *\n * Class instances are indistinguishable from general objects by type checking\n * unless they have non-public members.\n *\n * - Unless `Option.IgnoreInaccessibleMembers` is used, types with non-public\n * members will result in {@link SerializationErrorPerNonPublicProperties}.\n * When `Option.IgnoreInaccessibleMembers` is `ignore-inaccessible-members`,\n * non-public (non-function) members are preserved without error, but they are\n * filtered away by the type filters and thus produce an incorrectly narrowed\n * type compared to actual data. Though such a result may be customer desired.\n *\n * - An exception is made for classes that are intersected with primitives\n * (specifically `boolean`, `number`, * and `string`). In these cases, it is\n * assumed that the class only exists as a type modifier and not as a value\n * at runtime, and thus the class is permitted as no serialization is required.\n *\n * Perhaps a https://github.com/microsoft/TypeScript/issues/22677 fix will\n * enable better support.\n *\n * @example Typical usage\n *\n * ```typescript\n * function foo<T>(value: JsonSerializable<T>) { ... }\n * ```\n *\n * @privateRemarks\n * Upon recursion, the original type T is preserved intact. This is done to prevent\n * infinite recursion and produces a technically incorrect result type. However, with\n * proper use, that will never be an issue as any filtering of types will happen\n * before T recursion.\n *\n * @beta\n */\nexport type JsonSerializable<\n\tT,\n\tOptions extends JsonSerializableOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = InternalUtilityTypes.JsonSerializableImpl<T, Options>;\n"]}
1
+ {"version":3,"file":"jsonSerializable.js","sourceRoot":"","sources":["../src/jsonSerializable.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { InternalUtilityTypes } from \"./exposedInternalUtilityTypes.js\";\n\n/**\n * Options for {@link JsonSerializable}.\n *\n * @beta\n */\nexport interface JsonSerializableOptions {\n\t/**\n\t * Tuple of exact types that are managed by custom serialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n\t * without a replacer). Only exact types matching specification will be\n\t * preserved unaltered.\n\t *\n\t * The default value is `[]`.\n\t */\n\tAllowExactly?: unknown[];\n\n\t/**\n\t * General types that are managed by custom serialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n\t * without a replacer). Any type satisfying specification will be preserved\n\t * unaltered.\n\t *\n\t * The default value is `never`.\n\t */\n\tAllowExtensionOf?: unknown;\n\n\t/**\n\t * When set, inaccessible (protected and private) members throughout type T are\n\t * ignored as if not present.\n\t *\n\t * The default value is not present.\n\t */\n\tIgnoreInaccessibleMembers?: \"ignore-inaccessible-members\";\n}\n\n/**\n * Used to constrain a type `T` to types that are serializable as JSON\n * using {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n * (without a replacer) as base model.\n *\n * Under typical use a compile-time error is produced if `T` contains\n * non-JsonSerializable members.\n *\n * @typeParam T - The type to be constrained.\n * @typeParam Options - Options for the filter. See {@link JsonSerializableOptions}.\n *\n * @remarks\n * Before adding use of this utility type, consider using a utility like\n * {@link https://github.com/sinclairzx81/typebox#readme | TypeBox} that allows\n * for runtime validation.\n *\n * Note that this does NOT prevent use of values with non-JSON compatible data,\n * it only prevents using values with types that include non-JSON compatible data.\n * This means that one can, for example, pass in a value typed with JSON compatible\n * interface into this filter, that could actually be a class with lots on non-JSON\n * compatible fields and methods.\n *\n * Important: `T extends JsonSerializable<T>` is incorrect (does not even compile).\n *\n * The optional `Options.Allow*` parameters may be used to permit additional leaf types\n * to support situations where a `replacer` is used to handle special values (e.g.,\n * `JsonSerializable<{ x: IFluidHandle }, { AllowExtensionOf: IFluidHandle }>`).\n *\n * Note that `JsonSerializable<T>` does not protect against the following pitfalls\n * when serializing with JSON.stringify():\n *\n * - Non-finite numbers (`NaN`, `+/-Infinity`) are coerced to `null`.\n *\n * - Prototypes and non-enumerable properties are lost.\n *\n * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.\n *\n * - Getter and setters properties are lost. (Though appear supported.)\n *\n * - Functions with properties may be absent or the properties may be preserved\n * depending on the runtime typo of the value. (If built via Object.assign the\n * target member's type is preserved.) typeof =\\> 'function' is lost whereas when\n * typeof =\\> 'object' the properties are preserved.\n *\n * - Sparse arrays are filled with `null`.\n *\n * Also, `JsonSerializable<T>` does not prevent the construction of circular references.\n *\n * Specifying `JsonSerializable<unknown>` or `JsonSerializable<any>` yields a type\n * alias for {@link JsonTypeWith}`<never>` | {@link OpaqueJsonSerializable}`<unknown>`\n * and should not be used if precise type safety is desired.\n *\n * Class instances are indistinguishable from general objects by type checking\n * unless they have non-public members.\n *\n * - Unless `Option.IgnoreInaccessibleMembers` is used, types with non-public\n * members will result in {@link SerializationErrorPerNonPublicProperties}.\n * When `Option.IgnoreInaccessibleMembers` is `ignore-inaccessible-members`,\n * non-public (non-function) members are preserved without error, but they are\n * filtered away by the type filters and thus produce an incorrectly narrowed\n * type compared to actual data. Though such a result may be customer desired.\n *\n * - An exception is made for classes that are intersected with primitives\n * (specifically `boolean`, `number`, * and `string`). In these cases, it is\n * assumed that the class only exists as a type modifier and not as a value\n * at runtime, and thus the class is permitted as no serialization is required.\n *\n * Perhaps a https://github.com/microsoft/TypeScript/issues/22677 fix will\n * enable better support.\n *\n * @example Typical usage\n *\n * ```typescript\n * function foo<T>(value: JsonSerializable<T>) { ... }\n * ```\n *\n * @privateRemarks\n * Upon recursion, the original type T is preserved intact. This is done to prevent\n * infinite recursion and produces a technically incorrect result type. However, with\n * proper use, that will never be an issue as any filtering of types will happen\n * before T recursion.\n *\n * @beta\n */\nexport type JsonSerializable<\n\tT,\n\tOptions extends JsonSerializableOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = InternalUtilityTypes.JsonSerializableImpl<T, Options>;\n"]}
@@ -0,0 +1,70 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { JsonDeserialized } from "./jsonDeserialized.js";
6
+ import type { JsonSerializable, JsonSerializableOptions } from "./jsonSerializable.js";
7
+ import type { OpaqueJsonDeserialized, OpaqueJsonSerializable } from "./opaqueJson.js";
8
+ /**
9
+ * Helper to return an Opaque Json type version of Json type
10
+ *
11
+ * @remarks
12
+ * To use this helper, create a helper function that filters type `T` through at
13
+ * least {@link JsonSerializable} and optionally {@link JsonDeserialized}. Then
14
+ * cast value through `unknown as JsonTypeToOpaqueJson<T, Options>`, where
15
+ * `Options` reflects the serialization capabilities of that area.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * function castToOpaqueJson<T>(value: JsonSerializable<T>): JsonTypeToOpaqueJson<T> {
20
+ * return value as unknown as JsonTypeToOpaqueJson<T>;
21
+ * }
22
+ * ```
23
+ *
24
+ * @internal
25
+ */
26
+ export type JsonTypeToOpaqueJson<T, Options extends JsonSerializableOptions = {
27
+ AllowExactly: [];
28
+ AllowExtensionOf: never;
29
+ }> = T extends JsonSerializable<T, Options> & JsonDeserialized<T, Options> ? OpaqueJsonSerializable<T, Options extends {
30
+ AllowExactly: unknown[];
31
+ } ? Options["AllowExactly"] : [], Options extends {
32
+ AllowExtensionOf: unknown;
33
+ } ? Options["AllowExtensionOf"] : never> & OpaqueJsonDeserialized<T, Options extends {
34
+ AllowExactly: unknown[];
35
+ } ? Options["AllowExactly"] : [], Options extends {
36
+ AllowExtensionOf: unknown;
37
+ } ? Options["AllowExtensionOf"] : never> : T extends JsonDeserialized<T, Options> ? OpaqueJsonDeserialized<T, Options extends {
38
+ AllowExactly: unknown[];
39
+ } ? Options["AllowExactly"] : [], Options extends {
40
+ AllowExtensionOf: unknown;
41
+ } ? Options["AllowExtensionOf"] : never> : T extends JsonSerializable<T, Options> ? OpaqueJsonSerializable<T, Options extends {
42
+ AllowExactly: unknown[];
43
+ } ? Options["AllowExactly"] : [], Options extends {
44
+ AllowExtensionOf: unknown;
45
+ } ? Options["AllowExtensionOf"] : never> : never;
46
+ /**
47
+ * Helper to extract Json type from an Opaque Json type
48
+ *
49
+ * @remarks
50
+ * This type only works with basic serialization capabilities (options).
51
+ * Attempts to make `Options` generic resulted in infinite recursion
52
+ * in TypeScript compiler that was not understood, so this type only
53
+ * supports TJson (value type) variance.
54
+ *
55
+ * To use this helper, create a helper function that accepts
56
+ * `OpaqueJsonSerializable<unknown> | OpaqueJsonDeserialized<unknown>`.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * function exposeFromOpaqueJson<TOpaque extends OpaqueJsonSerializable<unknown> | OpaqueJsonDeserialized<unknown>>(
61
+ * opaque: TOpaque,
62
+ * ): OpaqueJsonToJsonType<TOpaque> {
63
+ * return opaque as unknown as OpaqueJsonToJsonType<TOpaque>;
64
+ * }
65
+ * ```
66
+ *
67
+ * @internal
68
+ */
69
+ export type OpaqueJsonToJsonType<TOpaque extends OpaqueJsonSerializable<unknown> | OpaqueJsonDeserialized<unknown>> = TOpaque extends OpaqueJsonSerializable<infer TJson> & OpaqueJsonDeserialized<infer TJson> ? JsonSerializable<TJson> & JsonDeserialized<TJson> : TOpaque extends OpaqueJsonDeserialized<infer TJson> ? JsonDeserialized<TJson> : TOpaque extends OpaqueJsonSerializable<infer TJson> ? JsonSerializable<TJson> : never;
70
+ //# sourceMappingURL=jsonUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonUtils.d.ts","sourceRoot":"","sources":["../src/jsonUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEtF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,oBAAoB,CAC/B,CAAC,EACD,OAAO,SAAS,uBAAuB,GAAG;IACzC,YAAY,EAAE,EAAE,CAAC;IACjB,gBAAgB,EAAE,KAAK,CAAC;CACxB,IACE,CAAC,SAAS,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,GACtE,sBAAsB,CACtB,CAAC,EACD,OAAO,SAAS;IAAE,YAAY,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,EAC1E,OAAO,SAAS;IAAE,gBAAgB,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,KAAK,CACnF,GACA,sBAAsB,CACrB,CAAC,EACD,OAAO,SAAS;IAAE,YAAY,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,EAC1E,OAAO,SAAS;IAAE,gBAAgB,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,KAAK,CACnF,GACD,CAAC,SAAS,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,GACrC,sBAAsB,CACtB,CAAC,EACD,OAAO,SAAS;IAAE,YAAY,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,EAC1E,OAAO,SAAS;IAAE,gBAAgB,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,KAAK,CACnF,GACA,CAAC,SAAS,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,GACrC,sBAAsB,CACtB,CAAC,EACD,OAAO,SAAS;IAAE,YAAY,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,EAC1E,OAAO,SAAS;IAAE,gBAAgB,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,KAAK,CACnF,GACA,KAAK,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,oBAAoB,CAC/B,OAAO,SAAS,sBAAsB,CAAC,OAAO,CAAC,GAAG,sBAAsB,CAAC,OAAO,CAAC,IAC9E,OAAO,SAAS,sBAAsB,CAAC,MAAM,KAAK,CAAC,GAAG,sBAAsB,CAAC,MAAM,KAAK,CAAC,GAC1F,gBAAgB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,GACjD,OAAO,SAAS,sBAAsB,CAAC,MAAM,KAAK,CAAC,GAClD,gBAAgB,CAAC,KAAK,CAAC,GACvB,OAAO,SAAS,sBAAsB,CAAC,MAAM,KAAK,CAAC,GAClD,gBAAgB,CAAC,KAAK,CAAC,GACvB,KAAK,CAAC"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=jsonUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonUtils.js","sourceRoot":"","sources":["../src/jsonUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { JsonDeserialized } from \"./jsonDeserialized.js\";\nimport type { JsonSerializable, JsonSerializableOptions } from \"./jsonSerializable.js\";\nimport type { OpaqueJsonDeserialized, OpaqueJsonSerializable } from \"./opaqueJson.js\";\n\n/**\n * Helper to return an Opaque Json type version of Json type\n *\n * @remarks\n * To use this helper, create a helper function that filters type `T` through at\n * least {@link JsonSerializable} and optionally {@link JsonDeserialized}. Then\n * cast value through `unknown as JsonTypeToOpaqueJson<T, Options>`, where\n * `Options` reflects the serialization capabilities of that area.\n *\n * @example\n * ```ts\n * function castToOpaqueJson<T>(value: JsonSerializable<T>): JsonTypeToOpaqueJson<T> {\n * return value as unknown as JsonTypeToOpaqueJson<T>;\n * }\n * ```\n *\n * @internal\n */\nexport type JsonTypeToOpaqueJson<\n\tT,\n\tOptions extends JsonSerializableOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = T extends JsonSerializable<T, Options> & JsonDeserialized<T, Options>\n\t? OpaqueJsonSerializable<\n\t\t\tT,\n\t\t\tOptions extends { AllowExactly: unknown[] } ? Options[\"AllowExactly\"] : [],\n\t\t\tOptions extends { AllowExtensionOf: unknown } ? Options[\"AllowExtensionOf\"] : never\n\t\t> &\n\t\t\tOpaqueJsonDeserialized<\n\t\t\t\tT,\n\t\t\t\tOptions extends { AllowExactly: unknown[] } ? Options[\"AllowExactly\"] : [],\n\t\t\t\tOptions extends { AllowExtensionOf: unknown } ? Options[\"AllowExtensionOf\"] : never\n\t\t\t>\n\t: T extends JsonDeserialized<T, Options>\n\t\t? OpaqueJsonDeserialized<\n\t\t\t\tT,\n\t\t\t\tOptions extends { AllowExactly: unknown[] } ? Options[\"AllowExactly\"] : [],\n\t\t\t\tOptions extends { AllowExtensionOf: unknown } ? Options[\"AllowExtensionOf\"] : never\n\t\t\t>\n\t\t: T extends JsonSerializable<T, Options>\n\t\t\t? OpaqueJsonSerializable<\n\t\t\t\t\tT,\n\t\t\t\t\tOptions extends { AllowExactly: unknown[] } ? Options[\"AllowExactly\"] : [],\n\t\t\t\t\tOptions extends { AllowExtensionOf: unknown } ? Options[\"AllowExtensionOf\"] : never\n\t\t\t\t>\n\t\t\t: never;\n\n/**\n * Helper to extract Json type from an Opaque Json type\n *\n * @remarks\n * This type only works with basic serialization capabilities (options).\n * Attempts to make `Options` generic resulted in infinite recursion\n * in TypeScript compiler that was not understood, so this type only\n * supports TJson (value type) variance.\n *\n * To use this helper, create a helper function that accepts\n * `OpaqueJsonSerializable<unknown> | OpaqueJsonDeserialized<unknown>`.\n *\n * @example\n * ```ts\n * function exposeFromOpaqueJson<TOpaque extends OpaqueJsonSerializable<unknown> | OpaqueJsonDeserialized<unknown>>(\n *\t opaque: TOpaque,\n * ): OpaqueJsonToJsonType<TOpaque> {\n * return opaque as unknown as OpaqueJsonToJsonType<TOpaque>;\n * }\n * ```\n *\n * @internal\n */\nexport type OpaqueJsonToJsonType<\n\tTOpaque extends OpaqueJsonSerializable<unknown> | OpaqueJsonDeserialized<unknown>,\n> = TOpaque extends OpaqueJsonSerializable<infer TJson> & OpaqueJsonDeserialized<infer TJson>\n\t? JsonSerializable<TJson> & JsonDeserialized<TJson>\n\t: TOpaque extends OpaqueJsonDeserialized<infer TJson>\n\t\t? JsonDeserialized<TJson>\n\t\t: TOpaque extends OpaqueJsonSerializable<infer TJson>\n\t\t\t? JsonSerializable<TJson>\n\t\t\t: never;\n"]}