Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intersection types its loosing generics #95

Open
uittorio opened this issue Nov 17, 2019 · 0 comments
Open

Intersection types its loosing generics #95

uittorio opened this issue Nov 17, 2019 · 0 comments

Comments

@uittorio
Copy link
Member

When mocking intersections generics are not correctly applied if the same interface is used more than once in the same intersection

Example

interface Test<T> { test: T; }

    interface Interface<T, T2> {
        a: Interface<T, T2> & Test<T> & Test<T2>;
    }

    interface TestA {
        b: string;
    }

    interface TestB {
        c: number;
    }

    const properties: Interface<TestA, TestB> = createMock<Interface<TestA, TestB>>();
    expect(properties.a.test.b).toBe('');
    expect(properties.a.test.c).toBe(0);

TestB is completely ignored for 2 reason:

  1. Deep merge doesnt work Intersection types are not merge correctly #94
  2. generics refer always to a single type based on the declaration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant