Export PageData, PageInfo, and param types from the package entry point#241
Export PageData, PageInfo, and param types from the package entry point#241
Conversation
The package exported function types (LayoutFunction, PageFunction, etc.) but not the data types those functions receive: PageData, PageInfo, TemplateInfo, and the various Params types. Users who want full type safety for layouts, templates, global.data.js, and page functions had no first-class way to import these types. They had to either reach into internal module paths or write partial inline JSDoc. This adds PageData as a runtime re-export (useful for instanceof checks) and re-exports PageInfo, TemplateInfo, LayoutFunctionParams, GlobalDataFunctionParams, PageFunctionParams, and TemplateFunctionParams as JSDoc typedefs from the package entry point.
There was a problem hiding this comment.
Pull request overview
Exposes the key data/param types that user-authored layouts/templates/global data/page functions receive by re-exporting them from the @domstack/static package entry point, eliminating fragile deep-imports.
Changes:
- Re-export
PageDataas a runtime export from the entry point. - Re-export
PageInfo/TemplateInfoas typedefs from the entry point. - Re-export
LayoutFunctionParams,GlobalDataFunctionParams,PageFunctionParams, andTemplateFunctionParamsas typedefs from the entry point.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TemplateFunctionParams was a tuple type (Parameters<TemplateFunction<T>>), inconsistent with the object-shaped LayoutFunctionParams and PageFunctionParams. Remove it from the public index.js exports and inline the tuple usage directly in the TemplateAsyncIterator internal definition. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Addressed both review comments: Comment 3105594603 (TemplateFunctionParams tuple type): Accepted. Removed Comment 3105594609 (smoke test for public types): Noted, but deferring this to a separate PR. The project already has integration-level test fixtures in |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 24619532197Coverage increased (+0.07%) to 91.537%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Imports PageData at runtime and verifies it is a class. TypeScript also checks the @typedef imports for PageInfo, TemplateInfo, LayoutFunctionParams, GlobalDataFunctionParams, PageFunctionParams, and TemplateFunctionParams at compile time via npm run test:tsc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ameters<>[0] Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This adds complexity to the types where I would like expect just new re-exporte. Audit this new complexity before landing. |
Closes #227
The package exported function types (
LayoutFunction,PageFunction,TemplateFunction, etc.) but not the data types those functions receive. Users writing layouts, templates,global.data.js, or page functions had no first-class way to importPageData,PageInfo, or any of the param types. The only options were reaching into internal module paths (fragile) or writing partial inline JSDoc annotations by hand.This change adds:
PageDataas a runtime re-export from the package entry point (useful forinstanceofchecks as well as typing)PageInfoandTemplateInfoas typedef re-exportsLayoutFunctionParams,GlobalDataFunctionParams,PageFunctionParams, andTemplateFunctionParamsas typedef re-exportsAll types were already defined in internal source files. This just makes them importable from
@domstack/staticdirectly.After this change, JSDoc users can write:
And TypeScript users can write:
No breaking changes. All existing exports remain unchanged.