MCPcopy Create free account
hub / github.com/arktypeio/arktype / withUndefined

Function withUndefined

ark/sets/structure/prop.ts:90–106  ·  view source on GitHub ↗
(value: BaseRoot)

Source from the content-addressed store, hash-verified

88
89/** an optional key or element's value without exactOptionalPropertyTypes, allowing undefined */
90export const withUndefined = (value: BaseRoot): BaseRoot => {
91 let result = valuesWithUndefined.get(value)
92 if (!result) {
93 result =
94 (
95 // an alias may not have resolved yet
96 !value.hasAlias &&
97 domainsOf(value) & unitBitsOf("undefined") &&
98 value.allowsUnused(undefined)
99 ) ?
100 value
101 : value.or($ark.kw.undefined)
102 // an alias's union is reduced again once it resolves
103 if (!value.hasAlias) valuesWithUndefined.set(value, result)
104 }
105 return result
106}
107
108export const writeDefaultIntersectionMessage = (
109 lValue: unknown,

Callers 2

widenFunction · 0.90
prop.tsFile · 0.85

Calls 5

domainsOfFunction · 0.90
unitBitsOfFunction · 0.90
orMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected