Skip to content

Commit

Permalink
Lock MSW to 0.40.2, and patch it to ignore TS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Aug 28, 2022
1 parent bb640f8 commit c9838b3
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 189 deletions.
20 changes: 20 additions & 0 deletions .yarn/patches/msw-npm-0.40.2-2107d48752
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/lib/types/context/set.d.ts b/lib/types/context/set.d.ts
index 266229bad706ec49392b8b87e18560c1566b490d..4fad485f8ffec2db92e808a05ccd9274414a9bd9 100644
--- a/lib/types/context/set.d.ts
+++ b/lib/types/context/set.d.ts
@@ -15,4 +15,5 @@ export declare type ForbiddenHeaderError<HeaderName extends string> = `SafeRespo
* })
* @see {@link https://mswjs.io/docs/api/context/set `ctx.set()`}
*/
+// @ts-ignore
export declare function set<N extends string | HeadersObject>(...args: N extends string ? Lowercase<N> extends ForbiddenHeaderNames ? ForbiddenHeaderError<N> : [N, string] : N extends HeadersObject<infer CookieName> ? Lowercase<CookieName> extends ForbiddenHeaderNames ? ForbiddenHeaderError<CookieName> : [N] : [N]): ResponseTransformer;
diff --git a/lib/types/sharedOptions.d.ts b/lib/types/sharedOptions.d.ts
index d1d6e05df2dc2c29f06d8d0b91c500a10e651a29..3d8c29fd2089b2abf21d78cd277aac9271e781c2 100644
--- a/lib/types/sharedOptions.d.ts
+++ b/lib/types/sharedOptions.d.ts
@@ -21,4 +21,5 @@ export interface LifeCycleEventsMap<ResponseType> {
'response:bypass': (response: ResponseType, requestId: string) => void;
unhandledException: (error: Error, request: MockedRequest) => void;
}
+// @ts-ignore
export declare type LifeCycleEventEmitter<ResponseType> = Pick<StrictEventEmitter<ResponseType>, 'on' | 'removeListener' | 'removeAllListeners'>;
2 changes: 1 addition & 1 deletion examples/query/react/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@types/jest": "^26.0.23",
"@types/react": "^18.0.5",
"@types/react-dom": "^18.0.5",
"msw": "^0.41.1",
"msw": "^0.40.2",
"typescript": "~4.2.4"
},
"eslintConfig": {
Expand Down
2 changes: 1 addition & 1 deletion examples/query/react/graphql-codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"framer-motion": "^2.9.5",
"graphql": "^15.5.0",
"graphql-request": "^3.4.0",
"msw": "0.28.2",
"msw": "0.40.2",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-icons": "3.11.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/query/react/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"framer-motion": "^2.9.5",
"graphql": "^15.5.0",
"graphql-request": "^3.4.0",
"msw": "0.28.2",
"msw": "0.40.2",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-icons": "3.11.0",
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react-redux": "npm:8.0.2",
"react": "npm:18.1.0",
"react-dom": "npm:18.1.0",
"msw": "0.40.2",
"@types/react": "npm:18.0.12",
"@types/react-dom": "npm:18.0.5",
"@types/inquirer": "npm:8.2.1",
Expand All @@ -51,7 +52,9 @@
"docs/react": "npm:17.0.2",
"docs/react-dom": "npm:17.0.2",
"docs/@types/react-dom": "npm:17.0.11",
"docs/@types/react": "npm:17.0.11"
"docs/@types/react": "npm:17.0.11",
"type-fest": "2.19.0",
"[email protected]": "patch:msw@npm:0.40.2#.yarn/patches/msw-npm-0.40.2-2107d48752"
},
"scripts": {
"build": "yarn build:packages",
Expand Down
2 changes: 1 addition & 1 deletion packages/rtk-query-codegen-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"esbuild-runner": "^2.2.1",
"husky": "^4.3.6",
"jest": "^27",
"msw": "^0.41.1",
"msw": "^0.40.2",
"openapi-types": "^9.1.0",
"pretty-quick": "^3.1.0",
"ts-jest": "^27",
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"json-stringify-safe": "^5.0.1",
"magic-string": "^0.25.7",
"merge-source-map": "^1.1.0",
"msw": "^0.41.1",
"msw": "^0.40.2",
"node-fetch": "^2.6.1",
"prettier": "^2.2.1",
"query-string": "^7.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/query/react/buildHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ import type { BaseQueryFn } from '../baseQueryTypes'
// Copy-pasted from React-Redux
export const useIsomorphicLayoutEffect =
typeof window !== 'undefined' &&
window.document &&
window.document.createElement
!!window.document &&
!!window.document.createElement
? useLayoutEffect
: useEffect

Expand Down
Loading

0 comments on commit c9838b3

Please sign in to comment.