@fkws/klonk 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -79,15 +79,11 @@ interface TaskBundle<
|
|
|
79
79
|
builder: InputBuilder<SourceType, AllOutputTypes, TaskInputType>;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* Doing so breaks contextual typing for object literals, causing string literal unions
|
|
86
|
-
* (e.g. `"low" | "critical"`) to widen to `string` inside input builder callbacks.
|
|
87
|
-
*
|
|
88
|
-
* By letting `TaskInputType` be inferred from the `task` argument (and then checking the
|
|
89
|
-
* builder against it), literal unions are preserved and DX stays sane.
|
|
82
|
+
* Prevent TypeScript from inferring `T` from a builder argument so that the
|
|
83
|
+
* task definition remains the source of truth. Useful for preserving safety
|
|
84
|
+
* when chaining `.addTask` calls.
|
|
90
85
|
*/
|
|
86
|
+
type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
91
87
|
/**
|
|
92
88
|
* An ordered sequence of Tasks executed with strong type inference.
|
|
93
89
|
*
|
|
@@ -138,7 +134,7 @@ declare class Playlist<
|
|
|
138
134
|
const IdentType extends string
|
|
139
135
|
>(task: Task<TaskInputType, TaskOutputType, IdentType> & {
|
|
140
136
|
ident: IdentType
|
|
141
|
-
}, builder: (source: SourceType, outputs: AllOutputTypes) => TaskInputType): Playlist<AllOutputTypes & { [K in IdentType] : Railroad<TaskOutputType> }, SourceType>;
|
|
137
|
+
}, builder: (source: SourceType, outputs: AllOutputTypes) => NoInfer<TaskInputType>): Playlist<AllOutputTypes & { [K in IdentType] : Railroad<TaskOutputType> }, SourceType>;
|
|
142
138
|
/**
|
|
143
139
|
* Register a callback to run after the playlist finishes. Use this hook to
|
|
144
140
|
* react to the last task or to adjust machine state before a transition.
|
package/package.json
CHANGED