Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript types #1

Open
ryall opened this issue Mar 21, 2022 · 3 comments
Open

Add TypeScript types #1

ryall opened this issue Mar 21, 2022 · 3 comments

Comments

@ryall
Copy link

ryall commented Mar 21, 2022

Looks like a great library, but missing TypeScript typings.

@receiptline
Copy link
Owner

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

@ryall
Copy link
Author

ryall commented Mar 24, 2022

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.

@onurbamaro
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants