{"record":{"id":"8d021401fbbcc5c6","repo":"can1357/oh-my-pi","slug":"unknown-alias-name","errorCode":null,"errorMessage":"unknown alias \"${name}\"","messagePattern":"unknown alias \"(.+?)\"","errorType":"exception","errorClass":"OmpTypeError","httpStatus":null,"severity":"error","filePath":"packages/omptype/src/type.ts","lineNumber":3910,"sourceCode":"\t\tReflect.set(schema, \"$\", scopeValue);\n\t\tReflect.set(schema, \"resolver\", resolve);\n\t\treturn schema;\n\t};\n\tconst parseScoped = (definition: unknown): InternalType =>\n\t\tbind(makeType(withScopeConfig(parseDef(definition, resolve)), EMPTY_STEPS, scopeMeta));\n\tconst scopedMatch = createMatchParser({\n\t\tparse: definition => parseScoped(definition) as unknown as BaseType,\n\t\tbranches: [],\n\t});\n\tconst scoped = Object.assign((definition: unknown) => parseScoped(definition), type, {\n\t\tfn: makeFn(resolve),\n\t\tmatch: scopedMatch,\n\t\t...naryStatics(resolve),\n\t}) as unknown as ScopedBuilder;\n\n\tconst targetFor = (name: string): IR => {\n\t\tconst resolved = resolve(name);\n\t\tif (resolved === undefined) throw new OmpTypeError(`unknown alias \"${name}\"`);\n\t\treturn resolved.k === \"alias\" ? resolved.resolve() : resolved;\n\t};\n\tconst schemaFor = (name: string): BaseType =>\n\t\tbind(makeType(withScopeConfig(targetFor(name)), EMPTY_STEPS, scopeMeta)) as unknown as BaseType;\n\n\tconst bindModule = (names: readonly string[]): RuntimeModule => {\n\t\tconst module = {} as RuntimeModule;\n\t\tObject.defineProperty(module, MODULE_SCOPE, { value: scopeValue });\n\t\tfor (const name of names) {\n\t\t\tconst entry = entries.get(name);\n\t\t\tif (entry === undefined) continue;\n\t\t\tif (entry.genericParameters !== undefined) {\n\t\t\t\tmodule[name] = genericFor(entry) as unknown as BaseType;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst definition = materialize(entry);\n\t\t\tmodule[name] = isRuntimeModule(definition) ? definition : schemaFor(name);\n\t\t}","sourceCodeStart":3892,"sourceCodeEnd":3928,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/omptype/src/type.ts#L3892-L3928","documentation":"When building a scope's module/builder surface, `targetFor(name)` resolves a requested alias name through the scope's resolver. If the name is not defined in the scope, resolution returns undefined and omptype throws `unknown alias`. This surfaces when accessing a type that the scope never declared.","triggerScenarios":"Accessing `myScope.type.Missing` or exporting a module for a name that is not a key in the scope's aliases; typos in scope keys vs. export lists; referencing an alias defined in a different scope without importing it.","commonSituations":"Refactoring scope keys without updating the exported module name list; case/typo mismatches (`UserId` vs `userId`); cross-scope references that were never added via `import`/`export` in the scope definition.","solutions":["Add the missing key to the scope's alias object.","Fix the typo/case in the name being accessed.","Use `scope.import`/`export` to bring in aliases defined in other scopes.","Enumerate the scope's available names (e.g. via the module exports) before accessing dynamically."],"exampleFix":"// before\nconst $ = type.scope({ user: \"string\" }); $.type.usr\n// after\nconst $ = type.scope({ user: \"string\" }); $.type.user","handlingStrategy":"try-catch","validationCode":"const aliasExists = ($: ScopedBuilder, name: string) => name in $.export;","typeGuard":null,"tryCatchPattern":"try { const t = scope.type[name as keyof typeof scope.type]; } catch (e) { if (e instanceof OmpTypeError && e.message.startsWith('unknown alias')) return null; throw e; }","preventionTips":["Drive dynamic access off the scope's exported module keys instead of hand-written name lists","Use TypeScript's inferred scope type (keyof) so missing names are caught at compile time","Import aliases from other scopes explicitly rather than assuming they are present"],"tags":["scope","alias","reference-error","schema"],"backgroundTag":"unknown-alias-reference","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}