This change brings increased type safety to uses of XmlAttributeComponent. Now the compiler is checkign for us that the properties that get passed in to every subclass match the intended interface, and also that the xmlKeys property -> xml attribute mapping has all the right keys
25 lines
569 B
TypeScript
25 lines
569 B
TypeScript
import { XmlAttributeComponent, XmlComponent } from "../xml-components";
|
|
|
|
interface IIndentAttributesProperties {
|
|
left: number;
|
|
hanging: number;
|
|
}
|
|
|
|
class IndentAttributes extends XmlAttributeComponent<IIndentAttributesProperties> {
|
|
protected xmlKeys = {
|
|
left: "w:left",
|
|
hanging: "w:hanging",
|
|
};
|
|
}
|
|
|
|
export class Indent extends XmlComponent {
|
|
|
|
constructor(left: number, hanging?: number) {
|
|
super("w:ind");
|
|
this.root.push(new IndentAttributes({
|
|
left: left,
|
|
hanging: hanging,
|
|
}));
|
|
}
|
|
}
|