Skip to content

Conversation

@bjohansebas
Copy link
Member

@bjohansebas bjohansebas commented Mar 15, 2025

I found a bug in res.del, because if its first argument is a function, we shouldn't modify it to be res.delete.

And I added more tests to ensure that more cases are covered.

@bjohansebas bjohansebas requested a review from a team March 15, 2025 23:30
@bjohansebas bjohansebas added the enhancement New feature or request label Mar 15, 2025
@bjohansebas bjohansebas requested a review from kjugi March 16, 2025 01:06
@bjohansebas bjohansebas requested a review from Copilot March 29, 2025 18:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the transformer for res.del to ensure that when the first argument is a function it is not modified to res.delete, and it expands test coverage for various response methods.

  • Correctly update the transformer for res.del so that only calls with a RegExp, string, or array as the first argument are changed.
  • Add new test fixtures for send, sendFile, redirect, json, jsonp, and delete endpoints to capture the updated behavior.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
transforms/v4-deprecated-signatures.ts Adjusts the call expression search and conditional logic to avoid modifying res.del when the first argument is a function.
transforms/testfixtures/v4-deprecated-signatures/send*.ts Updates tests for res.send to account for separation of status and body.
transforms/testfixtures/v4-deprecated-signatures/send-file*.ts Updates tests to verify the renaming of res.sendfile to res.sendFile.
transforms/testfixtures/v4-deprecated-signatures/redirect*.ts Updates tests to ensure proper parameter order in res.redirect calls.
transforms/testfixtures/v4-deprecated-signatures/json*.ts Updates tests to check the new handling of res.json and res.jsonp calls.
transforms/testfixtures/v4-deprecated-signatures/delete*.ts Adds test cases to verify that calls to app.del with a function argument are preserved.
Comments suppressed due to low confidence (1)

transforms/v4-deprecated-signatures.ts:107

  • [nitpick] Even though the current condition correctly skips transformation for function arguments, it might be clearer and more future-proof to explicitly check for function types (e.g. 'FunctionExpression' or 'ArrowFunctionExpression') to document the intent and avoid accidental modifications if new AST node types are introduced.
if (pathArguments[0].type !== 'RegExpLiteral' && pathArguments[0].type !== 'StringLiteral' && pathArguments[0].type !== 'ArrayExpression')

@bjohansebas bjohansebas merged commit ba27814 into main Mar 29, 2025
23 checks passed
@bjohansebas bjohansebas deleted the more-tests branch March 29, 2025 18:54
@bjohansebas bjohansebas mentioned this pull request Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant