Skip to content

Commit 8dd5bda

Browse files
authored
feat(core): allow to use a uniform state in withState (#2611)
* feat(core): allow to use a uniform state in `withState` * changeset
1 parent 1d78ab9 commit 8dd5bda

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changeset/curly-carrots-lead.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@envelop/core': patch
3+
---
4+
5+
Add a `withState` override to ease the typing of plugins whith the same state for all scopes.

packages/core/src/plugin-with-state.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { MaybePromise } from '@whatwg-node/promise-helpers';
22

3+
export function withState<P extends { instrumentation?: GenericInstrumentation }, State = object>(
4+
pluginFactory: (
5+
getState: <SP extends {}>(payload: SP) => PayloadWithState<SP, State, State, State>['state'],
6+
) => PluginWithState<P, State, State, State>,
7+
): P;
38
export function withState<
49
P extends { instrumentation?: GenericInstrumentation },
510
HttpState = object,

0 commit comments

Comments
 (0)