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.
package/.github/workflows/ci.yml
CHANGED
package/.pre-commit-config.yaml
CHANGED
package/package.json
CHANGED
|
@@ -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
|
})
|