( /** The set of names defined at the root-level of the scope mapped to their * corresponding definitions.**/ def: Record<string, unknown>, config?: ArkSchemaScopeConfig )
| 264 | readonly intrinsic: Omit<typeof $ark.intrinsic, `json${string}`> |
| 265 | |
| 266 | constructor( |
| 267 | /** The set of names defined at the root-level of the scope mapped to their |
| 268 | * corresponding definitions.**/ |
| 269 | def: Record<string, unknown>, |
| 270 | config?: ArkSchemaScopeConfig |
| 271 | ) { |
| 272 | this.config = mergeConfigs($ark.config, config) |
| 273 | |
| 274 | this.resolvedConfig = mergeConfigs($ark.resolvedConfig, config) |
| 275 | |
| 276 | this.name = |
| 277 | this.resolvedConfig.name ?? |
| 278 | `anonymousScope${Object.keys(scopesByName).length}` |
| 279 | if (this.name in scopesByName) |
| 280 | throwParseError(`A Scope already named ${this.name} already exists`) |
| 281 | scopesByName[this.name] = this |
| 282 | |
| 283 | const aliasEntries = Object.entries(def).map(entry => |
| 284 | this.preparseOwnAliasEntry(...entry) |
| 285 | ) |
| 286 | |
| 287 | for (const [k, v] of aliasEntries) { |
| 288 | let name = k |
| 289 | if (k[0] === "#") { |
| 290 | name = k.slice(1) |
| 291 | if (name in this.aliases) |
| 292 | throwParseError(writeDuplicateAliasError(name)) |
| 293 | this.aliases[name] = v |
| 294 | } else { |
| 295 | if (name in this.aliases) throwParseError(writeDuplicateAliasError(k)) |
| 296 | this.aliases[name] = v |
| 297 | this.exportedNames.push(name) |
| 298 | } |
| 299 | if ( |
| 300 | !hasArkKind(v, "module") && |
| 301 | !hasArkKind(v, "generic") && |
| 302 | !isThunk(v) |
| 303 | ) { |
| 304 | const preparsed = this.preparseOwnDefinitionFormat(v, { alias: name }) |
| 305 | this.resolutions[name] = |
| 306 | hasArkKind(preparsed, "root") ? |
| 307 | this.bindReference(preparsed) |
| 308 | : this.createParseContext(preparsed).id |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | // reduce union of all possible values reduces to unknown |
| 313 | rawUnknownUnion ??= this.node( |
| 314 | "union", |
| 315 | { |
| 316 | branches: [ |
| 317 | "string", |
| 318 | "number", |
| 319 | "object", |
| 320 | "bigint", |
| 321 | "symbol", |
| 322 | { unit: true }, |
| 323 | { unit: false }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…