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

When you 'clone call' in javascript it results in a syntax error #2650

Open
jaresty opened this issue Aug 9, 2024 · 0 comments
Open

When you 'clone call' in javascript it results in a syntax error #2650

jaresty opened this issue Aug 9, 2024 · 0 comments

Comments

@jaresty
Copy link
Contributor

jaresty commented Aug 9, 2024

Issue: Clone Call in TypeScript Adds Spaces Causing Syntax Errors

Description:

When using the "clone call" feature in TypeScript, the new call is separated from the old call with spaces. This behavior results in a syntax error, as TypeScript does not permit multiple function calls separated by spaces without proper delimiters. Consequently, users must manually intervene to correct this by adding a line break or a semicolon after cloning the call.

Example:

Consider the following TypeScript code:

function example() {
  myFunction();
  myFunction(); // Cloned call
}

Upon using "clone call," the result is:

function example() {
  myFunction();
  myFunction() myFunction(); // Syntax error
}

This occurs because the cloned call is appended with spaces, causing a syntax error.

Expected Behavior:

The expected behavior when using "clone call" is either to:

  1. Insert a line break after the cloned call:
function example() {
  myFunction();
  myFunction();
  myFunction(); // Cloned call with line break
}
  1. Append a semicolon after the cloned call:
function example() {
  myFunction();
  myFunction();; // Cloned call with semicolon
}

Impact:

This issue frequently arises when editing files with multiple function calls, such as in vitest files where each spec is its own call. The need for manual correction after each "clone call" operation disrupts workflow and reduces productivity.

Proposed Solution:

To address this issue, modify the "clone call" functionality to automatically insert a line break or a semicolon after the cloned call. While adding semicolons may be more complex to implement, it could provide a more robust solution.

Additional Notes:

This issue requires careful consideration as multiple function calls on the same line are possible, and the chosen solution should not break valid code patterns.

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

No branches or pull requests

1 participant