You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The inferred type of X cannot be named without a reference to ark/util when using Brand-Type #1577
The inferred type of 'GraphqlIdentifier' cannot be named without a reference to '.pnpm/@[email protected]/node_modules/@ark/util'. This is likely not portable. A type annotation is necessary.ts(2742)
Possible solutions are installing the EXACT same version and semver range as arktype uses from the locally installed package.
changed the title [-]The inferred type of X cannot be named without a reference to ark/util[/-][+]The inferred type of X cannot be named without a reference to ark/util when using Brand-Type[/+]on Jan 6, 2026
I'm facing the same issue, adding a comment for visibility.
I found a workaround:
type PlayerSlugBranded = string & { __brand: 'PlayerSlug' }
export const PlayerSlugSchema = type('string').pipe((val): PlayerSlugBranded => {
if (typeof val !== 'string') {
throw new Error(`Expected a string for PlayerSlug, got ${typeof val}`)
}
return val as PlayerSlugBranded
})
export type PlayerSlug = typeof PlayerSlugSchema.infer
For anyone having the general The inferred type of X cannot be named without a reference to error:
Fix
Declare the @ark/* packages ArkType depends on as direct deps of your package, pinned to the exact versions ArkType itself pins. ArkType uses "@ark/util": "0.56.0" (no ^) — your pin has to match, otherwise pnpm will install two copies.
# pnpm-workspace.yamlcatalog:
arktype: ^2.2.0# Pinned in lockstep with ArkType runtime deps — bump together.'@ark/util': 0.56.0'@ark/schema': 0.56.0
// package.json of any package whose public API leaks arktype-inferred types"dependencies": {
"arktype": "catalog:",
"@ark/util": "catalog:",
"@ark/schema": "catalog:"
}
After pnpm install, pnpm links node_modules/@ark/util directly into the consuming package, TS sees it as a direct dep, and the emitted .d.ts uses the bare specifier @ark/util — portable across installs.
What doesn't fix it
public-hoist-pattern[]=@ark/* in .npmrc alone. It makes the package resolvable at the workspace root, but TS still realpath-resolves the symlink into .pnpm/ during declaration emit unless @ark/* is a declared direct dep of the emitting package.
A type annotation on the specific declaration (: Type<...>) works locally but has to be repeated wherever the inferred type leaks — not scalable.
Local workaround if you can't change deps
Brand manually via .pipe, avoiding ArkType #Name brand syntax so the inferred type doesn't reach into @ark/util:
ArkType public types re-export symbols from @ark/util and @ark/schema (e.g. the brand-name machinery lives in @ark/util; ArkErrorCode in @ark/schema). When TypeScript emits the .d.ts for something whose inferred type unfolds into one of those symbols, it needs to name the source module. Since @ark/* aren't listed as direct deps of the emitting package, TS falls back to the shortest path it can find through node_modules — which under pnpm is the store path .pnpm/@[email protected]/…. That path pins a specific pnpm-layout and version slug, so TS correctly flags it as non-portable (TS2742 / TS2883).
Activity
[-]The inferred type of X cannot be named without a reference to ark/util[/-][+]The inferred type of X cannot be named without a reference to ark/util when using Brand-Type[/+]maximvl commentedon Apr 10, 2026
I'm facing the same issue, adding a comment for visibility.
I found a workaround:
mattidupre commentedon Apr 18, 2026
For anyone having the general
The inferred type of X cannot be named without a reference toerror:Fix
Declare the
@ark/*packages ArkType depends on as direct deps of your package, pinned to the exact versions ArkType itself pins. ArkType uses"@ark/util": "0.56.0"(no^) — your pin has to match, otherwise pnpm will install two copies.Single-package repo:
pnpm workspace with a catalog:
After
pnpm install, pnpm linksnode_modules/@ark/utildirectly into the consuming package, TS sees it as a direct dep, and the emitted.d.tsuses the bare specifier@ark/util— portable across installs.What doesn't fix it
public-hoist-pattern[]=@ark/*in.npmrcalone. It makes the package resolvable at the workspace root, but TS still realpath-resolves the symlink into.pnpm/during declaration emit unless@ark/*is a declared direct dep of the emitting package.: Type<...>) works locally but has to be repeated wherever the inferred type leaks — not scalable.Local workaround if you can't change deps
Brand manually via
.pipe, avoiding ArkType#Namebrand syntax so the inferred type doesn't reach into@ark/util:Root Cause
ArkType public types re-export symbols from
@ark/utiland@ark/schema(e.g. the brand-name machinery lives in@ark/util;ArkErrorCodein@ark/schema). When TypeScript emits the.d.tsfor something whose inferred type unfolds into one of those symbols, it needs to name the source module. Since@ark/*aren't listed as direct deps of the emitting package, TS falls back to the shortest path it can find throughnode_modules— which under pnpm is the store path.pnpm/@[email protected]/…. That path pins a specific pnpm-layout and version slug, so TS correctly flags it as non-portable (TS2742 / TS2883).fix(type): export the dependency types inferred types reference
docs: add CHANGELOG entries for #1577 and #1430
docs(repo): mark #1577 and #1430 fixed in issueAudit.md
ssalbdivad commentedon Nov 18, 2026
Fixed in 3.0.0-beta.0 (#1728). Try it with
npm i arktype@next.