Skip to content

Commit 05308fa

Browse files
authored
improve: Node 18 tsconfig and ES2023 lib (#794)
1 parent cc2dc55 commit 05308fa

9 files changed

Lines changed: 294 additions & 292 deletions

File tree

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,26 +84,27 @@
8484
"@graphql-typed-document-node/core": "^3.2.0",
8585
"@molt/command": "^0.9.0",
8686
"dprint": "^0.45.1",
87-
"zod": "^3.22.5"
87+
"zod": "^3.23.0"
8888
},
8989
"peerDependencies": {
9090
"graphql": "14 - 16"
9191
},
9292
"devDependencies": {
9393
"@pothos/core": "^3.41.1",
9494
"@pothos/plugin-simple-objects": "^3.7.0",
95-
"@tsconfig/node16": "^16.1.3",
95+
"@tsconfig/node18": "^18.2.4",
96+
"@tsconfig/strictest": "^2.0.5",
9697
"@types/body-parser": "^1.19.5",
9798
"@types/express": "^4.17.21",
9899
"@types/json-bigint": "^1.0.4",
99100
"@types/node": "^20.12.7",
100-
"@typescript-eslint/eslint-plugin": "^7.7.0",
101-
"@typescript-eslint/parser": "^7.7.0",
101+
"@typescript-eslint/eslint-plugin": "^7.7.1",
102+
"@typescript-eslint/parser": "^7.7.1",
102103
"apollo-server-express": "^3.13.0",
103104
"body-parser": "^1.20.2",
104105
"doctoc": "^2.2.1",
105106
"dripip": "^0.10.0",
106-
"eslint": "^9.0.0",
107+
"eslint": "^9.1.1",
107108
"eslint-config-prisma": "^0.6.0",
108109
"eslint-plugin-deprecation": "^2.0.0",
109110
"eslint-plugin-only-warn": "^1.1.0",
@@ -119,9 +120,9 @@
119120
"happy-dom": "^14.7.1",
120121
"json-bigint": "^1.0.0",
121122
"tsx": "^4.7.2",
122-
"type-fest": "^4.15.0",
123+
"type-fest": "^4.16.0",
123124
"typescript": "^5.4.5",
124-
"typescript-eslint": "^7.7.0",
125+
"typescript-eslint": "^7.7.1",
125126
"vitest": "^1.5.0"
126127
}
127128
}

pnpm-lock.yaml

Lines changed: 259 additions & 257 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/client.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ export const create = <$Input extends Input>(
127127
const documentString = SelectionSet.selectionSet(documentObjectEncoded)
128128
// todo variables
129129
const result = await executeDocumentExpression({ document: documentString })
130-
// @ts-expect-error todo make global available in TS...
131-
if (result.errors && (result.errors.length > 0)) throw new AggregateError(result.errors) // eslint-disable-line
130+
if (result.errors && (result.errors.length > 0)) throw new AggregateError(result.errors)
132131
// todo check for errors
133132
const dataDecoded = CustomScalars.decode(rootIndex, result.data)
134133
return { ...result, data: dataDecoded }
@@ -169,8 +168,7 @@ export const create = <$Input extends Input>(
169168
switch (returnMode) {
170169
case `data`: {
171170
if (result.errors && result.errors.length > 0) {
172-
// @ts-expect-error fixme -- get this global available
173-
throw new AggregateError(result.errors) // eslint-disable-line
171+
throw new AggregateError(result.errors)
174172
}
175173
return result.data
176174
}

src/entrypoints/main.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {
44
type BatchRequestsExtendedOptions,
55
type BatchRequestsOptions,
66
} from '../raw/functions/batchRequests.js'
7-
import { RequestExtendedOptions } from '../raw/functions/request.js'
7+
import type { RequestExtendedOptions } from '../raw/functions/request.js'
88
import { request } from '../raw/functions/request.js'
99
import type { GraphQLResponse, RequestMiddleware, ResponseMiddleware } from '../raw/helpers/types.js'
10-
import { RawRequestOptions, RequestDocument, RequestOptions, Variables } from '../raw/helpers/types.js'
10+
import type { RawRequestOptions, RequestDocument, RequestOptions, Variables } from '../raw/helpers/types.js'
1111
export { GraphQLClient } from '../raw/classes/GraphQLClient.js'
1212
export { batchRequests } from '../raw/functions/batchRequests.js'
1313
export { gql } from '../raw/functions/gql.js'
@@ -19,13 +19,13 @@ export {
1919
BatchRequestsOptions,
2020
ClientError,
2121
GraphQLResponse,
22-
RawRequestOptions,
22+
type RawRequestOptions,
2323
request,
24-
RequestDocument,
25-
RequestExtendedOptions,
24+
type RequestDocument,
25+
type RequestExtendedOptions,
2626
RequestMiddleware,
27-
RequestOptions,
27+
type RequestOptions,
2828
ResponseMiddleware,
29-
Variables,
29+
type Variables,
3030
}
3131
export default request

src/generator/code/SchemaRuntime.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const index = (config: Config) => {
8484
`
8585
}
8686

87-
const union = (config: Config, type: GraphQLUnionType) => {
87+
const union = (_config: Config, type: GraphQLUnionType) => {
8888
// todo probably need thunks here
8989
const members = type.getTypes().map(t => t.name).join(`, `)
9090
return `
@@ -103,7 +103,7 @@ const interface$ = (config: Config, type: GraphQLInterfaceType) => {
103103
return `export const ${type.name} = $.Interface(\`${type.name}\`, {${fields}}, [${implementors}])`
104104
}
105105

106-
const enum$ = (config: Config, type: GraphQLEnumType) => {
106+
const enum$ = (_config: Config, type: GraphQLEnumType) => {
107107
const members = type.getValues().map((value) => {
108108
return `\`${value.name}\``
109109
}).join(`, `)
@@ -156,7 +156,7 @@ const renderArg = (config: Config, arg: GraphQLArgument) => {
156156
return `${arg.name}: ${type}`
157157
}
158158

159-
const scalar = (config: Config, type: GraphQLScalarType) => {
159+
const scalar = (_config: Config, type: GraphQLScalarType) => {
160160
return `$Scalar.${type.name}`
161161
}
162162

src/lib/graphql.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ export const getNodeName = (node: Describable): NodeNamePlus => {
195195
return `GraphQLScalarType`
196196
default:
197197
return `GraphQLField`
198-
throw new Error(`Unknown node type: ${node.name}`)
199198
}
200199
}
201200

tests/raw/exports.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/raw/general.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ describe(`middleware`, () => {
143143
await client.batchRequests([
144144
{
145145
document: `query x($foo: String) { foo(foo: $foo) }`,
146-
variables: {foo: `bar`},
146+
variables: { foo: `bar` },
147147
},
148148
])
149149
expect(responseMiddleware).toBeCalledTimes(1)
@@ -156,7 +156,7 @@ describe(`middleware`, () => {
156156
variables: [{ foo: `bar` }],
157157
})
158158
})
159-
});
159+
})
160160
})
161161

162162
describe(`async request middleware`, () => {

tsconfig.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
{
2-
"extends": "@tsconfig/node16/tsconfig.json",
2+
"extends": [
3+
"@tsconfig/strictest/tsconfig.json",
4+
"@tsconfig/node18/tsconfig.json"
5+
],
36
"compilerOptions": {
4-
"lib": ["DOM", "DOM.Iterable", "ES2020"],
7+
"lib": ["DOM", "DOM.Iterable", "ES2023"],
8+
59
// Use ESM
610
"module": "NodeNext",
711
"moduleResolution": "nodenext",
812

9-
// Make the compiler stricter, catch more errors
10-
"noImplicitReturns": true,
11-
"noFallthroughCasesInSwitch": true,
12-
"noUncheckedIndexedAccess": true,
13-
"noImplicitOverride": true,
14-
"noPropertyAccessFromIndexSignature": true,
13+
// TODO enable, leads to lots of errors currently.
14+
"exactOptionalPropertyTypes": false,
15+
// We handle these with ESLint:
16+
"noUnusedLocals": false,
17+
"noUnusedParameters": false,
1518

1619
// DX
1720
"sourceMap": true,
@@ -23,7 +26,8 @@
2326

2427
// Other
2528
"skipLibCheck": true,
26-
"esModuleInterop": true
29+
"esModuleInterop": true,
30+
"isolatedModules": false
2731
},
2832
"include": ["src", "tests", "examples"],
2933
"exclude": ["build"]

0 commit comments

Comments
 (0)