Skip to content

feat: export Result and ResultConfig types from package entry#759

Merged
jimmyandrade merged 1 commit into
masterfrom
feat/issue-758-export-result-types
Jul 4, 2026
Merged

feat: export Result and ResultConfig types from package entry#759
jimmyandrade merged 1 commit into
masterfrom
feat/issue-758-export-result-types

Conversation

@jimmyandrade

Copy link
Copy Markdown
Collaborator

Summary

Proposed changes

Exposes the public result types on the package API so TypeScript consumers can annotate webfont() output directly.

  • src/index.ts: re-export Result (from ./types/Result) and ResultConfig (from ./types/ResultConfig) from the package entry. They were already defined and exported internally but not surfaced on the public entry point, so consumers had to fall back to ReturnType/Awaited inference.
  • README.md: add a TypeScript example under the existing Result section showing import { webfont, type Result, type ResultConfig } from "webfont" and typed access to result.config.filePath.
  • src/index.test.ts: add a type-level test (expectTypeOf) that fails npm run typecheck if the exports are removed or their shape changes, plus a test asserting the default and named webfont exports are the same reference.

No runtime behavior changes — this is a public type-surface addition plus docs.

Related issue

Refs #758 (kept open until the fix ships on npm, per the release workflow).

Dependencies added/removed (if applicable)

N/A — no package.json changes.


Testing

  • I have added or updated tests that prove my fix is effective or that my feature works (if applicable)
    • Unit test — type-level assertions in src/index.test.ts (validated by tsc), plus default/named export identity.

How to test

  1. npm run lint — Biome clean.
  2. npm run typecheck — passes; removing either export or changing ResultConfig/Result shape makes it fail.
  3. npm test — 418 tests pass.
  4. npm run test:package — publint clean, attw green for node10 / node16 (CJS & ESM) / bundler, and ESM+CJS pack-smoke consumers OK, confirming the types resolve from the published tarball.
  5. In a consumer: import { webfont, type Result, type ResultConfig } from "webfont" type-checks.

Test configuration

  • N/A

Checklist

  • I have added corresponding labels to this PR (like bug, enhancement...);
  • My commits follow the Conventional Commits 1.0 Guidelines;
  • My code follows the style guidelines of this project;
  • I have performed a self-review of my own code;
  • I have made changes to the documentation (if applicable);
  • My changes generate no new warnings or errors;

Made with Cursor

Re-export the public `Result` and `ResultConfig` types from `src/index.ts`
so TypeScript consumers can annotate `webfont()` output (and access
`result.config.filePath`) without relying on `ReturnType`/`Awaited`
inference.

Document the exported types with a TypeScript example in the README's
Result section, and add a type-level test that fails typecheck if the
exports are removed or their shape changes.

Refs #758

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the public TypeScript surface of webfont by re-exporting the Result and ResultConfig types from the package entry, allowing consumers to annotate webfont() output directly.

Changes:

  • Re-export Result and ResultConfig from src/index.ts.
  • Add a README TypeScript example demonstrating typed webfont() usage and result.config.filePath access.
  • Add tests to assert default/named export identity and to enforce the presence/shape of the exported result types via expectTypeOf.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/index.ts Re-exports Result / ResultConfig types from the public entry point.
src/index.test.ts Adds runtime export identity test and type-level assertions guarding the new public type exports.
README.md Documents the new public type exports with a TypeScript usage example under the Result section.

@jimmyandrade jimmyandrade merged commit c785797 into master Jul 4, 2026
4 checks passed
@jimmyandrade jimmyandrade deleted the feat/issue-758-export-result-types branch July 4, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants