receiptio icon indicating copy to clipboard operation
receiptio copied to clipboard

Add TypeScript types

Open ryall opened this issue 4 years ago • 3 comments

Looks like a great library, but missing TypeScript typings.

ryall avatar Mar 21 '22 15:03 ryall

Thanks for using ReceiptIO! As with receiptline we would like to add TypeScript typings.

receiptline avatar Mar 24 '22 16:03 receiptline

Here's a rough template for the ReceiptIO types:

declare module 'receiptio' {
  import { Transform } from 'node:stream';

  export type Printer =
    | 'escpos'
    | 'sii'
    | 'citizen'
    | 'fit'
    | 'impact'
    | 'impactb'
    | 'star'
    | 'starline'
    | 'emustarline'
    | 'stargraphic'
    | 'svg'
    | 'png';

  export type Language =
    | 'en'
    | 'fr'
    | 'de'
    | 'es'
    | 'po'
    | 'it'
    | 'ru'
    | 'ja'
    | 'ko'
    | 'zh-hans'
    | 'zh-hant'
    | string; // Not all are listed, so allow arbitrary for now

  export type PrintStatus =
    | 'success'
    | 'online'
    | 'coveropen'
    | 'paperempty'
    | 'error'
    | 'offline'
    | 'disconnect'
    | 'timeout';

  export function print(receiptmd: string, options?: string): PrintStatus;
  export function print(receiptmd: string, options?: string): string;

  export function createPrint(options?: string): Transform;
}

Not much I can do with the specific types as the options are passed as a string.

Any chance options could also be passed as an object? I will update the types for that.

ryall avatar Mar 24 '22 16:03 ryall

It is a really great library. It was hard to find something in js that worked well for printing.

It would be really lovely if it had types.

Awesome job anyway!

onurbamaro avatar Oct 30 '23 11:10 onurbamaro