Skip to content

Commit 4440121

Browse files
committed
Add message that we only support TS >= 4.1.0
1 parent ada5ee0 commit 4440121

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

integrationTests/ts/basic-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ExecutionResult } from 'graphql/execution';
1+
import type { ExecutionResult } from 'graphql/execution/execute';
22

33
import { graphqlSync } from 'graphql';
44
import { GraphQLString, GraphQLSchema, GraphQLObjectType } from 'graphql/type';

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
"private": true,
77
"main": "index",
88
"module": "index.mjs",
9-
"types": "index.d.ts",
9+
"types": "NotSupportedTSVersion.d.ts",
10+
"typesVersions": {
11+
">=4.1.0": {
12+
"*": ["index.d.ts"],
13+
"*/*": ["*/index.d.ts"],
14+
"*/*/*": ["*/*"]
15+
}
16+
},
1017
"sideEffects": false,
1118
"homepage": "https://github.com/graphql/graphql-js",
1219
"bugs": {

resources/build-npm.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ if (require.main === module) {
1818
fs.rmSync('./npmDist', { recursive: true, force: true });
1919
fs.mkdirSync('./npmDist');
2020

21+
const packageJSON = buildPackageJSON();
22+
2123
const srcFiles = readdirRecursive('./src', { ignoreDir: /^__.*__$/ });
2224
for (const filepath of srcFiles) {
2325
const srcPath = path.join('./src', filepath);
@@ -48,11 +50,23 @@ if (require.main === module) {
4850
'Fail to generate `*.d.ts` files, please run `npm run check`',
4951
);
5052

53+
assert(packageJSON.types, 'Missing "types".');
54+
const supportedTSVersions = Object.keys(packageJSON.typesVersions);
55+
assert(
56+
supportedTSVersions.length === 1,
57+
'Property "typesVersions" should have exactly one key.',
58+
);
59+
// TODO: revisit once TS implements https://github.com/microsoft/TypeScript/issues/44795
60+
fs.writeFileSync(
61+
path.join('./npmDist', packageJSON.types),
62+
// Provoke syntax error to show this message
63+
`"Package 'graphql' support only TS versions that are ${supportedTSVersions[0]}".`,
64+
);
65+
5166
fs.copyFileSync('./LICENSE', './npmDist/LICENSE');
5267
fs.copyFileSync('./README.md', './npmDist/README.md');
5368

5469
// Should be done as the last step so only valid packages can be published
55-
const packageJSON = buildPackageJSON();
5670
writeGeneratedFile('./npmDist/package.json', JSON.stringify(packageJSON));
5771

5872
showDirStats('./npmDist');

0 commit comments

Comments
 (0)