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.
34 lines
914 B
TypeScript
34 lines
914 B
TypeScript
import { ScriptingLanguage } from './ScriptingLanguage';
|
|
import type { IScriptingDefinition } from './IScriptingDefinition';
|
|
|
|
export class ScriptingDefinition implements IScriptingDefinition {
|
|
public readonly fileExtension: string;
|
|
|
|
constructor(
|
|
public readonly language: ScriptingLanguage,
|
|
public readonly startCode: string,
|
|
public readonly endCode: string,
|
|
) {
|
|
this.fileExtension = findExtension(language);
|
|
validateCode(startCode, 'start code');
|
|
validateCode(endCode, 'end code');
|
|
}
|
|
}
|
|
|
|
function findExtension(language: ScriptingLanguage): string {
|
|
switch (language) {
|
|
case ScriptingLanguage.shellscript:
|
|
return 'sh';
|
|
case ScriptingLanguage.batchfile:
|
|
return 'bat';
|
|
default:
|
|
throw new Error(`unsupported language: ${language}`);
|
|
}
|
|
}
|
|
|
|
function validateCode(code: string, name: string) {
|
|
if (!code) {
|
|
throw new Error(`missing ${name}`);
|
|
}
|
|
}
|