Bump to TypeScript 5.5 and enable noImplicitAny

This commit upgrades TypeScript from 5.4 to 5.5 and enables the
`noImplicitAny` option for stricter type checking. It refactors code to
comply with `noImplicitAny` and adapts to new TypeScript features and
limitations.

Key changes:

- Migrate from TypeScript 5.4 to 5.5
- Enable `noImplicitAny` for stricter type checking
- Refactor code to comply with new TypeScript features and limitations

Other supporting changes:

- Refactor progress bar handling for type safety
- Drop 'I' prefix from interfaces to align with new code convention
- Update TypeScript target from `ES2017` and `ES2018`.
  This allows named capturing groups. Otherwise, new TypeScript compiler
  does not compile the project and shows the following error:
  ```
  ...
  TimestampedFilenameGenerator.spec.ts:105:23 - error TS1503: Named capturing groups are only available when targeting 'ES2018' or later
  const pattern = /^(?<timestamp>\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})-(?<scriptName>[^.]+?)(?:\.(?<extension>[^.]+))?$/;// timestamp-scriptName.extension
  ...
  ```
- Refactor usage of `electron-progressbar` for type safety and
  less complexity.
This commit is contained in:
undergroundwires
2024-09-26 16:07:37 +02:00
parent a05a600071
commit e17744faf0
77 changed files with 656 additions and 332 deletions

View File

@@ -7,12 +7,14 @@ import { itIsSingletonFactory } from '@tests/unit/shared/TestCases/SingletonFact
import type { IApplicationContext } from '@/application/Context/IApplicationContext';
import { itIsTransientFactory } from '@tests/unit/shared/TestCases/TransientFactoryTests';
import { executeInComponentSetupContext } from '@tests/shared/Vue/ExecuteInComponentSetupContext';
import type { PropertyKeys } from '@/TypeHelpers';
type InjectionKeyType = PropertyKeys<typeof InjectionKeys>;
type DependencyInjectionTestFunction = (injectionKey: symbol) => void;
describe('DependencyProvider', () => {
describe('provideDependencies', () => {
const testCases: {
readonly [K in keyof typeof InjectionKeys]: (injectionKey: symbol) => void;
} = {
const testCases: Record<InjectionKeyType, DependencyInjectionTestFunction> = {
useCollectionState: createTransientTests(),
useApplication: createSingletonTests(),
useRuntimeEnvironment: createSingletonTests(),
@@ -27,7 +29,8 @@ describe('DependencyProvider', () => {
useAutoUnsubscribedEventListener: createTransientTests(),
};
Object.entries(testCases).forEach(([key, runTests]) => {
const registeredKey = InjectionKeys[key].key;
const injectionKey = key as InjectionKeyType;
const registeredKey = InjectionKeys[injectionKey].key;
describe(`Key: "${registeredKey.toString()}"`, () => {
runTests(registeredKey);
});
@@ -35,7 +38,7 @@ describe('DependencyProvider', () => {
});
});
function createTransientTests() {
function createTransientTests(): DependencyInjectionTestFunction {
return (injectionKey: symbol) => {
it('should register a function when transient dependency is resolved', () => {
// arrange
@@ -73,7 +76,7 @@ function createTransientTests() {
};
}
function createSingletonTests() {
function createSingletonTests(): DependencyInjectionTestFunction {
return (injectionKey: symbol) => {
it('should register an object when singleton dependency is resolved', () => {
// arrange

View File

@@ -1,20 +1,21 @@
import { describe, it, expect } from 'vitest';
import type { ISanityCheckOptions } from '@/infrastructure/RuntimeSanity/Common/ISanityCheckOptions';
import { RuntimeSanityValidator } from '@/presentation/bootstrapping/Modules/RuntimeSanityValidator';
import type { SanityCheckOptions } from '@/infrastructure/RuntimeSanity/Common/SanityCheckOptions';
import { RuntimeSanityBootstrapper } from '@/presentation/bootstrapping/Modules/RuntimeSanityBootstrapper';
import { expectDoesNotThrowAsync, expectThrowsAsync } from '@tests/shared/Assertions/ExpectThrowsAsync';
import type { RuntimeSanityValidator } from '@/infrastructure/RuntimeSanity/SanityChecks';
describe('RuntimeSanityValidator', () => {
describe('RuntimeSanityBootstrapper', () => {
it('calls validator with correct options upon bootstrap', async () => {
// arrange
const expectedOptions: ISanityCheckOptions = {
const expectedOptions: SanityCheckOptions = {
validateEnvironmentVariables: true,
validateWindowVariables: true,
};
let actualOptions: ISanityCheckOptions | undefined;
const validatorMock = (options) => {
let actualOptions: SanityCheckOptions | undefined;
const validatorMock: RuntimeSanityValidator = (options) => {
actualOptions = options;
};
const sut = new RuntimeSanityValidator(validatorMock);
const sut = new RuntimeSanityBootstrapper(validatorMock);
// act
await sut.bootstrap();
// assert
@@ -26,7 +27,7 @@ describe('RuntimeSanityValidator', () => {
const validatorMock = () => {
throw new Error(expectedMessage);
};
const sut = new RuntimeSanityValidator(validatorMock);
const sut = new RuntimeSanityBootstrapper(validatorMock);
// act
const act = async () => { await sut.bootstrap(); };
// assert
@@ -35,7 +36,7 @@ describe('RuntimeSanityValidator', () => {
it('runs successfully if validator passes', async () => {
// arrange
const validatorMock = () => { /* NOOP */ };
const sut = new RuntimeSanityValidator(validatorMock);
const sut = new RuntimeSanityBootstrapper(validatorMock);
// act
const act = async () => { await sut.bootstrap(); };
// assert