Skip to content

Commit

Permalink
Allow name in attach when only passing effect
Browse files Browse the repository at this point in the history
  • Loading branch information
kireevmp committed Mar 10, 2024
1 parent b7770df commit e3323e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/effector/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2742,6 +2742,7 @@ export function attach<
FX extends Effect<any, any, any>,
>(config: {
effect: FX
name?: string
}): Effect<EffectParams<FX>, EffectResult<FX>, EffectError<FX>>
/**
* Method for creating state-dependent effect and transforming effect payload
Expand Down
10 changes: 10 additions & 0 deletions src/types/__tests__/effector/attach.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ test('without source and mapParams (should pass)', () => {
`)
})

test('effect with explicit name (should pass)', () => {
const effect: Effect<void, void, Error> = createEffect()
const fx: Effect<void, void, Error> = attach({effect, name: 'fx'})
expect(typecheck).toMatchInlineSnapshot(`
"
no errors
"
`)
})

describe('unknown params type', () => {
test('unknown params type [with source] (?)', () => {
const source = createStore(0)
Expand Down

0 comments on commit e3323e3

Please sign in to comment.