Skip to content

Commit d2eb7bd

Browse files
committed
version: force proper typing on version literals
Types should be generic and stay the same across different versions E.g. `preReleaseTag` should be typed `string | null` even if it's a `null` literal for this particular release
1 parent 6453612 commit d2eb7bd

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

resources/gen-version.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ const body = `
1818
/**
1919
* A string containing the version of the GraphQL.js library
2020
*/
21-
export const version = '${version}';
21+
export const version = '${version}' as string;
2222
2323
/**
2424
* An object containing the components of the GraphQL.js version string
2525
*/
2626
export const versionInfo = Object.freeze({
27-
major: ${major},
28-
minor: ${minor},
29-
patch: ${patch},
30-
preReleaseTag: ${preReleaseTag ? `'${preReleaseTag}'` : 'null'},
27+
major: ${major} as number,
28+
minor: ${minor} as number,
29+
patch: ${patch} as number,
30+
preReleaseTag: ${
31+
preReleaseTag ? `'${preReleaseTag}'` : 'null'
32+
} as string | null,
3133
});
3234
`;
3335

src/version.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
/**
55
* A string containing the version of the GraphQL.js library
66
*/
7-
export const version = '16.0.0-rc.7';
7+
export const version = '16.0.0-rc.7' as string;
88

99
/**
1010
* An object containing the components of the GraphQL.js version string
1111
*/
1212
export const versionInfo = Object.freeze({
13-
major: 16,
14-
minor: 0,
15-
patch: 0,
16-
preReleaseTag: 'rc.7',
13+
major: 16 as number,
14+
minor: 0 as number,
15+
patch: 0 as number,
16+
preReleaseTag: 'rc.7' as string | null,
1717
});

0 commit comments

Comments
 (0)