This commit upgrades TypeScript to the latest version 5.3 and introduces `verbatimModuleSyntax` in line with the official Vue guide recommendatinos (vuejs/docs#2592). By enforcing `import type` for type-only imports, this commit improves code clarity and supports tooling optimization, ensuring imports are only bundled when necessary for runtime. Changes: - Bump TypeScript to 5.3.3 across the project. - Adjust import statements to utilize `import type` where applicable, promoting cleaner and more efficient code.
32 lines
949 B
TypeScript
32 lines
949 B
TypeScript
import type { IEnumParser } from '@/application/Common/Enum';
|
|
|
|
export class EnumParserStub<T> implements IEnumParser<T> {
|
|
private readonly scenarios = new Array<{
|
|
inputName: string, inputValue: string, outputValue: T }>();
|
|
|
|
private defaultValue: T;
|
|
|
|
public setup(inputName: string, inputValue: string, outputValue: T) {
|
|
this.scenarios.push({ inputName, inputValue, outputValue });
|
|
return this;
|
|
}
|
|
|
|
public setupDefaultValue(outputValue: T) {
|
|
this.defaultValue = outputValue;
|
|
return this;
|
|
}
|
|
|
|
public parseEnum(value: string, propertyName: string): T {
|
|
const scenario = this.scenarios.find(
|
|
(s) => s.inputName === propertyName && s.inputValue === value,
|
|
);
|
|
if (scenario) {
|
|
return scenario.outputValue;
|
|
}
|
|
if (this.defaultValue !== undefined) {
|
|
return this.defaultValue;
|
|
}
|
|
throw new Error(`Don't know now what to return from ${EnumParserStub.name}, forgot to set-up?`);
|
|
}
|
|
}
|