Skip to content

Commit

Permalink
version: force proper typing on version literals
Browse files Browse the repository at this point in the history
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
  • Loading branch information
IvanGoncharov committed Oct 28, 2021
1 parent 6453612 commit a27ad0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions resources/gen-version.js
Expand Up @@ -18,16 +18,16 @@ const body = `
/**
* A string containing the version of the GraphQL.js library
*/
export const version = '${version}';
export const version = '${version}' as string;
/**
* An object containing the components of the GraphQL.js version string
*/
export const versionInfo = Object.freeze({
major: ${major},
minor: ${minor},
patch: ${patch},
preReleaseTag: ${preReleaseTag ? `'${preReleaseTag}'` : 'null'},
major: ${major} as number,
minor: ${minor} as number,
patch: ${patch} as number,
preReleaseTag: ${preReleaseTag ? `'${preReleaseTag}'` : 'null'} as string | null,
});
`;

Expand Down
10 changes: 5 additions & 5 deletions src/version.ts
Expand Up @@ -4,14 +4,14 @@
/**
* A string containing the version of the GraphQL.js library
*/
export const version = '16.0.0-rc.7';
export const version = '16.0.0-rc.7' as string;

/**
* An object containing the components of the GraphQL.js version string
*/
export const versionInfo = Object.freeze({
major: 16,
minor: 0,
patch: 0,
preReleaseTag: 'rc.7',
major: 16 as number,
minor: 0 as number,
patch: 0 as number,
preReleaseTag: 'rc.7' as string | null,
});

0 comments on commit a27ad0b

Please sign in to comment.