Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Oct 16, 2024
1 parent 4ed7e4c commit 79ed916
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
3 changes: 2 additions & 1 deletion internal/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"devDependencies": {
"@types/node": "^22.7.5",
"@whatwg-node/disposablestack": "^0.0.5"
"@whatwg-node/disposablestack": "^0.0.5",
"@whatwg-node/server": "^0.9.49"
}
}
18 changes: 14 additions & 4 deletions internal/testing/src/createDisposableServer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import type { Server } from 'node:http';
import { createServer } from 'node:http';
import type { RequestListener, Server } from 'node:http';
import type { AddressInfo, Socket } from 'node:net';
import { DisposableSymbols } from '@whatwg-node/disposablestack';
import type {
ServerAdapter,
ServerAdapterBaseObject,
} from '@whatwg-node/server';

export interface DisposableServerOpts {
port?: number;
Expand All @@ -13,11 +17,17 @@ export interface DisposableServer {
server: Server;
}

export async function createDisposableServer(
requestListener?: RequestListener,
export async function createDisposableServer<
TServerContext,
TBaseObject extends ServerAdapterBaseObject<TServerContext>,
>(
adapter: ServerAdapter<TServerContext, TBaseObject>,
opts?: DisposableServerOpts,
): Promise<DisposableServer> {
const server = createServer(requestListener);
const server = createServer(
// @ts-expect-error TODO: type 'IncomingMessage' is not assignable to type 'NodeRequest' when using exactOptionalPropertyTypes
adapter,
);
const port = opts?.port || 0;
await new Promise<void>((resolve, reject) => {
server.once('error', (err) => reject(err));
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/tests/upstreamCancellation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Upstream Cancellation', () => {
await createDisposableServer(dataSourceAdapter);
const upstreamGraphQL = createYoga({
logging: false,
schema: createSchema({
schema: createSchema<{}>({
typeDefs: /* GraphQL */ `
type Query {
hello: String
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,7 @@ __metadata:
dependencies:
"@types/node": "npm:^22.7.5"
"@whatwg-node/disposablestack": "npm:^0.0.5"
"@whatwg-node/server": "npm:^0.9.49"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -4311,7 +4312,7 @@ __metadata:
languageName: node
linkType: hard

"@whatwg-node/server@npm:^0.9.44, @whatwg-node/server@npm:^0.9.46":
"@whatwg-node/server@npm:^0.9.44, @whatwg-node/server@npm:^0.9.46, @whatwg-node/server@npm:^0.9.49":
version: 0.9.49
resolution: "@whatwg-node/server@npm:0.9.49"
dependencies:
Expand Down

0 comments on commit 79ed916

Please sign in to comment.