Skip to content

feat: export Result and ResultConfig types from the package entry (+ document result.config.filePath) #758

Description

@jimmyandrade

Summary

webfont() resolves to a Result object whose config is a ResultConfig, but neither type is re-exported from the package entry (src/index.ts). TypeScript consumers currently cannot do:

import webfont, { type Result, type ResultConfig } from "webfont";

and have to fall back to ReturnType/Awaited inference to annotate the output.

Current state on master

  • src/types/Result.ts and src/types/ResultConfig.ts define and export the types internally.
  • src/index.ts only exports webfont (named + default), the SVG diagnostics helpers, and SvgToolsOptions types — not Result / ResultConfig.
  • result.config.filePath is already modeled as result-only metadata on master (landed in f557233, "fix: model filePath as result-only metadata"), but it is not documented in the README.

Proposed change

  1. Re-export the public result types from the entry point:
export type { Result } from "./types/Result";
export type { ResultConfig } from "./types/ResultConfig";
  1. Document the result shape in README.md:
    • A new Result section describing result.config (effective options + output metadata).
    • result.config.filePath — absolute path of the discovered/loaded config file; output-only (ignored if set as input).
    • A short TypeScript usage example using the exported types.

Reference implementation

An unmerged local branch feat/export-result-types already implements this (no PR was ever opened):

  • 460bb4cfeat: export Result and ResultConfig types from package entry (the src/index.ts re-exports).
  • README additions: a Result section, a TypeScript example, and result.config.filePath docs.
  • Also carries expanded cosmiconfig coverage (src/standalone/cosmiconfig.test.ts) that can be split out if desired.

The filePath modeling portion of that branch is already on master; the remaining, genuinely new work is the public type export + README documentation.

Acceptance criteria

  • import type { Result, ResultConfig } from "webfont" type-checks for consumers (verify via attw / pack-smoke in npm run test:package).
  • README documents result.config and result.config.filePath with a TypeScript example.
  • No runtime behavior change (types + docs only).

Metadata

Metadata

Assignees

Fields

No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions