πŸŽ™οΈ task - fix(types): export HelpfulErrorMetadata from the package index β€” subclass authors cannot name the constraint

Open Beginner friendly
#43 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
92/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

Start in src/index.ts, where HelpfulError and type HelpfulErrorCode are exported, and add HelpfulErrorMetadata beside them. Check the subclass pattern described in the issue to confirm the type is importable from the package entry point; a README note about subclassing is an optional follow-up.

Written by the indexing model from the issue text.

Description

πŸ¦«πŸŽ™οΈ dispatch to foreman

πŸ’§ task enqueued
   β”œβ”€ priority = ?
   β”œβ”€ yieldage = ?
   └─ leverage = ?

title
fix(types): export HelpfulErrorMetadata from the package index β€” subclass authors cannot name the constraint
description

what

add type HelpfulErrorMetadata to the package index export, beside HelpfulErrorCode.

why

HelpfulError and every subclass are generic over TMetadata extends HelpfulErrorMetadata. a consumer that declares its own subclass MUST name that constraint:

export class UnauthorizedRequestError<
  TMetadata extends HelpfulErrorMetadata = HelpfulErrorMetadata,   // <- unnameable
> extends BadRequestError<TMetadata> { ... }

but src/index.ts exports HelpfulError and type HelpfulErrorCode, and NOT HelpfulErrorMetadata. so the one type a subclass author needs is the one type they cannot import. the two workarounds are both poor: reach into helpful-errors/dist/HelpfulError (past the public entry into a build artifact), or redeclare Record<string, any> & { cause?: Error } locally (drifts). svc-gateway took a third route β€” type HelpfulErrorMetadata = NonNullable<HelpfulError["metadata"]> β€” which works but is a puzzle for a type the package already has.

why it bites

HelpfulError.throw binds this: T extends typeof HelpfulError, reading the constructor return type. a non-generic subclass returns HelpfulError<HelpfulErrorMetadata> where HelpfulError<TMetadata> is demanded, so .throw becomes unreachable (TS2684). the fix is to make the subclass generic β€” which needs the unexported constraint. so the gap blocks the documented subclass pattern.

ask

add type HelpfulErrorMetadata to the index export. one line. worth a readme note too, since subclasses are a first-class use of this package.

source

found during the declapract upgrade of ahbode/svc-gateway (branch vlad/bump-practs), item 8 of .dream/2026_08_12.upstream-sdk-zod-glossary-splits

Dominant language
TypeScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up β€” it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.