added types for img-diff-js (#46231)

* added types for img-diff-js

* Update types/img-diff-js/index.d.ts

Co-authored-by: Florian Keller <ffflorian@users.noreply.github.com>

* Update types/img-diff-js/index.d.ts

Co-authored-by: Florian Keller <ffflorian@users.noreply.github.com>

* updated JSDoc

* Update types/img-diff-js/index.d.ts

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>

Co-authored-by: Florian Keller <ffflorian@users.noreply.github.com>
Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
This commit is contained in:
Dan Chif 2020-07-21 22:03:48 +02:00 committed by GitHub
parent 39c383fd8a
commit 22aaff326a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,8 @@
import { imgDiff } from 'img-diff-js';
const options = {
actualFilename: 'a.jpg',
expectedFilename: 'b.jpg',
};
const result = imgDiff(options); // $ExpectType Promise<ImgDiffResult>

31
types/img-diff-js/index.d.ts vendored Normal file
View File

@ -0,0 +1,31 @@
// Type definitions for img-diff-js 0.4
// Project: https://github.com/reg-viz/img-diff-js#readme
// Definitions by: Daniel Chif <https://github.com/nadchif>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface ImgDiffOptions {
actualFilename: string;
expectedFilename: string;
diffFilename?: string;
/** {default:false} */
generateOnlyDiffFile?: boolean;
options?: {
/** {default: 0.1} */
threshold?: number;
/** {default:false} */
includeAA?: boolean;
};
}
export interface ImgDiffResult {
width: number;
height: number;
imagesAreSame: boolean;
diffCount: number;
}
/**
* Create image differential between two images.
*/
export function imgDiff(opt: ImgDiffOptions): Promise<ImgDiffResult>;
export function registerDecoder(extensions: string[], decoder: (filename: string) => any): void;

View 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",
"img-diff-js-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }