diff --git a/README.md b/README.md index e221feb..448b30d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ A type-safe way to write GraphQL. Express your query as a plain object. Keep you ## Getting started -`gql-in-ts` supports TypeScript 4.4 thru 4.9. +`gql-in-ts` supports TypeScript 4.4 thru 5.1. Install the library: diff --git a/package-lock.json b/package-lock.json index 21a9be0..2705d6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,9 @@ "ts4.7": "npm:typescript@4.7", "ts4.8": "npm:typescript@4.8", "ts4.9": "npm:typescript@4.9", - "typescript": "^4.9.0", + "ts5.0": "npm:typescript@5.0", + "ts5.1": "npm:typescript@5.1", + "typescript": "^5.1.0", "vitest": "^0.18.1" } }, @@ -2136,6 +2138,34 @@ "node": ">=4.2.0" } }, + "node_modules/ts5.0": { + "name": "typescript", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=12.20" + } + }, + "node_modules/ts5.1": { + "name": "typescript", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -2191,16 +2221,16 @@ } }, "node_modules/typescript": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", - "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/uri-js": { @@ -3724,6 +3754,18 @@ "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", "dev": true }, + "ts5.0": { + "version": "npm:typescript@5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "dev": true + }, + "ts5.1": { + "version": "npm:typescript@5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "dev": true + }, "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -3761,9 +3803,9 @@ "dev": true }, "typescript": { - "version": "4.9.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", - "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", "dev": true }, "uri-js": { diff --git a/package.json b/package.json index f12b7ed..e1b328d 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,9 @@ "ts4.7": "npm:typescript@4.7", "ts4.8": "npm:typescript@4.8", "ts4.9": "npm:typescript@4.9", - "typescript": "^4.9.0", + "ts5.0": "npm:typescript@5.0", + "ts5.1": "npm:typescript@5.1", + "typescript": "^5.1.0", "vitest": "^0.18.1" }, "scripts": { @@ -56,4 +58,4 @@ "dependencies": { "graphql": "^15.8.0" } -} +} \ No newline at end of file diff --git a/scripts/typecheck.mjs b/scripts/typecheck.mjs index f7604b8..2a60906 100644 --- a/scripts/typecheck.mjs +++ b/scripts/typecheck.mjs @@ -4,12 +4,17 @@ import ts4_6 from 'ts4.6'; import ts4_7 from 'ts4.7'; import ts4_8 from 'ts4.8'; import ts4_9 from 'ts4.9'; +import ts5_0 from 'ts5.0'; +import ts5_1 from 'ts5.1'; import * as path from 'path'; import { readFileSync } from 'fs'; const CONFIG_FILE_PATH = './tsconfig.test.json'; +// This script runs tsc of different versions programatically. +// Most of the source code is taken from this issue comment: // https://github.com/Microsoft/TypeScript/issues/6387#issuecomment-169739615 + const readFile = (path) => readFileSync(path, { encoding: 'utf-8' }); // Having one version per line is handy when toggling versions to test. @@ -21,6 +26,8 @@ const diagnosticsCount = [ ts4_7, ts4_8, ts4_9, + ts5_0, + ts5_1 ].map( (ts) => { const readConfigResult = ts.readConfigFile(CONFIG_FILE_PATH, readFile); diff --git a/src/graphql.ts b/src/graphql.ts index d926511..35696fd 100644 --- a/src/graphql.ts +++ b/src/graphql.ts @@ -314,7 +314,7 @@ type ResultForOutputObjectType< // | { __typename: 'A' | 'B'; } // ----------------------------- Union candidate 1 // | { __typename: 'A'; fieldSpecificToA: ; } // --- Union candidate 2 // - // The above type is hardly useless because one cannot discriminate + // The above type is hardly useful because one cannot discriminate // union candidates based on the value of __typename. // To be able to use __typename as a tag for telling apart the union // constituents, __typename of union candidate 1 have to be narrowed