Skip to content

Commit

Permalink
Made XmlableObject non ambient typings to fix typescript problem
Browse files Browse the repository at this point in the history
  • Loading branch information
dolanmiu committed Jul 8, 2017
1 parent 6784dc1 commit 8f632d4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ts/docx/table/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Paragraph } from "../paragraph";
import { XmlComponent } from "../xml-components";

import { IXmlableObject } from "../xml-components/xmlable-object";
import { TableGrid } from "./grid";
import { TableProperties, WidthTypes } from "./properties";

Expand Down Expand Up @@ -99,7 +99,7 @@ export class TableCell extends XmlComponent {
return this;
}

public prepForXml(): XmlableObject {
public prepForXml(): IXmlableObject {
// Cells must end with a paragraph
const retval = super.prepForXml();
const content = retval["w:tc"];
Expand Down
4 changes: 3 additions & 1 deletion ts/docx/xml-components/base.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { IXmlableObject } from "./xmlable-object";

export abstract class BaseXmlComponent {
protected rootKey: string;

constructor(rootKey: string) {
this.rootKey = rootKey;
}

public abstract prepForXml(): XmlableObject;
public abstract prepForXml(): IXmlableObject;
}
3 changes: 2 additions & 1 deletion ts/docx/xml-components/default-attributes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BaseXmlComponent } from "./base";
import { IXmlableObject } from "./xmlable-object";

export type AttributeMap<T> = {[P in keyof T]: string};

Expand All @@ -11,7 +12,7 @@ export abstract class XmlAttributeComponent<T> extends BaseXmlComponent {
this.root = properties;
}

public prepForXml(): XmlableObject {
public prepForXml(): IXmlableObject {
const attrs = {};
Object.keys(this.root).forEach((key) => {
const value = this.root[key];
Expand Down
3 changes: 2 additions & 1 deletion ts/docx/xml-components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BaseXmlComponent } from "./base";
import { IXmlableObject } from "./xmlable-object";
export { BaseXmlComponent };

export abstract class XmlComponent extends BaseXmlComponent {
Expand All @@ -9,7 +10,7 @@ export abstract class XmlComponent extends BaseXmlComponent {
this.root = new Array<BaseXmlComponent>();
}

public prepForXml(): XmlableObject {
public prepForXml(): IXmlableObject {
const children = this.root.map((comp) => {
if (comp instanceof BaseXmlComponent) {
return comp.prepForXml();
Expand Down
3 changes: 0 additions & 3 deletions ts/docx/xml-components/xmlable-object.d.ts

This file was deleted.

3 changes: 3 additions & 0 deletions ts/docx/xml-components/xmlable-object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface IXmlableObject extends Object {
_attr?: { [key: string]: (string | number | boolean) };
}
3 changes: 2 additions & 1 deletion ts/export/formatter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { BaseXmlComponent } from "../docx/xml-components";
import { IXmlableObject } from "../docx/xml-components/xmlable-object";

export class Formatter {
public format(input: BaseXmlComponent): XmlableObject {
public format(input: BaseXmlComponent): IXmlableObject {
return input.prepForXml();
}
}

0 comments on commit 8f632d4

Please sign in to comment.