feat: export Result and ResultConfig types from package entry#759
Merged
Conversation
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>
3 tasks
There was a problem hiding this comment.
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
ResultandResultConfigfromsrc/index.ts. - Add a README TypeScript example demonstrating typed
webfont()usage andresult.config.filePathaccess. - 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Proposed changes
Exposes the public result types on the package API so TypeScript consumers can annotate
webfont()output directly.src/index.ts: re-exportResult(from./types/Result) andResultConfig(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 toReturnType/Awaitedinference.README.md: add a TypeScript example under the existing Result section showingimport { webfont, type Result, type ResultConfig } from "webfont"and typed access toresult.config.filePath.src/index.test.ts: add a type-level test (expectTypeOf) that failsnpm run typecheckif the exports are removed or their shape changes, plus a test asserting the default and namedwebfontexports 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.jsonchanges.Testing
src/index.test.ts(validated bytsc), plus default/named export identity.How to test
npm run lint— Biome clean.npm run typecheck— passes; removing either export or changingResultConfig/Resultshape makes it fail.npm test— 418 tests pass.npm run test:package— publint clean,attwgreen for node10 / node16 (CJS & ESM) / bundler, and ESM+CJS pack-smoke consumers OK, confirming the types resolve from the published tarball.import { webfont, type Result, type ResultConfig } from "webfont"type-checks.Test configuration
Checklist
Made with Cursor