-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix MSW typescript compile errors #21319
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
Fix MSW typescript compile errors #21319
Conversation
There was a problem hiding this 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 TypeScript compilation errors introduced by the MSW (Mock Service Worker) v2 upgrade. The changes ensure TypeScript can successfully compile the entire project by properly migrating MSW handler syntax and fixing type issues in mock files.
Key Changes:
- Migrated e2e test files from MSW v1 syntax (
rest,res,ctx) to MSW v2 syntax (http,HttpResponse) - Updated mock handlers to use correct MSW v2 generic signature:
http.post<PathParams, RequestBodyType> - Fixed request body handling by extracting
userIdsfrom reference objects to simple string arrays
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Umbraco.Web.UI.Client/src/mocks/handlers/user/unlock.handlers.ts | Added proper MSW v2 generics and fixed userIds mapping from reference objects to string IDs |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/user/set-user-groups.handlers.ts | Added proper MSW v2 generics and type import for request model |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/user/invite.handlers.ts | Added proper MSW v2 generics and removed unnecessary <any> type parameter |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/user/enable.handlers.ts | Added proper MSW v2 generics and fixed userIds mapping from reference objects to string IDs |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/user/disable.handlers.ts | Added proper MSW v2 generics and fixed userIds mapping from reference objects to string IDs |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/user/current.handlers.ts | Added proper MSW v2 generics and improved type safety for route params handling |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/user/change-password.handlers.ts | Added proper MSW v2 generics and reformatted for consistency |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/telemetry.handlers.ts | Added proper MSW v2 generics and safer handling of optional request body properties |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/package.handlers.ts | Added proper MSW v2 generics for create and update package handlers |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/media-type/folder.handlers.ts | Added proper MSW v2 generics and type imports for folder operations |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/install.handlers.ts | Added proper MSW v2 generics for installation endpoints |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/health-check.handlers.ts | Added proper MSW v2 generics for health check action endpoint |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/dynamic-root.handlers.ts | Removed unused type import and simplified handler without generic types |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/document-type/folder.handlers.ts | Added proper MSW v2 generics and type imports for folder operations |
| src/Umbraco.Web.UI.Client/src/mocks/handlers/data-type/folder.handlers.ts | Added proper MSW v2 generics and type imports for folder operations |
| src/Umbraco.Web.UI.Client/e2e/upgrader.spec.ts | Converted from MSW v1 (rest, res, ctx) to MSW v2 (http, HttpResponse) syntax |
| src/Umbraco.Web.UI.Client/e2e/installer.spec.ts | Converted from MSW v1 (rest, res, ctx) to MSW v2 (http, HttpResponse) syntax |
It is currently not possible to successfully run the TypeScript compiler in the root of the project with
npm run compile. It complains with TypeScript errors. This was caused by the upgrade to MSW 2, and our build pipeline currently only runs the TypeScript compiler on part of the project, not catching the TypeScript errors in the mock files.Mock Handlers (Using Proper MSW v2 Generics)
Updated all handlers to use the correct MSW v2 generic signature:
E2E Files (MSW v1 → v2 Migration)
We also missed the upgrade for the e2e Playwright files. I am not sure if these are in use or if we can safely delete this folder.
rest,res,ctx) to MSW v2 syntax (http,HttpResponse)