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
28 lines
638 B
TypeScript
28 lines
638 B
TypeScript
import { XmlAttributeComponent, XmlComponent } from "../xml-components";
|
|
|
|
interface IRunFontAttributesProperties {
|
|
ascii: string;
|
|
hAnsi: string;
|
|
hint?: string;
|
|
}
|
|
|
|
class RunFontAttributes extends XmlAttributeComponent<IRunFontAttributesProperties> {
|
|
protected xmlKeys = {
|
|
ascii: "w:ascii",
|
|
hAnsi: "w:hAnsi",
|
|
hint: "w:hint",
|
|
};
|
|
}
|
|
|
|
export class RunFonts extends XmlComponent {
|
|
|
|
constructor(ascii: string, hint?: string) {
|
|
super("w:rFonts");
|
|
this.root.push(new RunFontAttributes({
|
|
ascii: ascii,
|
|
hAnsi: ascii,
|
|
hint: hint,
|
|
}));
|
|
}
|
|
}
|