Skip to content

Combine fails on large unions with object API but works via multiple arguments API #531

@7rulnik

Description

@7rulnik

Missing/Incorrect APIs

The example below fails with Type instantiation is excessively deep and possibly infinite.(2589).

It's obvious that this problem is related to Currency variations. It works with 14 elements, but not more. I also tried 4.5.0-beta with Tail-Recursion Elimination but the result is the same.

Also, it could be workarounded via multiple arguments, but it leads to more verbose code.

import { createStore, combine } from 'effector';

type Currency = 'usd' | 'eur' | 'cny' | 'uah' | 'byn' | 'thb' | 'rub' | 'azn' | 'kzt' | 'kgs' | 'uzs' | 'tzs' | 'kes' | 'zar' | 'ron' | 'mdl' | 'ils' | 'inr' | 'pln' | 'chf' | 'gbp';


const initialValue = 'usd' as Currency;

const $currency = createStore<Currency>(initialValue)

type AutosearchTrigger = {
  currency: Currency;
};

// Will fail with «Type instantiation is excessively deep and possibly infinite.»
const $autosearchTrigger = combine<AutosearchTrigger>({
  currency: $currency,
});


const $autosearchTriggerViaTuple = combine<Currency, AutosearchTrigger>($currency, (currency) => ({
  currency
}));

Playground Link: Provided

Relevant documentation

combine(...stores, fn) works
combine({ A, B, C }, fn?) doesn't work

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtypingsTypescript public type definitions issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions