Skip to content

Commit

Permalink
ZETA-6981: Add intial file for adding a varaible statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieGreenman committed Oct 29, 2023
1 parent cc1e7b9 commit 6ef8d65
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/rz/typescript/add-variable-statement/add-variable-statement.ts
Original file line number Diff line number Diff line change
@@ -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
}]
});
}

0 comments on commit 6ef8d65

Please sign in to comment.