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

Type is never if two distinct module groups are merged #20

Open
danieldietrich opened this issue Jul 18, 2023 · 0 comments
Open

Type is never if two distinct module groups are merged #20

danieldietrich opened this issue Jul 18, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@danieldietrich
Copy link
Member

danieldietrich commented Jul 18, 2023

Bug Report

Djinject version: 0.5.0

The following code is expected to work but currently does not compile:

interface I1 {
    b?: boolean
}

interface I2 {
    n: number
}

type Dependencies = {
    group: {
        Service1?: I1
    }
}

type Context = {
    group: {
        Service2: I2
    }
}

// ERROR: Type '{ Service1: () => I1; }' is not assignable to type 'never'.ts(2322)
export const x = {
    group: {
        Service1: () => ({
            b: true
        })
    }
} satisfies Module<Context, Dependencies>;

Workaround:

export const x = {
    group: {
        Service1: () => ({
            b: true
        })
    }
} satisfies Module<Context & Dependencies>;

The current behavior

Type of x is

{
    group: never
}

The expected behavior

Type of x is

{
    group: {
        Service1: I1,
        Service2: I2
    }
}
@danieldietrich danieldietrich added the bug Something isn't working label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant