@@ -18,6 +18,8 @@ if (require.main === module) {
18
18
fs . rmSync ( './npmDist' , { recursive : true , force : true } ) ;
19
19
fs . mkdirSync ( './npmDist' ) ;
20
20
21
+ const packageJSON = buildPackageJSON ( ) ;
22
+
21
23
const srcFiles = readdirRecursive ( './src' , { ignoreDir : / ^ _ _ .* _ _ $ / } ) ;
22
24
for ( const filepath of srcFiles ) {
23
25
const srcPath = path . join ( './src' , filepath ) ;
@@ -48,11 +50,23 @@ if (require.main === module) {
48
50
'Fail to generate `*.d.ts` files, please run `npm run check`' ,
49
51
) ;
50
52
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
+
51
66
fs . copyFileSync ( './LICENSE' , './npmDist/LICENSE' ) ;
52
67
fs . copyFileSync ( './README.md' , './npmDist/README.md' ) ;
53
68
54
69
// Should be done as the last step so only valid packages can be published
55
- const packageJSON = buildPackageJSON ( ) ;
56
70
writeGeneratedFile ( './npmDist/package.json' , JSON . stringify ( packageJSON ) ) ;
57
71
58
72
showDirStats ( './npmDist' ) ;
0 commit comments