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:
@@ -17,7 +17,7 @@ describe('parseTreeInput', () => {
|
||||
|
||||
it('returns an empty array if given an empty array', () => {
|
||||
// arrange
|
||||
const input = [];
|
||||
const input = new Array<TreeInputNodeData>();
|
||||
// act
|
||||
const nodes = parseTreeInput(input);
|
||||
// assert
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SingleNodeCollectionFocusManager } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/Focus/SingleNodeCollectionFocusManager';
|
||||
import type { TreeNodeCollection } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/NodeCollection/TreeNodeCollection';
|
||||
import { TreeNodeInitializerAndUpdater } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/NodeCollection/TreeNodeInitializerAndUpdater';
|
||||
import { TreeRootManager } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/TreeRootManager';
|
||||
import { TreeRootManager, type FocusManagerFactory } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/TreeRootManager';
|
||||
import { SingleNodeFocusManagerStub } from '@tests/unit/shared/Stubs/SingleNodeFocusManagerStub';
|
||||
import { TreeNodeCollectionStub } from '@tests/unit/shared/Stubs/TreeNodeCollectionStub';
|
||||
|
||||
@@ -19,9 +19,12 @@ describe('TreeRootManager', () => {
|
||||
it('set by constructor as expected', () => {
|
||||
// arrange
|
||||
const expectedCollection = new TreeNodeCollectionStub();
|
||||
const sut = new TreeRootManager();
|
||||
const context = new TestContext()
|
||||
.withNodeCollection(expectedCollection);
|
||||
// act
|
||||
const actualCollection = sut.collection;
|
||||
const actualCollection = context
|
||||
.build()
|
||||
.collection;
|
||||
// assert
|
||||
expect(actualCollection).to.equal(expectedCollection);
|
||||
});
|
||||
@@ -39,15 +42,41 @@ describe('TreeRootManager', () => {
|
||||
it('creates with same collection it uses', () => {
|
||||
// arrange
|
||||
let usedCollection: TreeNodeCollection | undefined;
|
||||
const factoryMock = (collection) => {
|
||||
const factoryMock: FocusManagerFactory = (collection) => {
|
||||
usedCollection = collection;
|
||||
return new SingleNodeFocusManagerStub();
|
||||
};
|
||||
const sut = new TreeRootManager(new TreeNodeCollectionStub(), factoryMock);
|
||||
const context = new TestContext()
|
||||
.withFocusManagerFactory(factoryMock);
|
||||
// act
|
||||
const expected = sut.collection;
|
||||
const expected = context
|
||||
.build()
|
||||
.collection;
|
||||
// assert
|
||||
expect(usedCollection).to.equal(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
class TestContext {
|
||||
private nodeCollection: TreeNodeCollection = new TreeNodeCollectionStub();
|
||||
|
||||
private focusManagerFactory: FocusManagerFactory = () => new SingleNodeFocusManagerStub();
|
||||
|
||||
public withFocusManagerFactory(focusManagerFactory: FocusManagerFactory): this {
|
||||
this.focusManagerFactory = focusManagerFactory;
|
||||
return this;
|
||||
}
|
||||
|
||||
public withNodeCollection(nodeCollection: TreeNodeCollection): this {
|
||||
this.nodeCollection = nodeCollection;
|
||||
return this;
|
||||
}
|
||||
|
||||
public build(): TreeRootManager {
|
||||
return new TreeRootManager(
|
||||
this.nodeCollection,
|
||||
this.focusManagerFactory,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user