I’m trying to migrate our GraphQL node server from apollo-server-express
(v3) to the new @apollo/server
(v4), but I keep getting typescript compilation errors from inside node_modules
@apollo/server/* when running tsc
As in, not from my code…
I’ve tried everything I can think of to resolve this, but I am at a dead end. I’m using the recommended compilation settings in my tsconfig.json
Node version: v18.12.1
Typescript version: 4.6.2
Errors output from tsc:
❯ node -v
v18.12.1
❯ npx tsc
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:64:35 - error TS1139: Type parameter declaration expected.
64 export declare class ApolloServer {
~~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:64:42 - error TS1005: ‘;’ expected.
64 export declare class ApolloServer {
~~~~~~~~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:64:51 - error TS1128: Declaration or statement expected.
64 export declare class ApolloServer {
~~~~~~~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:65:22 - error TS1005: ‘,’ expected.
65 private internals;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:66:42 - error TS1005: ‘(’ expected.
66 readonly cache: KeyValueCache;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:67:28 - error TS1005: ‘,’ expected.
67 readonly logger: Logger;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:69:5 - error TS1005: ‘,’ expected.
69 start(): Promise;
~~~~~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:70:5 - error TS1005: ‘,’ expected.
70 startInBackgroundHandlingStartupErrorsByLoggingAndFailingAllRequests(): void;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:71:5 - error TS1005: ‘,’ expected.
71 private _start;
~~~~~~~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:71:19 - error TS1005: ‘,’ expected.
71 private _start;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:72:51 - error TS1005: ‘,’ expected.
72 private maybeRegisterTerminationSignalHandlers;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:73:27 - error TS1005: ‘,’ expected.
73 private _ensureStarted;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:75:5 - error TS1005: ‘,’ expected.
75 private logStartupError;
~~~~~~~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:75:28 - error TS1005: ‘,’ expected.
75 private logStartupError;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:76:35 - error TS1005: ‘,’ expected.
76 private static constructSchema;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:77:45 - error TS1005: ‘,’ expected.
77 private static generateSchemaDerivedData;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:79:5 - error TS1005: ‘,’ expected.
79 private addDefaultPlugins;
~~~~~~~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:79:30 - error TS1005: ‘,’ expected.
79 private addDefaultPlugins;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:81:5 - error TS1005: ‘,’ expected.
81 executeHTTPGraphQLRequest({ httpGraphQLRequest, context, }: {
~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:85:5 - error TS1005: ‘,’ expected.
85 private errorResponse;
~~~~~~~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:85:26 - error TS1005: ‘,’ expected.
85 private errorResponse;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:86:24 - error TS1005: ‘,’ expected.
86 private prefersHTML;
~
node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:90:5 - error TS1005: ‘,’ expected.
90 executeOperation<TData = Record<string, unknown>, TVariables extends VariableValues = VariableValues>(request: Omit<GraphQLRequest, ‘query’> & {
~~~~~~~~~~~~~~~~
node_modules/@apollo/server/dist/esm/externalTypes/plugins.d.ts:20:37 - error TS1139: Type parameter declaration expected.
20 export interface ApolloServerPlugin {
~~
node_modules/@apollo/server/dist/esm/externalTypes/plugins.d.ts:20:49 - error TS1005: ‘;’ expected.
20 export interface ApolloServerPlugin {
~~~~~~~
node_modules/@apollo/server/dist/esm/externalTypes/plugins.d.ts:22:5 - error TS1005: ‘,’ expected.
22 requestDidStart?(requestContext: GraphQLRequestContext): Promise<GraphQLRequestListener | void>;
~~~~~~~~~~~~~~~
node_modules/@apollo/server/dist/esm/externalTypes/plugins.d.ts:23:5 - error TS1005: ‘,’ expected.
23 unexpectedErrorProcessingRequest?({ requestContext, error, }: {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@apollo/server/dist/esm/externalTypes/plugins.d.ts:27:5 - error TS1005: ‘,’ expected.
27 contextCreationDidFail?({ error }: {
~~~~~~~~~~~~~~~~~~~~~~
node_modules/@apollo/server/dist/esm/externalTypes/plugins.d.ts:30:5 - error TS1005: ‘,’ expected.
30 invalidRequestWasReceived?({ error }: {
~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@apollo/server/dist/esm/externalTypes/plugins.d.ts:33:5 - error TS1005: ‘,’ expected.
33 startupDidFail?({ error }: {
~~~~~~~~~~~~~~
Found 30 errors in 2 files.
Errors Files
23 node_modules/@apollo/server/dist/esm/ApolloServer.d.ts:64
7 node_modules/@apollo/server/dist/esm/externalTypes/plugins.d.ts:20
tsconfig.json:
{ "compilerOptions": { "rootDir": "src/", "outDir": "build", "target": "ES2020", "lib": [ "ES2020" ], "module": "ESNext", "moduleResolution": "node", "esModuleInterop": true, "types": [ "node" ], "allowJs": true, "strict": false, "sourceMap": false, "noImplicitAny": false, "noImplicitThis": true, "noUnusedLocals": true, "noUnusedParameters": false, "allowSyntheticDefaultImports": true, "downlevelIteration": true, "resolveJsonModule": true, "baseUrl": "src/", "skipLibCheck": true }, "include": [ "src/**/*" ], "exclude": [ "node_modules" ] }