Create types: @types/js-captcha (#35686)

This commit is contained in:
PikachuEXE 2019-05-29 04:00:45 +08:00 committed by Sheetal Nandi
parent 8821e40a2e
commit c3a16ffdf2
5 changed files with 99 additions and 0 deletions

32
types/js-captcha/dist/js/jCaptcha.d.ts vendored Normal file
View File

@ -0,0 +1,32 @@
declare namespace jCaptcha {
/**
* Options for the base jCaptcha class. Derived from https://github.com/robiveli/js-captcha#options
*/
interface Options {
el?: string;
requiredValue?: string;
resetOnError?: boolean;
focusOnError?: boolean;
clearOnSubmit?: boolean;
canvasWidth?: number;
canvasHeight?: number;
canvasFontSize?: string;
canvasFontFamily?: string;
canvasFillStyle?: string;
callback?: (response: "success" | "error", input: NodeListOf<Element>) => void;
}
}
declare class jCaptcha {
constructor(options?: jCaptcha.Options);
validate(): void;
reset(): void;
}
export = jCaptcha;
export as namespace jCaptcha;

7
types/js-captcha/index.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
// Type definitions for js-captcha 1.1
// Project: https://github.com/robiveli/js-captcha
// Definitions by: PikachuEXE <https://github.com/pikachuexe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as jCaptcha from "./dist/js/jCaptcha";

View File

@ -0,0 +1,31 @@
import jCaptcha from "js-captcha/dist/js/jCaptcha";
const myCaptcha1 = new jCaptcha({
el: "jCaptcha1",
requiredValue: "*",
resetOnError: true,
focusOnError: true,
clearOnSubmit: true,
canvasWidth: 50,
canvasHeight: 15,
canvasFontSize: "15px",
canvasFontFamily: "Arial",
canvasFillStyle: "#ddd",
callback: (response: "success" | "error", input: NodeListOf<Element>) => {
if (response === "success") {
// Do something
}
if (response === "error") {
// Do something
}
},
});
const myCaptcha2 = new jCaptcha({});
const myCaptcha3 = new jCaptcha();

View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"dist/js/jCaptcha.d.ts",
"js-captcha-tests.ts"
]
}

View File

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