ascii-table icon indicating copy to clipboard operation
ascii-table copied to clipboard

Example d.ts code for Typescript

Open wraith4081 opened this issue 2 years ago • 4 comments

I love this project, but for Typescript I have to write it myself every time. Here is a sample code for those looking for d.ts for Typescript.

declare module 'ascii-table' {
  export default class AsciiTable {
    constructor(title?: string);

    setTitle(title: string): void;
    setHeading(...headings: string[]): void;
    addRow(...values: string[]): void;
    addRow(row: string[]): void;
    addRow(row: Record<string, string>): void;
    addRow(row: string[], truncate: boolean): void;
    addRow(row: Record<string, string>, truncate: boolean): void;
    setAlign(column: number, alignment: 'left' | 'center' | 'right'): void;
    setAlign(alignments: ('left' | 'center' | 'right')[]): void;
    setJustify(column: number, justify: boolean): void;
    setJustify(justify: boolean[]): void;
    setChars(chars: Record<string, string>): void;
    setStyle(style: 'default' | 'fat' | 'thin' | 'double' | 'round' | 'single'): void;
    setBorder(border: boolean): void;
    setTruncate(truncate: boolean): void;
    setMaxColWidth(maxWidth: number): void;
    setMinColWidth(minWidth: number): void;
    setColWidth(column: number, width: number): void;
    setColWidths(widths: number[]): void;
    setDefaultColWidth(width: number): void;
    setDefaultAlignment(alignment: 'left' | 'center' | 'right'): void;
    setDefaultJustify(justify: boolean): void;
    setDefaultTruncate(truncate: boolean): void;
    setDefaultMaxColWidth(maxWidth: number): void;
    setDefaultMinColWidth(minWidth: number): void;
    setDefaultStyle(style: 'default' | 'fat' | 'thin' | 'double' | 'round' | 'single'): void;
    setDefaultBorder(border: boolean): void;
    setDefaultChars(chars: Record<string, string>): void;
    toString(): string;
  }
}

wraith4081 avatar Sep 09 '23 10:09 wraith4081

You saved me time, thanks! I would like to suggest you add removeBorder(): void to the code

ruj avatar Oct 12 '23 17:10 ruj

You saved me time, thanks! I would like to suggest you add removeBorder(): void to the code

You're welcome. Thanks for noticing the a missing part.

wraith4081 avatar Oct 12 '23 17:10 wraith4081

Thanks for sharing these!

One method that I noticed is missing from the list is addRowMatrix:

addRowMatrix(row: Array<unknown>): void;

ericapisani avatar Nov 14 '23 21:11 ericapisani

Thanks for sharing these!

One method that I noticed is missing from the list is addRowMatrix:

addRowMatrix(row: Array<unknown>): void;

Thank you for your contribution. I hope one day we can see this issue inside the library

wraith4081 avatar Nov 15 '23 04:11 wraith4081