Skip to content

Commit 78f3479

Browse files
committed
fix: type-level arithmetic!
Working around microsoft/TypeScript#26382, which will likely never get solved.
1 parent cf1ba92 commit 78f3479

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/min-version.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ const chalk = require('chalk');
88
const ErrorMessage = require('./error-message');
99
const PathHelpers = require('./path-helpers');
1010

11-
const minimalVersion = {major: 2, minor: 14};
12-
// prettier-ignore
13-
const supportedRange = `${minimalVersion.major}.${minimalVersion.minor}.0 <= v < ${minimalVersion.major + 1}.0.0`
11+
const minimalVersion = /** @type {const} */ ({major: 2, minor: 14});
12+
13+
// TS can't do arithmetic, so make sure the cast is right when bumping the major.
14+
const nextMajor = /** @type {3} */ (minimalVersion.major + 1);
15+
16+
const supportedRange = /** @type {const} */ (
17+
`${minimalVersion.major}.${minimalVersion.minor}.0 <= v < ${nextMajor}.0.0`
18+
);
1419

1520
/**
1621
* If given an input version string smaller than the hardcoded `minimalVersion`,

0 commit comments

Comments
 (0)