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

[printer]: protected constructor and private constructor are fixed incorrectly. #172

Closed
ElPrudi opened this issue Jul 26, 2023 · 2 comments
Labels
bug Something isn't working printer

Comments

@ElPrudi
Copy link

ElPrudi commented Jul 26, 2023

For example, I have this class:

export default class Test {
    protected x: number
    protected y: number

    private constructor(x: number, y: number) {
        if (typeof x === 'number') this.x = x  // example rule to trigger printer
        this.y = y
    }
}

The printer doesn't understand that the constructor can be scoped, so it transform it into this:

const isNumber = (a): a is number => typeof 'number'

export default class Test {
    protected x: number
    protected y: number
    constructorprivate(x: number, y: number) {
        if (isNumber(x)) this.x = x

        this.y = y
    }
}
@coderaiser coderaiser added bug Something isn't working printer labels Jul 27, 2023
@coderaiser
Copy link
Owner

Thanks! Just fixed 🎉, is it works for you?

@ElPrudi
Copy link
Author

ElPrudi commented Jul 27, 2023

Yes, it doesn't try to fix it anymore. Thank you very much :)

@ElPrudi ElPrudi closed this as completed Jul 27, 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 printer
Projects
None yet
Development

No branches or pull requests

2 participants