make XmlAttributeComponent into a generic class
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
This commit is contained in:
@ -4,10 +4,8 @@ interface IComponentAttributes {
|
||||
val: string;
|
||||
}
|
||||
|
||||
class ComponentAttributes extends XmlAttributeComponent {
|
||||
constructor(properties: IComponentAttributes) {
|
||||
super({val: "w:val"}, properties);
|
||||
}
|
||||
class ComponentAttributes extends XmlAttributeComponent<IComponentAttributes> {
|
||||
protected xmlKeys = {val: "w:val"};
|
||||
}
|
||||
|
||||
export class Name extends XmlComponent {
|
||||
|
@ -14,15 +14,13 @@ export interface IStyleAttributes {
|
||||
customStyle?: string;
|
||||
}
|
||||
|
||||
class StyleAttributes extends XmlAttributeComponent {
|
||||
constructor(properties: IStyleAttributes) {
|
||||
super({
|
||||
type: "w:type",
|
||||
styleId: "w:styleId",
|
||||
default: "w:default",
|
||||
customStyle: "w:customStyle",
|
||||
}, properties);
|
||||
}
|
||||
class StyleAttributes extends XmlAttributeComponent<IStyleAttributes> {
|
||||
protected xmlKeys = {
|
||||
type: "w:type",
|
||||
styleId: "w:styleId",
|
||||
default: "w:default",
|
||||
customStyle: "w:customStyle",
|
||||
};
|
||||
}
|
||||
|
||||
export class Style extends XmlComponent {
|
||||
|
Reference in New Issue
Block a user