From a6e40d9d922ce2d32f28db182ee52c6c7120516b Mon Sep 17 00:00:00 2001 From: felipe Date: Sun, 12 Mar 2017 22:06:11 +0100 Subject: [PATCH] tightened type checking for tab stops --- ts/docx/paragraph/tab-stop.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ts/docx/paragraph/tab-stop.ts b/ts/docx/paragraph/tab-stop.ts index f531f6ba84..6154c33d2a 100644 --- a/ts/docx/paragraph/tab-stop.ts +++ b/ts/docx/paragraph/tab-stop.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "../xml-components"; class TabStop extends XmlComponent { @@ -8,11 +8,17 @@ class TabStop extends XmlComponent { } } +export type tabOptions = "left" | "right"; + +class TabAttributes extends XmlAttributeComponent<{val: tabOptions, pos: string | number}> { + protected xmlKeys = {val: "w:val", pos: "w:pos"}; +} + class Tab extends XmlComponent { - constructor(value: string, position: string | number) { + constructor(value: tabOptions, position: string | number) { super("w:tab"); - this.root.push(new Attributes({ + this.root.push(new TabAttributes({ val: value, pos: position, }));