Skip to content

Fix formatting of multiline variable declaration initializers #19570

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

Conversation

srolel
Copy link
Contributor

@srolel srolel commented Oct 30, 2017

Fixes #19167

Sets the effectiveParentStartLine to the last line of a multiline variable declaration name, so that effectiveParentStartLine === startLine evaluates to true.

This fixes the case presented in the issue, and also for array destructuring. It does not handle the case of a type definition after the variable name:

const {
    a,
    b
}: {
    a: number,
    b: number
};

Or a type definition followed by an initializer:

const {
    a,
    b
}: {
    a: number,
    b: number
} = {
    a: 5,
    b: 4
};

Which will behave the same as prior to the fix. These can be fixed by offsetting effectiveParentStartLine to be the last line of the previous relevant Node, which I can do if the general idea is sound.

@typescript-bot
Copy link
Collaborator

Thanks for your contribution. This PR has not been updated in a while and cannot be automatically merged at the time being. For housekeeping purposes we are closing stale PRs. If you'd still like to continue working on this PR, please leave a message and one of the maintainers can reopen it.

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

Successfully merging this pull request may close these issues.

Extra indent added after multi-line destructured assignment
2 participants