Skip to content

feat!: prepare 1.0 API (typed result, package exports, navigation fix) - #4

Merged
devCrossNet merged 3 commits into
mainfrom
feat/v1-api
Oct 8, 2026
Merged

devCrossNet merged 3 commits into
mainfrom
feat/v1-api

Conversation

@devCrossNet

Copy link
Copy Markdown
Owner

What is accomplished by your PR?

Three changes for the 1.0 release, one commit each.

1. fix(navigation): support children before their parent

getNavigation() threw a TypeError when a child navigation item came before its parent in navigationItems. Parents are now added first. Children with an unknown parent are ignored.

2. feat!: generic result type, no any left

  • New type parameter Result on Quaire, QuaireBase and QuaireOptions (default Record<string, unknown>)
  • getResult() returns QuairePartialResult<Result>: every answer is optional and can be null (missing until given, null when invalidated)
  • QuaireQuestion.value, QuaireQuestion.defaultValue and QuaireNavigationItem.value are unknown
  • Interfaces also work as result type (constraint is object)
  • Type tests with expectTypeOf, checked by npm run typecheck
  • README section "Typed result"
type MyResult = { foo: string; bar: Array<number> };
const q = new Quaire<QuaireItem, QuaireQuestion, QuaireNavigationItem, MyResult>({ items });
q.getResult(); // { foo?: string | null; bar?: Array<number> | null }

3. build!: package exports

  • exports map with types and default condition
  • Only dist is published (examples removed, .npmignore removed)
  • Package size 15.2 kB → 9.5 kB, 40 → 15 files

Tested with the packed tarball in an empty project: require and import work, TypeScript works with node16 and bundler resolution, quaire/dist/types is blocked (ERR_PACKAGE_PATH_NOT_EXPORTED).

Is there something controversial in your PR?

Breaking changes (planned for 1.0):

  • getResult() and all answer values are no longer any. Consumers must pass a result type or narrow the values.
  • Deep imports like quaire/dist/... are no longer possible.
  • Examples are no longer in the npm package (still on GitHub).
  • Result is the fourth type parameter, so all other type parameters must be passed to set it.

Checklist

  • Run unit tests to ensure all existing tests are still passing
  • Add new passing unit tests to cover the code introduced by your PR
  • Change documentation for the code introduced by your PR

🤖 Generated with Claude Code

devCrossNet and others added 3 commits October 8, 2026 19:19
…tems

getNavigation() threw a TypeError when a child navigation item came before
its parent. Parents are now added first. Children with an unknown parent
are ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- add Result type parameter to Quaire, QuaireBase and QuaireOptions
- getResult() returns QuairePartialResult<Result>
- question and navigation values are unknown instead of any
- add type tests with expectTypeOf and document typed results

BREAKING CHANGE: getResult(), QuaireQuestion.value, QuaireQuestion.defaultValue
and QuaireNavigationItem.value are no longer any. Pass a result type as fourth
type parameter or narrow the values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- add exports map with types and default condition
- remove examples from the published package
- remove .npmignore, files already defines the package content

BREAKING CHANGE: deep imports like quaire/dist/types are no longer possible
and examples are no longer part of the npm package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devCrossNet
devCrossNet merged commit f837e25 into main Oct 8, 2026
2 checks passed
@devCrossNet
devCrossNet deleted the feat/v1-api branch October 8, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant