Merge pull request #1898 from dolanmiu/feat/strict-types-for-File-Child

Add strict types for file child
This commit is contained in:
Dolan
2023-01-23 15:01:03 +00:00
committed by GitHub
5 changed files with 14 additions and 10 deletions

5
src/file/file-child.ts Normal file
View File

@ -0,0 +1,5 @@
import { XmlComponent } from "@file/xml-components";
export class FileChild extends XmlComponent {
public readonly fileChild = Symbol();
}

View File

@ -11,15 +11,13 @@ import { Footer, Header } from "./header";
import { HeaderWrapper, IDocumentHeader } from "./header-wrapper";
import { Media } from "./media";
import { Numbering } from "./numbering";
import { Paragraph } from "./paragraph";
import { Comments } from "./paragraph/run/comment-run";
import { Relationships } from "./relationships";
import { Settings } from "./settings";
import { Styles } from "./styles";
import { ExternalStylesFactory } from "./styles/external-styles-factory";
import { DefaultStylesFactory } from "./styles/factory";
import { Table } from "./table";
import { TableOfContents } from "./table-of-contents";
import { FileChild } from "./file-child";
export interface ISectionOptions {
readonly headers?: {
@ -33,7 +31,7 @@ export interface ISectionOptions {
readonly even?: Footer;
};
readonly properties?: ISectionPropertiesOptions;
readonly children: readonly (Paragraph | Table | TableOfContents)[];
readonly children: readonly FileChild[];
}
export class File {

View File

@ -1,7 +1,8 @@
// http://officeopenxml.com/WPparagraph.php
import { FootnoteReferenceRun } from "@file/footnotes";
import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components";
import { IContext, IXmlableObject } from "@file/xml-components";
import { uniqueId } from "@util/convenience-functions";
import { FileChild } from "@file/file-child";
import { TargetModeType } from "../relationships/relationship/relationship";
import { DeletedTextRun, InsertedTextRun } from "../track-revision";
@ -39,7 +40,7 @@ export interface IParagraphOptions extends IParagraphPropertiesOptions {
readonly children?: readonly ParagraphChild[];
}
export class Paragraph extends XmlComponent {
export class Paragraph extends FileChild {
private readonly properties: ParagraphProperties;
public constructor(options: string | IParagraphOptions) {

View File

@ -3,13 +3,13 @@
import { Paragraph } from "@file/paragraph";
import { Run } from "@file/paragraph/run";
import { Begin, End, Separate } from "@file/paragraph/run/field";
import { XmlComponent } from "@file/xml-components";
import { FileChild } from "@file/file-child";
import { FieldInstruction } from "./field-instruction";
import { StructuredDocumentTagContent } from "./sdt-content";
import { StructuredDocumentTagProperties } from "./sdt-properties";
import { ITableOfContentsOptions } from "./table-of-contents-properties";
export class TableOfContents extends XmlComponent {
export class TableOfContents extends FileChild {
public constructor(alias: string = "Table of Contents", properties?: ITableOfContentsOptions) {
super("w:sdt");
this.root.push(new StructuredDocumentTagProperties(alias));

View File

@ -1,5 +1,5 @@
// http://officeopenxml.com/WPtableGrid.php
import { XmlComponent } from "@file/xml-components";
import { FileChild } from "@file/file-child";
import { AlignmentType } from "../paragraph";
import { TableGrid } from "./grid";
@ -34,7 +34,7 @@ export interface ITableOptions {
readonly visuallyRightToLeft?: boolean;
}
export class Table extends XmlComponent {
export class Table extends FileChild {
public constructor({
rows,
width,