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.
46 lines
1.9 KiB
TypeScript
46 lines
1.9 KiB
TypeScript
import { ExpressionPosition } from '@/application/Parser/Executable/Script/Compiler/Expressions/Expression/ExpressionPosition';
|
|
import type { IExpression } from '@/application/Parser/Executable/Script/Compiler/Expressions/Expression/IExpression';
|
|
import type { IReadOnlyFunctionParameterCollection } from '@/application/Parser/Executable/Script/Compiler/Function/Parameter/IFunctionParameterCollection';
|
|
import type { IExpressionEvaluationContext } from '@/application/Parser/Executable/Script/Compiler/Expressions/Expression/ExpressionEvaluationContext';
|
|
import { FunctionParameterCollectionStub } from './FunctionParameterCollectionStub';
|
|
|
|
export class ExpressionStub implements IExpression {
|
|
public callHistory = new Array<IExpressionEvaluationContext>();
|
|
|
|
public position = new ExpressionPosition(0, 5);
|
|
|
|
public parameters: IReadOnlyFunctionParameterCollection = new FunctionParameterCollectionStub();
|
|
|
|
private result = `[${ExpressionStub.name}] result`;
|
|
|
|
public withParameters(parameters: IReadOnlyFunctionParameterCollection) {
|
|
this.parameters = parameters;
|
|
return this;
|
|
}
|
|
|
|
public withParameterNames(parameterNames: readonly string[], isOptional = false) {
|
|
const collection = new FunctionParameterCollectionStub()
|
|
.withParameterNames(parameterNames, isOptional);
|
|
return this.withParameters(collection);
|
|
}
|
|
|
|
public withPosition(start: number, end: number) {
|
|
this.position = new ExpressionPosition(start, end);
|
|
return this;
|
|
}
|
|
|
|
public withEvaluatedResult(result: string) {
|
|
this.result = result;
|
|
return this;
|
|
}
|
|
|
|
public evaluate(context: IExpressionEvaluationContext): string {
|
|
this.callHistory.push(context);
|
|
if (this.result === undefined /* not empty string */) {
|
|
const { args } = context;
|
|
return `[expression-stub] args: ${args ? Object.entries(args).map((key, value) => `${key}: ${value}`).join('", "') : 'none'}`;
|
|
}
|
|
return this.result;
|
|
}
|
|
}
|