From 40ace6efb8db155034f28dda5c159dfb05c42662 Mon Sep 17 00:00:00 2001 From: Dave Cardwell Date: Sun, 18 Feb 2024 02:37:47 -0500 Subject: [PATCH] fix(typescript-checker): support prerelease TypeScript versions (#4738) --- packages/typescript-checker/src/tsconfig-helpers.ts | 2 +- .../test/unit/typescript-helpers.spec.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/typescript-checker/src/tsconfig-helpers.ts b/packages/typescript-checker/src/tsconfig-helpers.ts index 5a2b48d115..b984b603a0 100644 --- a/packages/typescript-checker/src/tsconfig-helpers.ts +++ b/packages/typescript-checker/src/tsconfig-helpers.ts @@ -28,7 +28,7 @@ const LOW_EMIT_OPTIONS_FOR_PROJECT_REFERENCES: Readonly=3.6')) { + if (!semver.satisfies(version, '>=3.6', { includePrerelease: true })) { throw new Error(`@stryker-mutator/typescript-checker only supports typescript@3.6 or higher. Found typescript@${version}`); } } diff --git a/packages/typescript-checker/test/unit/typescript-helpers.spec.ts b/packages/typescript-checker/test/unit/typescript-helpers.spec.ts index 3180c2c3be..e7a12d6209 100644 --- a/packages/typescript-checker/test/unit/typescript-helpers.spec.ts +++ b/packages/typescript-checker/test/unit/typescript-helpers.spec.ts @@ -200,12 +200,20 @@ describe('typescript-helpers', () => { '@stryker-mutator/typescript-checker only supports typescript@3.6 or higher. Found typescript@3.5.0', ); }); + it('should throw if typescript@3.5.0-beta', () => { + expect(guardTSVersion.bind(undefined, '3.5.0-beta')).throws( + '@stryker-mutator/typescript-checker only supports typescript@3.6 or higher. Found typescript@3.5.0-beta', + ); + }); it('should not throw if typescript@3.6.0', () => { expect(guardTSVersion.bind(undefined, '3.6.0')).not.throws(); }); it('should not throw if typescript@4.0.0', () => { expect(guardTSVersion.bind(undefined, '4.0.0')).not.throws(); }); + it('should not throw if typescript@5.4.0-beta', () => { + expect(guardTSVersion.bind(undefined, '5.4.0-beta')).not.throws(); + }); }); describe(getSourceMappingURL.name, () => {