Skip to content

Fix getCodeFixesAtPosition for ts(2339) thows error False expression: Token end is child end #43645

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

Merged
merged 2 commits into from
Apr 20, 2021

Conversation

jeanp413
Copy link
Contributor

Fixes #43191

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Apr 12, 2021
@jessetrinity jessetrinity self-assigned this Apr 19, 2021
@jessetrinity
Copy link
Contributor

I see that other code fixes make use of the same flag but I'm not 100% sure what it does. Can you point to where the truncation was causing the problem?

@jeanp413
Copy link
Contributor Author

@jessetrinity There are some places in checker.ts that checks the length and if it's too long replaces the remaining text with ... ${properties.length - i} more ...

if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) {
    typeElements.push(factory.createPropertySignature(/*modifiers*/ undefined, `... ${properties.length - i} more ...`, /*questionToken*/ undefined, /*type*/ undefined));
    addPropertyToElementList(properties[properties.length - 1], context, typeElements);
    break;
}

And then when trying to format the text (which is invalid in formatting.ts) to apply the corresponding text edits it would throw an error

@jessetrinity jessetrinity self-requested a review April 20, 2021 17:00
Copy link
Contributor

@jessetrinity jessetrinity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks!

@jessetrinity jessetrinity merged commit 8513f78 into microsoft:master Apr 20, 2021
@jeanp413 jeanp413 deleted the fix-43191 branch April 20, 2021 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

languageService.getCodeFixesAtPosition() throws for ts(2339) and object destructuring with many identifiers
3 participants