diff --git a/src/rz/typescript/add-variable-statement/add-variable-statement.ts b/src/rz/typescript/add-variable-statement/add-variable-statement.ts new file mode 100644 index 0000000..08e1983 --- /dev/null +++ b/src/rz/typescript/add-variable-statement/add-variable-statement.ts @@ -0,0 +1,14 @@ +import { VariableDeclarationKind } from "ts-morph"; +import { EditCodeBlockInput } from "../interfaces/edit-typescript.interface"; + +// right now assumes all methods will be private +export function addVariableDeclarationStatement(editCodeBlockInput: EditCodeBlockInput): void { + const sourceFile = editCodeBlockInput.sourceFile; + sourceFile.insertVariableStatement(0, { + declarationKind: VariableDeclarationKind.Const, + declarations: [{ + name: editCodeBlockInput.name as string, + initializer: editCodeBlockInput.codeBlock + }] + }); +} \ No newline at end of file