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

Irregular Class Return Values not being Reflected Correctly with Types in TS #43272

Closed
NightshadeX9X opened this issue Mar 16, 2021 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@NightshadeX9X
Copy link

Bug Report

Irregular Class Return Values not being Reflected Correctly with Types in TS

⏯ Playground Link

Playground link with relevant code

💻 Code

class X {
    constructor() {
        return { b: 42 };
    }
}
// EXPECTED: The value X should be of type `new () => { b: number }`
// REALITY: The value X is of type `new () => {}`


const x = new X();
// EXPECTED: The value x should be of type X, which should equate to type `{ b: number }`
// REALITY: The value x is of type X, which equates to `{}`


x.b // UNEXPECTED ERROR

🙁 Actual behavior

Classes with no properties/methods defined outside the constructor have a return type of {}

🙂 Expected behavior

I expected classes to be typed correctly, and reflect the type that they actually return.

@RyanCavanaugh
Copy link
Member

Duplicate #27594

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Mar 16, 2021
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