tightened type checking for tab stops

This commit is contained in:
felipe
2017-03-12 22:06:11 +01:00
parent 0b78e33444
commit a6e40d9d92

View File

@ -1,4 +1,4 @@
import { Attributes, XmlComponent } from "../xml-components"; import { XmlAttributeComponent, XmlComponent } from "../xml-components";
class TabStop extends XmlComponent { 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 { class Tab extends XmlComponent {
constructor(value: string, position: string | number) { constructor(value: tabOptions, position: string | number) {
super("w:tab"); super("w:tab");
this.root.push(new Attributes({ this.root.push(new TabAttributes({
val: value, val: value,
pos: position, pos: position,
})); }));