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
23 lines
542 B
TypeScript
23 lines
542 B
TypeScript
import { XmlAttributeComponent, XmlComponent } from "../xml-components";
|
|
|
|
export interface ISpacingProperties {
|
|
after?: number;
|
|
before?: number;
|
|
line?: number;
|
|
}
|
|
|
|
class SpacingAttributes extends XmlAttributeComponent<ISpacingProperties> {
|
|
protected xmlKeys = {
|
|
after: "w:after",
|
|
before: "w:before",
|
|
line: "w:line",
|
|
};
|
|
}
|
|
|
|
export class Spacing extends XmlComponent {
|
|
constructor(opts: ISpacingProperties) {
|
|
super("w:spacing");
|
|
this.root.push(new SpacingAttributes(opts));
|
|
}
|
|
}
|