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 are not merge correctly #94

Open
uittorio opened this issue Nov 17, 2019 · 1 comment
Open

Intersection types are not merge correctly #94

uittorio opened this issue Nov 17, 2019 · 1 comment

Comments

@uittorio
Copy link
Member

In this scenario ts auto mock should be able to mix/merge all the properties for ABC

interface D { d: { d1: string }; }
interface E { d: { d2: number }; }
interface F { f: number; }
interface A { x: D; }
interface B { x: E; }
interface C { x: F; }

type ABC = A & B & C;
const abc: ABC = {
    x: {
        d: {
            d1: '',
            d2: 0,
        },
        f: 3,
    },
};

Right now instead it will not merge literal properties after the first level.
f and d2 will not be in the mock

Issue
Its failing because it resolving the properties of the initial intersections types that will not include the subtypes

Possible solution
Still to investigate

@fabbree
Copy link

fabbree commented Oct 27, 2022

Hello there,

I might have stumbled on the same issue with an even simpler case:

import {
  createMock
} from "ts-auto-mock";

type Wrapper<T> = T & {
  addedField: string,
}

let a = createMock<Wrapper<{field1: number}>>()

console.log(a.field1); //undefined
console.log(a.addedField); //'addedField8e889b'

I was expecting to have both field populated but only first level is.

I hope it may helps your investigations.

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

2 participants