• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import * as semver from 'semver';
2import * as ts from 'typescript';
3
4function semverCheck(version: string): boolean {
5  return semver.satisfies(
6    ts.version,
7    `>= ${version}.0 || >= ${version}.1-rc || >= ${version}.0-beta`,
8    {
9      includePrerelease: true,
10    },
11  );
12}
13
14const versions = [
15  //
16  '3.7',
17  '3.8',
18  '3.9',
19  '4.0',
20] as const;
21type Versions = typeof versions extends ArrayLike<infer U> ? U : never;
22
23const typescriptVersionIsAtLeast = {} as Record<Versions, boolean>;
24for (const version of versions) {
25  typescriptVersionIsAtLeast[version] = semverCheck(version);
26}
27
28export { typescriptVersionIsAtLeast };
29