Skip to content

Commit

Permalink
fix!: fix code after deps bump
Browse files Browse the repository at this point in the history
BREAKING CHANGE: empty response type should now be typed as never instead of void
  • Loading branch information
Coobaha committed Jan 4, 2022
1 parent 51019ff commit 6440479
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"crypto-js": "^4.1.1",
"escape-string-regexp": "^5.0.0",
"escape-string-regexp": "4.0.0",
"glob": "^7.2.0",
"json-schema-merge-allof": "^0.8.1",
"json-schema-traverse": "^1.0.0",
Expand Down
12 changes: 10 additions & 2 deletions src/typed-fastify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,19 @@ export type RequestHandler<
S = Service<ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig>,
Paths = ServiceSchema['paths'],
OpHandler = {
[Path in HandlerPaths]: Handler<Paths[Path], Path, ServiceSchema, RawServer, RawRequest, RawReply, ContextConfig>;
[Path in HandlerPaths]: Handler<
Path extends keyof Paths ? Paths[Path] : never,
Path,
ServiceSchema,
RawServer,
RawRequest,
RawReply,
ContextConfig
>;
}[HandlerPaths],
OpHandlerObj = {
[Path in HandlerPaths]: HandlerObj<
Paths[Path],
Path extends keyof Paths ? Paths[Path] : never,
Path,
ServiceSchema,
RawServer,
Expand Down
10 changes: 5 additions & 5 deletions tap-snapshots/test/integration.test.ts.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ exports[`test/integration.test.ts TAP POST / rejects invalid payload > response
Object {
"Headers": Array [
"HTTP/1.1 400 Bad Request",
"content-length: 84",
"content-type: application/json; charset=utf-8",
"content-length: 84",
"Date: dateString",
"Connection: keep-alive",
],
Expand Down Expand Up @@ -394,8 +394,8 @@ exports[`test/integration.test.ts TAP POST /paramswithtypo/:Ids/:subid > respons
Object {
"Headers": Array [
"HTTP/1.1 400 Bad Request",
"content-length: 79",
"content-type: application/json; charset=utf-8",
"content-length: 79",
"Date: dateString",
"Connection: keep-alive",
],
Expand Down Expand Up @@ -710,8 +710,8 @@ exports[`test/integration.test.ts TAP it validates get query param against schem
Object {
"Headers": Array [
"HTTP/1.1 400 Bad Request",
"content-length: 96",
"content-type: application/json; charset=utf-8",
"content-length: 96",
"Date: dateString",
"Connection: keep-alive",
],
Expand Down Expand Up @@ -872,8 +872,8 @@ exports[`test/integration.test.ts TAP it validates headers > response path:GET /
Object {
"Headers": Array [
"HTTP/1.1 400 Bad Request",
"content-length: 106",
"content-type: application/json; charset=utf-8",
"content-length: 106",
"Date: dateString",
"Connection: keep-alive",
],
Expand All @@ -891,8 +891,8 @@ exports[`test/integration.test.ts TAP it validates headers > response path:GET /
Object {
"Headers": Array [
"HTTP/1.1 400 Bad Request",
"content-length: 102",
"content-type: application/json; charset=utf-8",
"content-length: 102",
"Date: dateString",
"Connection: keep-alive",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ interface ExtendedSchema extends ExampleSchema {
request: SharedRequest;
response: {
204: {
content: void;
content: never;
};
};
};
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
dependencies:
ajv "^6.12.6"

"@isaacs/import-jsx@*", "@isaacs/import-jsx@^4.0.1":
"@isaacs/import-jsx@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@isaacs/import-jsx/-/import-jsx-4.0.1.tgz#493cab5fc543a0703dba7c3f5947d6499028a169"
integrity sha512-l34FEsEqpdYdGcQjRCxWy+7rHY6euUbOBz9FI+Mq6oQeVhNegHcXFSJxVxrJvOpO31NbnDjS74quKXDlPDearA==
Expand Down Expand Up @@ -619,7 +619,7 @@
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==

"@types/react@*":
"@types/react@^17":
version "17.0.38"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.38.tgz#f24249fefd89357d5fa71f739a686b8d7c7202bd"
integrity sha512-SI92X1IA+FMnP3qM5m4QReluXzhcmovhZnLNm3pyeQlooi02qI7sLiepEYqT678uNiyc25XfCqxREFpy3W7YhQ==
Expand Down Expand Up @@ -1368,6 +1368,11 @@ escalade@^3.1.1:
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==

[email protected]:
version "4.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==

escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
Expand All @@ -1378,11 +1383,6 @@ escape-string-regexp@^2.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344"
integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==

escape-string-regexp@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz#4683126b500b61762f2dbebace1806e8be31b1c8"
integrity sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==

eslint-formatter-pretty@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/eslint-formatter-pretty/-/eslint-formatter-pretty-4.1.0.tgz#7a6877c14ffe2672066c853587d89603e97c7708"
Expand Down Expand Up @@ -1854,7 +1854,7 @@ inherits@2, inherits@^2.0.3:
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==

ink@*, ink@^3.2.0:
ink@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/ink/-/ink-3.2.0.tgz#434793630dc57d611c8fe8fffa1db6b56f1a16bb"
integrity sha512-firNp1q3xxTzoItj/eOOSZQnYSlyrWks5llCTVX37nJ59K3eXbQ8PtzCguqo8YI19EELo5QxaKnJd4VxzhU8tg==
Expand Down Expand Up @@ -2755,7 +2755,7 @@ react-reconciler@^0.26.2:
object-assign "^4.1.1"
scheduler "^0.20.2"

react@*:
react@^17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"
integrity sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==
Expand Down Expand Up @@ -3446,7 +3446,7 @@ tree-kill@^1.2.2:
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==

treport@*:
treport@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/treport/-/treport-3.0.2.tgz#6503b6430b201620a20fef2892bc875dc6495116"
integrity sha512-aMKalaiZMsTfTXIEnJEz7BT5aHzN+ZV5hFCrXZsCbRZxfGRop+7JQdXntBs1FHZc9W2zMHLxGHb42yf08l6/bw==
Expand Down

0 comments on commit 6440479

Please sign in to comment.