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

Function bindKeywords

ark/type/type.ts:393–404  ·  view source on GitHub ↗
(keywords: Dict, $: InternalScope)

Source from the content-addressed store, hash-verified

391
392/** what an ambient holds, each bound to `$` once it's read */
393const bindKeywords = (keywords: Dict, $: InternalScope): object => {
394 const bound = hasArkKind(keywords, "module") ? new RootModule({}) : {}
395 const resolve = (k: string) => {
396 const keyword = keywords[k]
397 if (hasArkKind(keyword, "module")) return bindKeywords(keyword, $)
398 const resolution = $.bindKw(keyword as BaseRoot | GenericRoot)
399 // a resolved scope has already compiled the nodes bound before it
400 return $.resolved ? finalizeExport($, resolution) : resolution
401 }
402 for (const k of Object.keys(keywords)) defineLazily(bound, k, resolve)
403 return bound
404}
405
406export type UnitTypeParser<$> = <const t>(value: t) => Type<t, $>
407

Callers 2

constructorMethod · 0.85
resolveFunction · 0.85

Calls 2

hasArkKindFunction · 0.90
defineLazilyFunction · 0.90

Tested by

no test coverage detected