Skip to content

Commit bf84a6f

Browse files
docs(types): state the merge tap a merged stats key needs
1 parent 70abaa5 commit bf84a6f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎lib/stats/StatsFactory.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const smartGrouping = require("./smartGrouping");
103103
*/
104104

105105
/**
106-
* The `[item, created item]` of each array path, typing its item hooks (`filter`, `sort`, `filterSorted`) and created item hooks (`sortResults`, `groupResults`, `filterResults`, `merge`); an optional third element is what `merge` makes of the created items, which `result` then gets instead of their array.
106+
* The `[item, created item]` of each array path, typing its item hooks (`filter`, `sort`, `filterSorted`) and created item hooks (`sortResults`, `groupResults`, `filterResults`, `merge`); an optional third element is what `merge` makes of the created items, which `result` then gets instead of their array, so a key declaring one must register a `merge` tap returning that type.
107107
* A plugin types its own paths by declaration merging: `declare module "webpack" { interface StatsFactoryItemKeys { "myPlugin.items": [MyItem, MyCreatedItem] } }`.
108108
* @augmentable
109109
* @typedef {{
@@ -133,6 +133,7 @@ const smartGrouping = require("./smartGrouping");
133133

134134
/**
135135
* The value `result` gets for an array path: what `merge` made of its created items, else their array.
136+
* A key declaring a merged type must register a `merge` tap returning it, or `result` gets the plain array at runtime.
136137
* @template {keyof StatsFactoryItemKeys} K
137138
* @typedef {StatsFactoryItemKeys[K] extends [EXPECTED_ANY, EXPECTED_ANY, infer M] ? M : StatsFactoryItemKeys[K][1][]} StatsFactoryMergedItems
138139
*/
@@ -224,6 +225,7 @@ const smartGrouping = require("./smartGrouping");
224225

225226
/**
226227
* `merge` hooks: the exact created items for array paths in `StatsFactoryItemKeys`, merged into the third element a merged key declares.
228+
* A key declaring that element must tap here and return it, since `result` is typed by it.
227229
* @typedef {{
228230
* for<K extends keyof StatsFactoryItemKeys>(key: K): SyncBailHook<[StatsFactoryItemKeys[K][1][], StatsFactoryContext], StatsFactoryMergedItems<K> | void>,
229231
* for(key: string): SyncBailHook<[StatsPluginValue[], StatsFactoryContext], StatsPluginValue | void>

‎types.d.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35837,7 +35837,7 @@ declare namespace exports {
3583735837
}
3583835838

3583935839
/**
35840-
* The `[item, created item]` of each array path, typing its item hooks (`filter`, `sort`, `filterSorted`) and created item hooks (`sortResults`, `groupResults`, `filterResults`, `merge`); an optional third element is what `merge` makes of the created items, which `result` then gets instead of their array.
35840+
* The `[item, created item]` of each array path, typing its item hooks (`filter`, `sort`, `filterSorted`) and created item hooks (`sortResults`, `groupResults`, `filterResults`, `merge`); an optional third element is what `merge` makes of the created items, which `result` then gets instead of their array, so a key declaring one must register a `merge` tap returning that type.
3584135841
* A plugin types its own paths by declaration merging: `declare module "webpack" { interface StatsFactoryItemKeys { "myPlugin.items": [MyItem, MyCreatedItem] } }`.
3584235842
*/
3584335843
export interface StatsFactoryItemKeys {

0 commit comments

Comments
 (0)