esupgrade 2025.22.1 → 2025.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ jobs:
23
23
  steps:
24
24
  - uses: actions/checkout@v7
25
25
  - name: Set up Node.js
26
- uses: actions/setup-node@v6
26
+ uses: actions/setup-node@v7
27
27
  with:
28
28
  node-version-file: package.json
29
29
  - run: npm ci
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
13
  - uses: actions/checkout@v7
14
- - uses: actions/setup-node@v6
14
+ - uses: actions/setup-node@v7
15
15
  with:
16
16
  node-version-file: package.json
17
17
  registry-url: 'https://registry.npmjs.org'
@@ -32,7 +32,7 @@ repos:
32
32
  - id: write-good
33
33
  args: [--no-passive]
34
34
  - repo: https://github.com/pre-commit/mirrors-eslint
35
- rev: v10.6.0
35
+ rev: v10.7.0
36
36
  hooks:
37
37
  - id: eslint
38
38
  args: ["--fix"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esupgrade",
3
- "version": "2025.22.1",
3
+ "version": "2025.22.2",
4
4
  "description": "Auto-upgrade your JavaScript syntax",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -68,6 +68,16 @@ export function anonymousFunctionToArrow(root) {
68
68
  arrowFunction.async = true
69
69
  }
70
70
 
71
+ // Preserve TypeScript generic type parameters
72
+ if (node.typeParameters) {
73
+ arrowFunction.typeParameters = node.typeParameters
74
+ }
75
+
76
+ // Preserve TypeScript return type annotation
77
+ if (node.returnType) {
78
+ arrowFunction.returnType = node.returnType
79
+ }
80
+
71
81
  j(path).replaceWith(arrowFunction)
72
82
 
73
83
  modified = true
@@ -220,5 +220,25 @@ suite("widely-available", () => {
220
220
 
221
221
  assert(!result.modified, "skip named function expression")
222
222
  })
223
+
224
+ test("generic type parameters are preserved", () => {
225
+ const result = transform(`
226
+ globalThis.Promise.withResolvers = function<T>() {
227
+ return { promise: new Promise<T>(), resolve: null };
228
+ };
229
+ `)
230
+
231
+ assert(result.modified, "transform generic function expression")
232
+ assert.match(result.code, /<T>\(\) =>/)
233
+ })
234
+
235
+ test("generic type parameters with return type are preserved", () => {
236
+ const result = transform(`
237
+ arr.map(function<T>(x: T): T { return x; });
238
+ `)
239
+
240
+ assert(result.modified, "transform generic callback function")
241
+ assert.match(result.code, /<T>\(x: T\): T =>/)
242
+ })
223
243
  })
224
244
  })