mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Mailcheck: Add support for Synchronous mode (#43144)
* Add support for Synchronous mode * Update header * Remove patch from header
This commit is contained in:
parent
80fef04542
commit
2f2b97cd5d
19
types/mailcheck/index.d.ts
vendored
19
types/mailcheck/index.d.ts
vendored
@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/mailcheck/mailcheck
|
||||
// Definitions by: Paulo Cesar <https://github.com/pocesar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 3.8
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
@ -46,23 +46,31 @@ declare namespace MailcheckModule {
|
||||
full: string;
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
export interface IAsynchronousOptions {
|
||||
email: string;
|
||||
domains?: string[];
|
||||
secondLevelDomains?: string[];
|
||||
topLevelDomains?: string[];
|
||||
distanceFunction?: IDistanceFunction;
|
||||
suggested?: ISuggested | IJQuerySuggested;
|
||||
suggested: ISuggested | IJQuerySuggested;
|
||||
empty?: IEmpty | IJQueryEmpty;
|
||||
}
|
||||
export interface ISynchronousOptions {
|
||||
email: string;
|
||||
domains?: string[];
|
||||
secondLevelDomains?: string[];
|
||||
topLevelDomains?: string[];
|
||||
distanceFunction?: IDistanceFunction;
|
||||
|
||||
}
|
||||
export interface Static {
|
||||
defaultDomains: string[];
|
||||
defaultSecondLevelDomains: string[];
|
||||
defaultTopLevelDomains: string[];
|
||||
domainThreshold: number;
|
||||
topLevelThreshold: number;
|
||||
run(opts: IOptions):void;
|
||||
run(opts: IAsynchronousOptions):void;
|
||||
run(opts: ISynchronousOptions):ISuggestion | undefined;
|
||||
suggest: ISuggestFunction;
|
||||
encodeEmail(email: string): string;
|
||||
splitEmail(email: string): ISplitEmail;
|
||||
@ -73,7 +81,8 @@ declare namespace MailcheckModule {
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
mailcheck(opts: MailcheckModule.IOptions): void;
|
||||
mailcheck(opts: MailcheckModule.IAsynchronousOptions):void;
|
||||
mailcheck(opts: MailcheckModule.ISynchronousOptions):MailcheckModule.ISuggestion | void;
|
||||
}
|
||||
|
||||
declare module 'mailcheck' {
|
||||
|
||||
@ -18,6 +18,8 @@ $('#email').on('blur', function() {
|
||||
distanceFunction: superStringDistance, // optional
|
||||
suggested: function(element: JQuery, suggestion: MailcheckModule.ISuggestion) {
|
||||
// callback code
|
||||
element; // $ExpectType JQuery<HTMLElement>
|
||||
suggestion; // $ExpectType ISuggestion
|
||||
},
|
||||
empty: function(element: JQuery) {
|
||||
// callback code
|
||||
@ -33,6 +35,7 @@ Mailcheck.run({
|
||||
distanceFunction: superStringDistance, // optional
|
||||
suggested: function(suggestion: MailcheckModule.ISuggestion) {
|
||||
// callback code
|
||||
suggestion; // $ExpectType ISuggestion
|
||||
},
|
||||
empty: function() {
|
||||
// callback code
|
||||
@ -47,9 +50,18 @@ MC.run({
|
||||
distanceFunction: superStringDistance, // optional
|
||||
suggested: function(suggested: MailcheckModule.ISuggestion) {
|
||||
// callback code
|
||||
suggested.address === '' && suggested.full === '' && suggested.domain === '';
|
||||
suggested; // $ExpectType ISuggestion
|
||||
},
|
||||
empty: function() {
|
||||
// callback code
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const result3 = MC.run({
|
||||
email: 'nonoptional@example.com',
|
||||
domains: domains, // optional
|
||||
secondLevelDomains: secondLevelDomains, // optional
|
||||
topLevelDomains: topLevelDomains, // optional
|
||||
distanceFunction: superStringDistance, // optional
|
||||
});
|
||||
result3; // $ExpectType ISuggestion | undefined
|
||||
Loading…
Reference in New Issue
Block a user