mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[printer] New typings for module "printer" (#47625)
* Add types for printer * Update types/printer/index.d.ts Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com> * Remove namespace declaration Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>
This commit is contained in:
parent
22da8b47ae
commit
a13d8cb4de
63
types/printer/index.d.ts
vendored
Normal file
63
types/printer/index.d.ts
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
// Type definitions for printer 0.4
|
||||
// Project: http://github.com/tojocky/node-printer
|
||||
// Definitions by: Christos Panagiotakopoulos <https://github.com/chrispanag>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export function getPrinters(): PrinterDetails[];
|
||||
export function getPrinter(printerName: string): PrinterDetails;
|
||||
export function getPrinterDriverOptions(printerName: string): PrinterDriverOptions;
|
||||
export function getSelectedPaperSize(printerName: string): string;
|
||||
export function getDefaultPrinterName(): string | undefined;
|
||||
export function printDirect(options: PrintDirectOptions): void;
|
||||
export function printFile(options: PrintFileOptions): void;
|
||||
export function getSupportedPrintFormats(): string[];
|
||||
export function getJob(printerName: string, jobId: number): JobDetails;
|
||||
export function setJob(printerName: string, jobId: number, command: 'CANCEL' | string): void;
|
||||
export function getSupportedJobCommands(): string[];
|
||||
|
||||
export interface PrintDirectOptions {
|
||||
data: string | Buffer;
|
||||
printer?: string;
|
||||
type?: 'RAW' | 'TEXT' | 'PDF' | 'JPEG' | 'POSTSCRIPT' | 'COMMAND' | 'AUTO';
|
||||
options?: { [key: string]: string };
|
||||
success?: PrintOnSuccessFunction;
|
||||
error?: PrintOnErrorFunction;
|
||||
}
|
||||
|
||||
export interface PrintFileOptions {
|
||||
filename: string;
|
||||
printer?: string;
|
||||
success?: PrintOnSuccessFunction;
|
||||
error?: PrintOnErrorFunction;
|
||||
}
|
||||
|
||||
export type PrintOnSuccessFunction = (jobId: string) => any;
|
||||
export type PrintOnErrorFunction = (err: Error) => any;
|
||||
|
||||
export interface PrinterDetails {
|
||||
name: string;
|
||||
isDefault: boolean;
|
||||
options: { [key: string]: string; };
|
||||
}
|
||||
|
||||
export interface PrinterDriverOptions {
|
||||
[key: string]: { [key: string]: boolean; };
|
||||
}
|
||||
|
||||
export interface JobDetails {
|
||||
id: number;
|
||||
name: string;
|
||||
printerName: string;
|
||||
user: string;
|
||||
format: string;
|
||||
priority: number;
|
||||
size: number;
|
||||
status: JobStatus[];
|
||||
completedTime: Date;
|
||||
creationTime: Date;
|
||||
processingTime: Date;
|
||||
}
|
||||
|
||||
export type JobStatus = 'PAUSED' | 'PRINTING' | 'PRINTED' | 'CANCELLED' | 'PENDING' | 'ABORTED';
|
||||
17
types/printer/printer-tests.ts
Normal file
17
types/printer/printer-tests.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import printer = require("printer");
|
||||
|
||||
printer.getDefaultPrinterName(); // $ExpectType string | undefined
|
||||
printer.getJob("test", 5); // $ExpectType JobDetails
|
||||
printer.getPrinter("printerName"); // $ExpectType PrinterDetails
|
||||
printer.getPrinterDriverOptions("printerName"); // $ExpectType PrinterDriverOptions
|
||||
printer.getPrinters(); // $ExpectType PrinterDetails[]
|
||||
printer.getSelectedPaperSize("printerName"); // $ExpectType string
|
||||
printer.getSupportedJobCommands(); // $ExpectType string[]
|
||||
printer.getSupportedPrintFormats(); // $ExpectType string[]
|
||||
printer.printDirect({
|
||||
data: 'test'
|
||||
});
|
||||
printer.printFile({
|
||||
filename: 'test'
|
||||
});
|
||||
printer.setJob("printerName", 5, "CANCEL"); // $ExpectType void
|
||||
23
types/printer/tsconfig.json
Normal file
23
types/printer/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"printer-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/printer/tslint.json
Normal file
1
types/printer/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user