Skip to content

[nightly][regression] Wrong generic parameter inferred for constructed class instance #58158

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

Closed
MichaelMitchell-at opened this issue Apr 12, 2024 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@MichaelMitchell-at
Copy link
Contributor

MichaelMitchell-at commented Apr 12, 2024

πŸ”Ž Search Terms

generic, class, infer

πŸ•— Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.5.0-dev.20240411#code/KYDwDg9gTgLgBDAnmYcCCBnDBLA5gOwB4AVAGjgFUA+OAXjgHkBbbGE8ga2EQgDNKaAMkoBuAFBiAxgBsAhljgAxCBBI0A3mLja4kiPgwwoAV0kxoACjDGARtOySEALjjEAlHHUBfCTvRY8fAtjF3UQFwBGLzcXZVVMHAJ2T3C4KKoNLT8dPQN4ADcXBMDksMivGnoGGwArYDMAOnlEoO9yGAALbAwGmHJjN3FsnShgGGMofDh8YAB3JRULfMGs4YB6NbgAPQB+VeyN12RUAHI4wmKky6IyTzhUiJE4CvJ1e8iniqoTuG7piHgzUCsjsqHMCGOcDOKguASStzeD0+GRODX2fkOs1kMH2Ph8QA

πŸ’» Code

export type Assign<T, U> = Omit<T, keyof U> & U;

class Foo<T> {
    constructor(public t: T) {}

    assign(u: {x: 1}): Foo<Assign<T, {x: 1}>> {
        const v: Assign<T, {x: 1}> = Object.assign({}, this.t, u);
        return new Foo(v);
        // ^?
        // Type 'Foo<Assign<Assign<T, { x: 1; }>, { x: 1; }>>' is not assignable to type 'Foo<Assign<T, { x: 1; }>>'.
        // wat
    }
}

πŸ™ Actual behavior

Type error

πŸ™‚ Expected behavior

No type error

Additional information about the issue

No response

@weswigham
Copy link
Member

Duplicate of #58074 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants