{"record":{"id":"24a43f49d9be572f","repo":"can1357/oh-my-pi","slug":"alias-name-is-declared-as-both-public-and-pri","errorCode":null,"errorMessage":"alias \"${name}\" is declared as both public and private","messagePattern":"alias \"(.+?)\" is declared as both public and private","errorType":"exception","errorClass":"OmpTypeError","httpStatus":null,"severity":"error","filePath":"packages/omptype/src/type.ts","lineNumber":3791,"sourceCode":"\tmaterialized: boolean;\n}\n\nfunction isRuntimeModule(value: unknown): value is RuntimeModule {\n\treturn typeof value === \"object\" && value !== null && MODULE_SCOPE in value;\n}\n\nfunction buildScope(aliases: Record<string, unknown>, options?: ScopeOptions): TypeScope {\n\tconst scopeMeta: TypeMeta = options?.clone === undefined ? EMPTY_META : { clone: options.clone };\n\tconst withScopeConfig = (ir: IR): IR =>\n\t\toptions?.divisor === undefined ? ir : configureSelected(ir, options.divisor, { kind: \"divisor\" });\n\tconst entries = new Map<string, ScopeAlias>();\n\tfor (const sourceName in aliases) {\n\t\tconst isPrivate = sourceName.startsWith(\"#\");\n\t\tconst visibleName = isPrivate ? sourceName.slice(1) : sourceName;\n\t\tconst declaration = parseGenericDeclaration(visibleName);\n\t\tconst external = isRuntimeGeneric(aliases[sourceName]) ? aliases[sourceName] : undefined;\n\t\tconst name = declaration?.name ?? visibleName;\n\t\tif (entries.has(name)) throw new OmpTypeError(`alias \"${name}\" is declared as both public and private`);\n\t\tentries.set(name, {\n\t\t\tname,\n\t\t\tsourceName,\n\t\t\tprivate: isPrivate,\n\t\t\tgenericParameters: declaration?.parameters ?? external?.[GENERIC_META].parameters,\n\t\t\tdefinition: aliases[sourceName],\n\t\t\tgeneric: external,\n\t\t\tmaterialized: false,\n\t\t});\n\t}\n\n\tconst references = new Map<string, IR>();\n\tconst targets = new Map<string, IR>();\n\tlet scopeValue: TypeScope;\n\n\tconst materialize = (entry: ScopeAlias): unknown => {\n\t\tif (entry.materialized) return entry.definition;\n\t\tentry.materialized = true;","sourceCodeStart":3773,"sourceCodeEnd":3809,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/omptype/src/type.ts#L3773-L3809","documentation":"In a scope, every alias key maps to a canonical visible name (a leading `#` marks the alias private and is stripped). Two source keys that reduce to the same visible name — e.g. `\"foo\"` and `\"#foo\"` — collide, and omptype throws when building the scope's alias table.","triggerScenarios":"Defining a scope with both `{ \"foo\": ..., \"#foo\": ... }`, or constructing scope keys dynamically so one ends up with a `#` prefix duplicating an existing public alias.","commonSituations":"Merging alias maps from multiple modules where one exports a private variant and another a public one with the same name; template-driven scope generation that conditionally prefixes `#`.","solutions":["Delete the duplicate key from the aliases object passed to `type.scope`.","Rename one of the colliding aliases.","Normalize keys (strip/standardize `#` prefixes) before building the scope object when keys are dynamic."],"exampleFix":"// before\ntype.scope({ \"foo\": \"string\", \"#foo\": \"number\" })\n// after\ntype.scope({ \"foo\": \"string\", \"#bar\": \"number\" })","handlingStrategy":"validation","validationCode":"function hasAliasCollision(aliases: Record<string, unknown>) { const seen = new Set(); for (const k of Object.keys(aliases)) { const n = k.startsWith('#') ? k.slice(1) : k; if (seen.has(n)) return true; seen.add(n); } return false; }","typeGuard":null,"tryCatchPattern":"try { const $ = type.scope(aliases); } catch (e) { if (e instanceof OmpTypeError && e.message.includes('both public and private')) dedupeAliases(aliases); else throw e; }","preventionTips":["Strip '#' prefixes when merging alias maps from multiple sources and dedupe first","Do not conditionally add a '#' variant of an existing public alias","Keep private aliases in a separate namespace with distinct visible names"],"tags":["scope","alias","collision","schema"],"backgroundTag":"duplicate-alias-name","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}