Skip to content
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

Upgrade TS to 3.7.3 #3618

Merged
merged 3 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The version headers in this history reflect the versions of Apollo Server itself

> The changes noted within this `vNEXT` section have not been released yet. New PRs and commits which introduce changes should include an entry in this `vNEXT` section as part of their development. When a release is being prepared, a new header will be (manually) created below and the the appropriate changes within that release will be moved into the new section.

- _Nothing yet. Stay tuned!_
- `apollo-server-core`: Upgrade TS to 3.7.3 [#3618](https://github.com/apollographql/apollo-server/pull/3618)

### v2.9.14

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"supertest": "4.0.2",
"test-listen": "1.1.0",
"ts-jest": "24.2.0",
"typescript": "3.6.2",
"typescript": "3.7.3",
"ws": "6.2.1"
},
"jest": {
Expand Down
20 changes: 6 additions & 14 deletions packages/apollo-server-core/src/utils/dispatcher.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { GraphQLRequestListener } from "apollo-server-plugin-base";

type AnyFunction = (...args: any[]) => any;
type Args<F> = F extends (...args: infer A) => any ? A : never;
type FunctionPropertyNames<T, F extends AnyFunction = AnyFunction> = {
[K in keyof T]: T[K] extends F ? K : never;
}[keyof T];
type AsFunction<F> = F extends AnyFunction ? F : never;
type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;

type DidEndHook<TArgs extends any[]> = (...args: TArgs) => void;

export class Dispatcher<T> {
export class Dispatcher<T extends GraphQLRequestListener> {
constructor(protected targets: T[]) {}

public async invokeHookAsync<
TMethodName extends FunctionPropertyNames<Required<T>>
>(
public async invokeHookAsync<TMethodName extends keyof T>(
methodName: TMethodName,
...args: Args<T[TMethodName]>
): Promise<UnwrapPromise<ReturnType<AsFunction<T[TMethodName]>>>[]> {
Expand All @@ -27,9 +24,7 @@ export class Dispatcher<T> {
);
}

public async invokeHooksUntilNonNull<
TMethodName extends FunctionPropertyNames<Required<T>>
>(
public async invokeHooksUntilNonNull<TMethodName extends keyof T>(
methodName: TMethodName,
...args: Args<T[TMethodName]>
): Promise<UnwrapPromise<ReturnType<AsFunction<T[TMethodName]>>> | null> {
Expand All @@ -47,10 +42,7 @@ export class Dispatcher<T> {
}

public invokeDidStartHook<
TMethodName extends FunctionPropertyNames<
Required<T>,
(...args: any[]) => AnyFunction | void
>,
TMethodName extends keyof T,
TEndHookArgs extends Args<ReturnType<AsFunction<T[TMethodName]>>>
>(
methodName: TMethodName,
Expand Down