branded types are not portable when declaration: true

Hi, I'm trying to export a branded type from a shared node package. The tsconfig has declaration: true because I want the type declarations emitted, but that seems to get me a type portability error:
The inferred type of 'Test' 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)
The inferred type of 'Test' 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)
just from
import { type } from "arktype";

export const Test = type.string.brand("test");
import { type } from "arktype";

export const Test = type.string.brand("test");
I know it can work if I explicitly type the return, but I don't want to give up type inference, is there an easy solution to this?
1 Reply
ssalbdivad
ssalbdivad2w ago
That's a weird one because the Brand type in @ark/utilis... - fully exported - serializable (it's just a string literal)
You may be able to work around it by adding @ark/util as an explicit dependency (it already is transitively). @Andarist any ideas why this would happen here?

Did you find this page helpful?