mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge branch 'master' into fix-post-3.3-errors
This commit is contained in:
Vendored
+1
-3
@@ -246,9 +246,7 @@ declare namespace acorn {
|
||||
let LooseParser: ILooseParserClass | undefined;
|
||||
let pluginsLoose: PluginsObject | undefined;
|
||||
|
||||
interface ILooseParserClass {
|
||||
new (input: string, options?: Options): ILooseParser;
|
||||
}
|
||||
type ILooseParserClass = new (input: string, options?: Options) => ILooseParser;
|
||||
|
||||
interface ILooseParser {}
|
||||
|
||||
|
||||
@@ -9,5 +9,8 @@ ansiRegex().test('\u001B[4mcake\u001B[0m'); // $ExpectType boolean
|
||||
ansiRegex().test('cake'); // $ExpectType boolean
|
||||
// => false
|
||||
|
||||
ansiRegex({onlyFirst: true}).test('cake'); // $ExpectType boolean
|
||||
// => false
|
||||
|
||||
'\u001B[4mcake\u001B[0m'.match(ansiRegex()); // $ExpectType RegExpMatchArray | null
|
||||
// => ['\u001B[4m', '\u001B[0m']
|
||||
|
||||
Vendored
+12
-3
@@ -1,7 +1,16 @@
|
||||
// Type definitions for ansi-regex 3.0
|
||||
// Type definitions for ansi-regex 4.0
|
||||
// Project: https://github.com/chalk/ansi-regex#readme
|
||||
// Definitions by: Manish Vachharajani <https://github.com/mvachhar>
|
||||
// Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function r(): RegExp;
|
||||
export = r;
|
||||
declare namespace ansiRegex {
|
||||
interface Options {
|
||||
/** Match only the first ANSI escape. */
|
||||
onlyFirst?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare function ansiRegex(options?: ansiRegex.Options): RegExp;
|
||||
|
||||
export = ansiRegex;
|
||||
|
||||
@@ -136,6 +136,12 @@ webAuth.passwordlessStart({
|
||||
send: 'code'
|
||||
}, (err, data) => {});
|
||||
|
||||
webAuth.passwordlessLogin({
|
||||
connection: 'the_connection',
|
||||
phoneNumber: '123',
|
||||
verificationCode: '456'
|
||||
}, (err, data) => {});
|
||||
|
||||
webAuth.signupAndAuthorize({
|
||||
connection: 'the_connection',
|
||||
email: 'me@example.com',
|
||||
|
||||
Vendored
+14
@@ -270,6 +270,13 @@ export class WebAuth {
|
||||
*/
|
||||
passwordlessVerify(options: PasswordlessVerifyOptions, callback: Auth0Callback<any>): void;
|
||||
|
||||
/**
|
||||
* Logs in a user with the verification code sent to the user
|
||||
* @param options
|
||||
* @param callback
|
||||
*/
|
||||
passwordlessLogin(options: PasswordlessLoginOptions, callback: Auth0Callback<any>): void;
|
||||
|
||||
/**
|
||||
* Renews an existing session on Auth0's servers using `response_mode=web_message` (i.e. Auth0's hosted login page)
|
||||
*
|
||||
@@ -615,6 +622,13 @@ export interface PasswordlessVerifyOptions {
|
||||
send?: string;
|
||||
}
|
||||
|
||||
export interface PasswordlessLoginOptions {
|
||||
connection: string;
|
||||
verificationCode: string;
|
||||
phoneNumber?: string;
|
||||
email?: string;
|
||||
}
|
||||
|
||||
export interface Auth0UserProfile {
|
||||
name: string;
|
||||
nickname: string;
|
||||
|
||||
@@ -118,12 +118,18 @@ str = apiGwEvt.resource;
|
||||
str = customAuthorizerEvt.type;
|
||||
str = customAuthorizerEvt.methodArn;
|
||||
strOrUndefined = customAuthorizerEvt.authorizationToken;
|
||||
strOrUndefined = customAuthorizerEvt.resource;
|
||||
strOrUndefined = customAuthorizerEvt.path;
|
||||
strOrUndefined = customAuthorizerEvt.httpMethod;
|
||||
str = customAuthorizerEvt.headers!["example"];
|
||||
str = customAuthorizerEvt.multiValueHeaders!["example"][0];
|
||||
str = customAuthorizerEvt.pathParameters!["example"];
|
||||
str = customAuthorizerEvt.queryStringParameters!["example"];
|
||||
str = customAuthorizerEvt.multiValueQueryStringParameters!["example"][0];
|
||||
str = customAuthorizerEvt.stageVariables!["example"];
|
||||
apiGwEvtReqCtxOpt = customAuthorizerEvt.requestContext;
|
||||
strOrUndefined = customAuthorizerEvt.domainName;
|
||||
strOrUndefined = customAuthorizerEvt.apiId;
|
||||
|
||||
/* DynamoDB Stream Event */
|
||||
const dynamoDBStreamEvent: AWSLambda.DynamoDBStreamEvent = {
|
||||
|
||||
Vendored
+6
@@ -79,12 +79,18 @@ export interface CustomAuthorizerEvent {
|
||||
type: string;
|
||||
methodArn: string;
|
||||
authorizationToken?: string;
|
||||
resource?: string;
|
||||
path?: string;
|
||||
httpMethod?: string;
|
||||
headers?: { [name: string]: string };
|
||||
multiValueHeaders?: { [name: string]: string[] };
|
||||
pathParameters?: { [name: string]: string } | null;
|
||||
queryStringParameters?: { [name: string]: string } | null;
|
||||
multiValueQueryStringParameters?: { [name: string]: string[] } | null;
|
||||
stageVariables?: { [name: string]: string };
|
||||
requestContext?: APIGatewayEventRequestContext;
|
||||
domainName?: string;
|
||||
apiId?: string;
|
||||
}
|
||||
|
||||
// Context
|
||||
|
||||
Vendored
+10
@@ -119,6 +119,16 @@ declare namespace Bull {
|
||||
*/
|
||||
attemptsMade: number;
|
||||
|
||||
/**
|
||||
* When this job was started (unix milliseconds)
|
||||
*/
|
||||
processedOn?: number;
|
||||
|
||||
/**
|
||||
* When this job was completed (unix milliseconds)
|
||||
*/
|
||||
finishedOn?: number;
|
||||
|
||||
/**
|
||||
* Report progress on a job
|
||||
*/
|
||||
|
||||
@@ -438,10 +438,10 @@ test("simple tracer built on contexts", function (t) {
|
||||
this.harvester = harvester;
|
||||
}
|
||||
runHandler(callback: any) {
|
||||
const wrapped = tracer.bind(function () {
|
||||
const wrapped = tracer.bind(() => {
|
||||
callback();
|
||||
this.harvester.emit('finished', tracer.get('transaction'));
|
||||
}.bind(this));
|
||||
});
|
||||
wrapped();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ if (fns["Array.prototype.includes"]) {
|
||||
}
|
||||
const syntax = es.syntax();
|
||||
if (syntax["Arrow function"]) {
|
||||
new Function("() => {}");
|
||||
// new Function("() => {}");
|
||||
}
|
||||
|
||||
if (fns.es2017.__all && syntax.es2017.__all) {
|
||||
|
||||
Vendored
+18
@@ -1,19 +1,37 @@
|
||||
// Type definitions for ethereumjs-tx 1.0
|
||||
// Project: https://github.com/ethereumjs/ethereumjs-tx
|
||||
// Definitions by: Leonid Logvinov <https://github.com/LogvinovLeon>
|
||||
// David Mihal <https://github.com/dmihal>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node"/>
|
||||
|
||||
import BN = require("bn.js");
|
||||
|
||||
declare class EthereumTx {
|
||||
raw: Buffer[];
|
||||
r: Buffer;
|
||||
s: Buffer;
|
||||
v: Buffer;
|
||||
nonce: Buffer;
|
||||
gasPrice: Buffer;
|
||||
gasLimit: Buffer;
|
||||
to: Buffer;
|
||||
value: Buffer;
|
||||
data: Buffer;
|
||||
serialize(): Buffer;
|
||||
sign(buffer: Buffer): void;
|
||||
toJSON(): string | string[];
|
||||
toCreationAddress(): boolean;
|
||||
hash(includeSignature?: boolean): Buffer;
|
||||
getChainId(): Buffer;
|
||||
getSenderAddress(): Buffer;
|
||||
getSenderPublicKey(): Buffer;
|
||||
verifySignature(): boolean;
|
||||
getDataFee(): BN;
|
||||
getBaseFee(): BN;
|
||||
getUpfrontCost(): BN;
|
||||
validate(stringError?: boolean): string | boolean;
|
||||
constructor(txParams: any);
|
||||
}
|
||||
export = EthereumTx;
|
||||
|
||||
Vendored
+1
@@ -16,5 +16,6 @@ export interface GanacheOpts {
|
||||
mnemonic?: string;
|
||||
gasLimit?: number;
|
||||
vmErrorsOnRPCResponse?: boolean;
|
||||
db_path?: string;
|
||||
}
|
||||
export function provider(opts: GanacheOpts): Provider;
|
||||
|
||||
@@ -37,7 +37,7 @@ import * as prefs from "sdk/simple-prefs";
|
||||
type prefType = {pref1: string};
|
||||
(prefs.prefs as prefType)["pref1"] = "value";
|
||||
prefs.on("pref1", () => console.log("pref1 changed"));
|
||||
prefs.removeListener("pref1", new Function());
|
||||
prefs.removeListener("pref1", () => {});
|
||||
|
||||
import * as storage from "sdk/simple-storage";
|
||||
storage.storage.value = 10;
|
||||
|
||||
Vendored
+22
-20
@@ -39,37 +39,39 @@ export function safeDump(obj: any, opts?: DumpOptions): string;
|
||||
export function dump(obj: any, opts?: DumpOptions): string;
|
||||
|
||||
export interface LoadOptions {
|
||||
// string to be used as a file path in error/warning messages.
|
||||
/** string to be used as a file path in error/warning messages. */
|
||||
filename?: string;
|
||||
// function to call on warning messages.
|
||||
/** function to call on warning messages. */
|
||||
onWarning?(this: null, e: YAMLException): void;
|
||||
// specifies a schema to use.
|
||||
/** specifies a schema to use. */
|
||||
schema?: SchemaDefinition;
|
||||
// compatibility with JSON.parse behaviour.
|
||||
/** compatibility with JSON.parse behaviour. */
|
||||
json?: boolean;
|
||||
}
|
||||
|
||||
export interface DumpOptions {
|
||||
// indentation width to use (in spaces).
|
||||
/** indentation width to use (in spaces). */
|
||||
indent?: number;
|
||||
// do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types.
|
||||
/** do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types. */
|
||||
skipInvalid?: boolean;
|
||||
// specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere
|
||||
/** specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere */
|
||||
flowLevel?: number;
|
||||
// Each tag may have own set of styles. - "tag" => "style" map.
|
||||
/** Each tag may have own set of styles. - "tag" => "style" map. */
|
||||
styles?: { [x: string]: any; };
|
||||
// specifies a schema to use.
|
||||
/** specifies a schema to use. */
|
||||
schema?: SchemaDefinition;
|
||||
// if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false)
|
||||
/** if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false) */
|
||||
sortKeys?: boolean | ((a: any, b: any) => number);
|
||||
// set max line width. (default: 80)
|
||||
/** set max line width. (default: 80) */
|
||||
lineWidth?: number;
|
||||
// if true, don't convert duplicate objects into references (default: false)
|
||||
/** if true, don't convert duplicate objects into references (default: false) */
|
||||
noRefs?: boolean;
|
||||
// if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false)
|
||||
/** if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) */
|
||||
noCompatMode?: boolean;
|
||||
// if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`.
|
||||
// Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false).
|
||||
/**
|
||||
* if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`.
|
||||
* Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false).
|
||||
*/
|
||||
condenseFlow?: boolean;
|
||||
}
|
||||
|
||||
@@ -90,15 +92,15 @@ export interface SchemaDefinition {
|
||||
include?: Schema[];
|
||||
}
|
||||
|
||||
// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||
/** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */
|
||||
export let FAILSAFE_SCHEMA: Schema;
|
||||
// only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||
/** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */
|
||||
export let JSON_SCHEMA: Schema;
|
||||
// same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923
|
||||
/** same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 */
|
||||
export let CORE_SCHEMA: Schema;
|
||||
// all supported YAML types, without unsafe ones (!!js/undefined, !!js/regexp and !!js/function): http://yaml.org/type/
|
||||
/** all supported YAML types, without unsafe ones (!!js/undefined, !!js/regexp and !!js/function): http://yaml.org/type/ */
|
||||
export let DEFAULT_SAFE_SCHEMA: Schema;
|
||||
// all supported YAML types.
|
||||
/** all supported YAML types. */
|
||||
export let DEFAULT_FULL_SCHEMA: Schema;
|
||||
export let MINIMAL_SCHEMA: Schema;
|
||||
export let SAFE_SCHEMA: Schema;
|
||||
|
||||
Vendored
+176
-16
@@ -48,7 +48,7 @@ interface KnockoutObservableArrayFunctions<T> extends KnockoutReadonlyObservable
|
||||
* Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
|
||||
* @param start The zero-based location in the array from which to start removing elements.
|
||||
* @param deleteCount The number of elements to remove.
|
||||
* @param ...items Elements to insert into the array in place of the deleted elements.
|
||||
* @param items Elements to insert into the array in place of the deleted elements.
|
||||
*/
|
||||
splice(start: number, deleteCount: number, ...items: T[]): T[];
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ interface KnockoutObservableArrayFunctions<T> extends KnockoutReadonlyObservable
|
||||
pop(): T;
|
||||
/**
|
||||
* Adds a new item to the end of array.
|
||||
* @param ...items Items to be added
|
||||
* @param items Items to be added
|
||||
*/
|
||||
push(...items: T[]): void;
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ interface KnockoutObservableArrayFunctions<T> extends KnockoutReadonlyObservable
|
||||
shift(): T;
|
||||
/**
|
||||
* Inserts a new item at the beginning of the array.
|
||||
* @param ...items Items to be added
|
||||
* @param items Items to be added
|
||||
*/
|
||||
unshift(...items: T[]): number;
|
||||
/**
|
||||
@@ -96,7 +96,7 @@ interface KnockoutObservableArrayFunctions<T> extends KnockoutReadonlyObservable
|
||||
*/
|
||||
remove(item: T): T[];
|
||||
/**
|
||||
* Removes all values and returns them as an array.
|
||||
* Removes all values and returns them as an array.
|
||||
* @param removeFunction A function used to determine true if item should be removed and fasle otherwise
|
||||
*/
|
||||
remove(removeFunction: (item: T) => boolean): T[];
|
||||
@@ -139,24 +139,70 @@ interface KnockoutSubscribableStatic {
|
||||
}
|
||||
|
||||
interface KnockoutSubscription {
|
||||
/**
|
||||
* Terminates a subscription
|
||||
*/
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
interface KnockoutSubscribable<T> extends KnockoutSubscribableFunctions<T> {
|
||||
subscribe(callback: (newValue: T) => void, target: any, event: "beforeChange"): KnockoutSubscription;
|
||||
/**
|
||||
* Registers to be notified after the observable's value changes
|
||||
* @param callback Function that is called whenever the notification happens
|
||||
* @param target Defines the value of 'this' in the callback function
|
||||
* @param event The name of the event to receive notification for
|
||||
*/
|
||||
subscribe(callback: (newValue: T) => void, target?: any, event?: "change"): KnockoutSubscription;
|
||||
/**
|
||||
* Registers to be notified before the observable's value changes
|
||||
* @param callback Function that is called whenever the notification happens
|
||||
* @param target Defines the value of 'this' in the callback function
|
||||
* @param event The name of the event to receive notification for
|
||||
*/
|
||||
subscribe(callback: (newValue: T) => void, target: any, event: "beforeChange"): KnockoutSubscription;
|
||||
/**
|
||||
* Registers to be notified when the observable's value changes
|
||||
* @param callback Function that is called whenever the notification happens
|
||||
* @param target Defines the value of 'this' in the callback function
|
||||
* @param event The name of the event to receive notification for
|
||||
*/
|
||||
subscribe<TEvent>(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription;
|
||||
|
||||
/**
|
||||
* Customizes observables basic functionality
|
||||
* @param requestedExtenders Name of the extender feature and its value, e.g. { notify: 'always' }, { rateLimit: 50 }
|
||||
*/
|
||||
extend(requestedExtenders: { [key: string]: any; }): KnockoutSubscribable<T>;
|
||||
/**
|
||||
* Gets total number of subscribers
|
||||
*/
|
||||
getSubscriptionsCount(): number;
|
||||
/**
|
||||
* Gets number of subscribers of a particular event
|
||||
* @param event Event name
|
||||
*/
|
||||
getSubscriptionsCount(event: string): number;
|
||||
}
|
||||
|
||||
interface KnockoutComputedStatic {
|
||||
fn: KnockoutComputedFunctions<any>;
|
||||
|
||||
/**
|
||||
* Creates computed observable
|
||||
*/
|
||||
<T>(): KnockoutComputed<T>;
|
||||
<T>(func: () => T, context?: any, options?: any): KnockoutComputed<T>;
|
||||
<T>(def: KnockoutComputedDefine<T>, context?: any): KnockoutComputed<T>;
|
||||
/**
|
||||
* Creates computed observable
|
||||
* @param evaluatorFunction Function that computes the observable value
|
||||
* @param context Defines the value of 'this' when evaluating the computed observable
|
||||
* @param options An object with further properties for the computed observable
|
||||
*/
|
||||
<T>(evaluatorFunction: () => T, context?: any, options?: any): KnockoutComputed<T>;
|
||||
/**
|
||||
* Creates computed observable
|
||||
* @param options An object that defines the computed observable options and behavior
|
||||
* @param context Defines the value of 'this' when evaluating the computed observable
|
||||
*/
|
||||
<T>(options: KnockoutComputedDefine<T>, context?: any): KnockoutComputed<T>;
|
||||
}
|
||||
|
||||
interface KnockoutReadonlyComputed<T> extends KnockoutReadonlyObservable<T> {
|
||||
@@ -167,11 +213,27 @@ interface KnockoutReadonlyComputed<T> extends KnockoutReadonlyObservable<T> {
|
||||
interface KnockoutComputed<T> extends KnockoutReadonlyComputed<T>, KnockoutObservable<T>, KnockoutComputedFunctions<T> {
|
||||
fn: KnockoutComputedFunctions<any>;
|
||||
|
||||
// It's possible for a to be undefined, since the equalityComparer is run on the initial
|
||||
// It's possible for 'a' to be undefined, since the equalityComparer is run on the initial
|
||||
// computation with undefined as the first argument. This is user-relevant for deferred computeds.
|
||||
equalityComparer(a: T | undefined, b: T): boolean;
|
||||
|
||||
/**
|
||||
* Manually disposes the computed observable, clearing all subscriptions to dependencies.
|
||||
* This function is useful if you want to stop a computed observable from being updated or want to clean up memory for a
|
||||
* computed observable that has dependencies on observables that won’t be cleaned.
|
||||
*/
|
||||
dispose(): void;
|
||||
/**
|
||||
* Returns whether the computed observable may be updated in the future. A computed observable is inactive if it has no dependencies.
|
||||
*/
|
||||
isActive(): boolean;
|
||||
/**
|
||||
* Returns the current number of dependencies of the computed observable.
|
||||
*/
|
||||
getDependenciesCount(): number;
|
||||
/**
|
||||
* Customizes observables basic functionality
|
||||
* @param requestedExtenders Name of the extender feature and it's value, e.g. { notify: 'always' }, { rateLimit: 50 }
|
||||
*/
|
||||
extend(requestedExtenders: { [key: string]: any; }): KnockoutComputed<T>;
|
||||
}
|
||||
|
||||
@@ -222,6 +284,10 @@ interface KnockoutObservableStatic {
|
||||
interface KnockoutReadonlyObservable<T> extends KnockoutSubscribable<T>, KnockoutObservableFunctions<T> {
|
||||
(): T;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current value of the computed observable without creating a dependency
|
||||
*/
|
||||
peek(): T;
|
||||
valueHasMutated?: { (): void; };
|
||||
valueWillMutate?: { (): void; };
|
||||
@@ -235,12 +301,38 @@ interface KnockoutObservable<T> extends KnockoutReadonlyObservable<T> {
|
||||
}
|
||||
|
||||
interface KnockoutComputedDefine<T> {
|
||||
/**
|
||||
* A function that is used to evaluate the computed observable’s current value.
|
||||
*/
|
||||
read(): T;
|
||||
/**
|
||||
* Makes the computed observable writable. This is a function that receives values that other code is trying to write to your computed observable.
|
||||
* It’s up to you to supply custom logic to handle the incoming values, typically by writing the values to some underlying observable(s).
|
||||
* @param value
|
||||
*/
|
||||
write?(value: T): void;
|
||||
/**
|
||||
* Disposal of the computed observable will be triggered when the specified DOM node is removed by KO.
|
||||
* This feature is used to dispose computed observables used in bindings when nodes are removed by the template and control-flow bindings.
|
||||
*/
|
||||
disposeWhenNodeIsRemoved?: Node;
|
||||
/**
|
||||
* This function is executed before each re-evaluation to determine if the computed observable should be disposed.
|
||||
* A true-ish result will trigger disposal of the computed observable.
|
||||
*/
|
||||
disposeWhen?(): boolean;
|
||||
/**
|
||||
* Defines the value of 'this' whenever KO invokes your 'read' or 'write' callbacks.
|
||||
*/
|
||||
owner?: any;
|
||||
/**
|
||||
* If true, then the value of the computed observable will not be evaluated until something actually attempts to access its value or manually subscribes to it.
|
||||
* By default, a computed observable has its value determined immediately during creation.
|
||||
*/
|
||||
deferEvaluation?: boolean;
|
||||
/**
|
||||
* If true, the computed observable will be set up as a purecomputed observable. This option is an alternative to the ko.pureComputed constructor.
|
||||
*/
|
||||
pure?: boolean;
|
||||
}
|
||||
|
||||
@@ -547,7 +639,17 @@ interface KnockoutStatic {
|
||||
observable: KnockoutObservableStatic;
|
||||
|
||||
computed: KnockoutComputedStatic;
|
||||
/**
|
||||
* Creates a pure computed observable
|
||||
* @param evaluatorFunction Function that computes the observable value
|
||||
* @param context Defines the value of 'this' when evaluating the computed observable
|
||||
*/
|
||||
pureComputed<T>(evaluatorFunction: () => T, context?: any): KnockoutComputed<T>;
|
||||
/**
|
||||
* Creates a pure computed observable
|
||||
* @param options An object that defines the computed observable options and behavior
|
||||
* @param context Defines the value of 'this' when evaluating the computed observable
|
||||
*/
|
||||
pureComputed<T>(options: KnockoutComputedDefine<T>, context?: any): KnockoutComputed<T>;
|
||||
|
||||
observableArray: KnockoutObservableArrayStatic;
|
||||
@@ -557,14 +659,35 @@ interface KnockoutStatic {
|
||||
toJSON(viewModel: any, replacer?: Function, space?: any): string;
|
||||
|
||||
toJS(viewModel: any): any;
|
||||
|
||||
/**
|
||||
* Determine if argument is an observable. Returns true for observables, observable arrays, and all computed observables.
|
||||
* @param instance Object to be checked
|
||||
*/
|
||||
isObservable(instance: any): instance is KnockoutObservable<any>;
|
||||
/**
|
||||
* Determine if argument is an observable. Returns true for observables, observable arrays, and all computed observables.
|
||||
* @param instance Object to be checked
|
||||
*/
|
||||
isObservable<T>(instance: KnockoutObservable<T> | T): instance is KnockoutObservable<T>;
|
||||
|
||||
/**
|
||||
* Determine if argument is a writable observable. Returns true for observables, observable arrays, and writable computed observables.
|
||||
* @param instance Object to be checked
|
||||
*/
|
||||
isWriteableObservable(instance: any): instance is KnockoutObservable<any>;
|
||||
/**
|
||||
* Determine if argument is a writable observable. Returns true for observables, observable arrays, and writable computed observables.
|
||||
* @param instance Object to be checked
|
||||
*/
|
||||
isWriteableObservable<T>(instance: KnockoutObservable<T> | T): instance is KnockoutObservable<T>;
|
||||
|
||||
/**
|
||||
* Determine if argument is a computed observable
|
||||
* @param instance Object to be checked
|
||||
*/
|
||||
isComputed(instance: any): instance is KnockoutComputed<any>;
|
||||
/**
|
||||
* Determine if argument is a computed observable
|
||||
* @param instance Object to be checked
|
||||
*/
|
||||
isComputed<T>(instance: KnockoutObservable<T> | T): instance is KnockoutComputed<T>;
|
||||
|
||||
dataFor(node: any): any;
|
||||
@@ -575,6 +698,9 @@ interface KnockoutStatic {
|
||||
unwrap<T>(value: KnockoutObservable<T> | T): T;
|
||||
unwrap<T>(value: KnockoutObservableArray<T> | T[]): T[];
|
||||
|
||||
/**
|
||||
* Get information about the current computed property during the execution of a computed observable’s evaluator function.
|
||||
*/
|
||||
computedContext: KnockoutComputedContext;
|
||||
|
||||
//////////////////////////////////
|
||||
@@ -656,7 +782,13 @@ interface KnockoutStatic {
|
||||
renderTemplateForEach(template: Function, arrayOrObservableArray: KnockoutObservable<any>, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
|
||||
renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable<any>, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
|
||||
|
||||
ignoreDependencies<T>(callback: () => T): T;
|
||||
/**
|
||||
* Executes a callback function inside a computed observable, without creating a dependecy between it and the observables inside the function
|
||||
* @param callback Function to be called.
|
||||
* @param callbackTarget Defines the value of 'this' in the callback function
|
||||
* @param callbackArgs Arguments for the callback Function
|
||||
*/
|
||||
ignoreDependencies<T>(callback: () => T, callbackTarget?: any, callbackArgs?: any): T;
|
||||
|
||||
expressionRewriting: {
|
||||
bindingRewriteValidators: any[];
|
||||
@@ -731,7 +863,14 @@ interface KnockoutBindingProvider {
|
||||
}
|
||||
|
||||
interface KnockoutComputedContext {
|
||||
/**
|
||||
* Returns the number of dependencies of the computed observable detected so far during the current evaluation.
|
||||
*/
|
||||
getDependenciesCount(): number;
|
||||
/**
|
||||
* A function that returns true if called during the first ever evaluation of the current computed observable, or false otherwise.
|
||||
* For pure computed observables, isInitial() is always undefined.
|
||||
*/
|
||||
isInitial: () => boolean;
|
||||
isSleeping: boolean;
|
||||
}
|
||||
@@ -799,12 +938,33 @@ declare namespace KnockoutComponentTypes {
|
||||
}
|
||||
|
||||
interface KnockoutComponents {
|
||||
// overloads for register method:
|
||||
register(componentName: string, config: KnockoutComponentTypes.Config | KnockoutComponentTypes.EmptyConfig): void;
|
||||
|
||||
/**
|
||||
* Registers a component, in the default component loader, to be used by name in the component binding.
|
||||
* @param componentName Component name.
|
||||
* @param config Component configuration.
|
||||
*/
|
||||
register(componentName: string, config: KnockoutComponentTypes.Config | KnockoutComponentTypes.EmptyConfig): void;
|
||||
/**
|
||||
* Determine if a component with the specified name is already registered in the default component loader.
|
||||
* @param componentName Component name.
|
||||
*/
|
||||
isRegistered(componentName: string): boolean;
|
||||
/**
|
||||
* Removes the named component from the default component loader registry. Or if no such component was registered, does nothing.
|
||||
* @param componentName Component name.
|
||||
*/
|
||||
unregister(componentName: string): void;
|
||||
/**
|
||||
* Searchs each registered component loader by component name, and returns the viewmodel/template declaration via callback parameter
|
||||
* @param componentName Component name.
|
||||
* @param callback Function to be called with the viewmodel/template declaration parameter.
|
||||
*/
|
||||
get(componentName: string, callback: (definition: KnockoutComponentTypes.Definition) => void): void;
|
||||
/**
|
||||
* Clears the cache knockout creates to speed up component loading, for a given component.
|
||||
* @param componentName Component name.
|
||||
*/
|
||||
clearCachedDefinition(componentName: string): void
|
||||
defaultLoader: KnockoutComponentTypes.Loader;
|
||||
loaders: KnockoutComponentTypes.Loader[];
|
||||
|
||||
Vendored
+6
-6
@@ -126,7 +126,7 @@ declare module Mongo {
|
||||
new <T>(name: string, options?: {
|
||||
connection?: Object | null;
|
||||
idGeneration?: string;
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}): Collection<T>;
|
||||
}
|
||||
interface Collection<T> {
|
||||
@@ -135,14 +135,14 @@ declare module Mongo {
|
||||
update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean;
|
||||
remove?: (userId: string, doc: T) => boolean;
|
||||
fetch?: string[];
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}): boolean;
|
||||
deny(options: {
|
||||
insert?: (userId: string, doc: T) => boolean;
|
||||
update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean;
|
||||
remove?: (userId: string, doc: T) => boolean;
|
||||
fetch?: string[];
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}): boolean;
|
||||
find(selector?: Selector<T> | ObjectID | string, options?: {
|
||||
sort?: SortSpecifier;
|
||||
@@ -150,14 +150,14 @@ declare module Mongo {
|
||||
limit?: number;
|
||||
fields?: FieldSpecifier;
|
||||
reactive?: boolean;
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}): Cursor<T>;
|
||||
findOne(selector?: Selector<T> | ObjectID | string, options?: {
|
||||
sort?: SortSpecifier;
|
||||
skip?: number;
|
||||
fields?: FieldSpecifier;
|
||||
reactive?: boolean;
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}): T;
|
||||
insert(doc: T, callback?: Function): string;
|
||||
rawCollection(): any;
|
||||
@@ -229,6 +229,6 @@ declare module Mongo {
|
||||
update?: (userId: string, doc: any, fieldNames: string[], modifier: any) => boolean;
|
||||
remove?: (userId: string, doc: any) => boolean;
|
||||
fetch?: string[];
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -9,6 +9,7 @@
|
||||
// Stefan Holzapfel <https://github.com/stefanholzapfel>
|
||||
// Andrey Markeev <https://github.com/andrei-markeev>
|
||||
// Leon Machens <https://github.com/lmachens>
|
||||
// Arthur Gunn <https://github.com/gunn>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
|
||||
Vendored
+6
-6
@@ -127,7 +127,7 @@ declare module "meteor/mongo" {
|
||||
new <T>(name: string, options?: {
|
||||
connection?: Object | null;
|
||||
idGeneration?: string;
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}): Collection<T>;
|
||||
}
|
||||
interface Collection<T> {
|
||||
@@ -136,14 +136,14 @@ declare module "meteor/mongo" {
|
||||
update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean;
|
||||
remove?: (userId: string, doc: T) => boolean;
|
||||
fetch?: string[];
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}): boolean;
|
||||
deny(options: {
|
||||
insert?: (userId: string, doc: T) => boolean;
|
||||
update?: (userId: string, doc: T, fieldNames: string[], modifier: any) => boolean;
|
||||
remove?: (userId: string, doc: T) => boolean;
|
||||
fetch?: string[];
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}): boolean;
|
||||
find(selector?: Selector<T> | ObjectID | string, options?: {
|
||||
sort?: SortSpecifier;
|
||||
@@ -151,14 +151,14 @@ declare module "meteor/mongo" {
|
||||
limit?: number;
|
||||
fields?: FieldSpecifier;
|
||||
reactive?: boolean;
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}): Cursor<T>;
|
||||
findOne(selector?: Selector<T> | ObjectID | string, options?: {
|
||||
sort?: SortSpecifier;
|
||||
skip?: number;
|
||||
fields?: FieldSpecifier;
|
||||
reactive?: boolean;
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}): T;
|
||||
insert(doc: T, callback?: Function): string;
|
||||
rawCollection(): any;
|
||||
@@ -230,7 +230,7 @@ declare module "meteor/mongo" {
|
||||
update?: (userId: string, doc: any, fieldNames: string[], modifier: any) => boolean;
|
||||
remove?: (userId: string, doc: any) => boolean;
|
||||
fetch?: string[];
|
||||
transform?: Function;
|
||||
transform?: Function | null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ Posts.insert({ title: "Hello world", body: "First post" });
|
||||
**/
|
||||
|
||||
class Animal {
|
||||
constructor(doc: any) {}
|
||||
constructor(public doc: any) {}
|
||||
}
|
||||
|
||||
interface AnimalDAO {
|
||||
|
||||
@@ -213,7 +213,7 @@ Posts.insert({ title: "Hello world", body: "First post" });
|
||||
**/
|
||||
|
||||
class Animal {
|
||||
constructor(doc: any) {}
|
||||
constructor(public doc: any) {}
|
||||
}
|
||||
|
||||
interface AnimalDAO {
|
||||
|
||||
@@ -121,12 +121,12 @@ sql = mysql.format(sql, inserts);
|
||||
|
||||
connection.config.queryFormat = function(query, values) {
|
||||
if (!values) return query;
|
||||
return query.replace(/\:(\w+)/g, function(txt: string, key: string) {
|
||||
return query.replace(/\:(\w+)/g, (txt: string, key: string) => {
|
||||
if (values.hasOwnProperty(key)) {
|
||||
return this.escape(values[key]);
|
||||
}
|
||||
return txt;
|
||||
}.bind(this));
|
||||
});
|
||||
};
|
||||
|
||||
connection.query("UPDATE posts SET title = :title", {title: "Hello MySQL"});
|
||||
|
||||
Vendored
+7
-3
@@ -37,8 +37,8 @@ export interface EncryptOptions {
|
||||
}
|
||||
|
||||
export interface EncryptedMessage {
|
||||
data: string,
|
||||
message: string,
|
||||
data?: string,
|
||||
message?: message.Message,
|
||||
}
|
||||
|
||||
export interface DecryptOptions {
|
||||
@@ -571,6 +571,10 @@ export namespace message {
|
||||
@param keys array of keys to verify signatures
|
||||
*/
|
||||
verify(keys: Array<key.Key>): Array<Object>,
|
||||
|
||||
packets: {
|
||||
write(): Uint8Array,
|
||||
},
|
||||
}
|
||||
|
||||
/** creates new message object from binary data
|
||||
@@ -595,7 +599,7 @@ export namespace message {
|
||||
* @returns {Message} new message object
|
||||
* @static
|
||||
*/
|
||||
function read(data: Uint8Array): Message;
|
||||
function read(data: Uint8Array): Promise<Message>;
|
||||
}
|
||||
|
||||
export namespace packet {
|
||||
|
||||
@@ -70,6 +70,45 @@ Promise.all(promises).then(function (values) {
|
||||
// failure
|
||||
});
|
||||
|
||||
openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
|
||||
(async () => {
|
||||
let msgOptions: openpgp.EncryptOptions;
|
||||
|
||||
msgOptions = {
|
||||
message: openpgp.message.fromBinary(new Uint8Array([0x01, 0x01, 0x01])),
|
||||
passwords: ['secret stuff'],
|
||||
armor: false,
|
||||
};
|
||||
|
||||
let cipher = await openpgp.encrypt(msgOptions);
|
||||
let encrypted = cipher.message.packets.write(); // get raw encrypted packets as Uint8Array
|
||||
|
||||
let plain = await openpgp.decrypt({
|
||||
message: await openpgp.message.read(encrypted),
|
||||
passwords: ['secret stuff'],
|
||||
format: 'binary'
|
||||
});
|
||||
|
||||
return plain.data;
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
let cipher = await openpgp.encrypt({
|
||||
message: openpgp.message.fromText('hello world'),
|
||||
passwords: 'super secure',
|
||||
armor: true,
|
||||
});
|
||||
let encrypted = cipher.data;
|
||||
|
||||
let plain = await openpgp.decrypt({
|
||||
message: await openpgp.message.readArmored(encrypted),
|
||||
passwords: 'super secure',
|
||||
});
|
||||
|
||||
return plain.data;
|
||||
})();
|
||||
|
||||
|
||||
// Open PGP Tests
|
||||
|
||||
|
||||
Vendored
+7
-3
@@ -36,8 +36,8 @@ export interface EncryptOptions {
|
||||
}
|
||||
|
||||
export interface EncryptedMessage {
|
||||
data: string,
|
||||
message: string,
|
||||
data?: string,
|
||||
message?: message.Message,
|
||||
}
|
||||
|
||||
export interface DecryptOptions {
|
||||
@@ -570,6 +570,10 @@ export namespace message {
|
||||
@param keys array of keys to verify signatures
|
||||
*/
|
||||
verify(keys: Array<key.Key>): Array<Object>,
|
||||
|
||||
packets: {
|
||||
write(): Uint8Array,
|
||||
},
|
||||
}
|
||||
|
||||
/** creates new message object from binary data
|
||||
@@ -594,7 +598,7 @@ export namespace message {
|
||||
* @returns {Message} new message object
|
||||
* @static
|
||||
*/
|
||||
function read(data: Uint8Array): Message;
|
||||
function read(data: Uint8Array): Promise<Message>;
|
||||
}
|
||||
|
||||
export namespace packet {
|
||||
|
||||
@@ -70,6 +70,45 @@ Promise.all(promises).then(function (values) {
|
||||
// failure
|
||||
});
|
||||
|
||||
openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
|
||||
(async () => {
|
||||
let msgOptions: openpgp.EncryptOptions;
|
||||
|
||||
msgOptions = {
|
||||
message: openpgp.message.fromBinary(new Uint8Array([0x01, 0x01, 0x01])),
|
||||
passwords: ['secret stuff'],
|
||||
armor: false,
|
||||
};
|
||||
|
||||
let cipher = await openpgp.encrypt(msgOptions);
|
||||
let encrypted = cipher.message.packets.write(); // get raw encrypted packets as Uint8Array
|
||||
|
||||
let plain = await openpgp.decrypt({
|
||||
message: await openpgp.message.read(encrypted),
|
||||
passwords: ['secret stuff'],
|
||||
format: 'binary'
|
||||
});
|
||||
|
||||
return plain.data;
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
let cipher = await openpgp.encrypt({
|
||||
message: openpgp.message.fromText('hello world'),
|
||||
passwords: 'super secure',
|
||||
armor: true,
|
||||
});
|
||||
let encrypted = cipher.data;
|
||||
|
||||
let plain = await openpgp.decrypt({
|
||||
message: await openpgp.message.readArmored(encrypted),
|
||||
passwords: 'super secure',
|
||||
});
|
||||
|
||||
return plain.data;
|
||||
})();
|
||||
|
||||
|
||||
// Open PGP Tests
|
||||
|
||||
|
||||
Vendored
+66
-8
@@ -1,9 +1,10 @@
|
||||
// Type definitions for react-beautiful-dnd 7.1
|
||||
// Type definitions for react-beautiful-dnd 10.0
|
||||
// Project: https://github.com/atlassian/react-beautiful-dnd
|
||||
// Definitions by: varHarrie <https://github.com/varHarrie>
|
||||
// Bradley Ayers <https://github.com/bradleyayers>
|
||||
// Austin Turner <https://github.com/paustint>
|
||||
// Mark Nelissen <https://github.com/marknelissen>
|
||||
// Enrico Boccadifuoco <https://github.com/enricoboccadifuoco>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -22,10 +23,40 @@ export interface DraggableLocation {
|
||||
index: number;
|
||||
}
|
||||
|
||||
export interface HookProvided {
|
||||
export type MovementMode = 'FLUID' | 'SNAP';
|
||||
|
||||
/**
|
||||
* Responders
|
||||
*/
|
||||
|
||||
export interface ResponderProvided {
|
||||
announce: Announce;
|
||||
}
|
||||
|
||||
export type OnBeforeDragStartResponder = (start: DragStart) => void;
|
||||
|
||||
export type OnDragStartResponder = (
|
||||
start: DragStart,
|
||||
provided: ResponderProvided,
|
||||
) => void;
|
||||
|
||||
export type OnDragUpdateResponder = (
|
||||
update: DragUpdate,
|
||||
provided: ResponderProvided,
|
||||
) => void;
|
||||
|
||||
export type OnDragEndResponder = (
|
||||
result: DropResult,
|
||||
provided: ResponderProvided,
|
||||
) => void;
|
||||
|
||||
export interface Responders {
|
||||
onBeforeDragStart?: OnBeforeDragStartResponder;
|
||||
onDragStart?: OnDragStartResponder;
|
||||
onDragUpdate?: OnDragUpdateResponder;
|
||||
onDragEnd: OnDragEndResponder;
|
||||
}
|
||||
|
||||
/**
|
||||
* DragDropContext
|
||||
*/
|
||||
@@ -34,10 +65,19 @@ export interface DragStart {
|
||||
draggableId: DraggableId;
|
||||
type: TypeId;
|
||||
source: DraggableLocation;
|
||||
mode: MovementMode;
|
||||
}
|
||||
|
||||
export interface DragUpdate extends DragStart {
|
||||
destination?: DraggableLocation | null;
|
||||
// populated when a draggable is dragging over another in combine mode
|
||||
combine?: Combine | null;
|
||||
}
|
||||
|
||||
// details of the item that is being combined with
|
||||
export interface Combine {
|
||||
draggableId: DraggableId;
|
||||
droppableId: DroppableId;
|
||||
}
|
||||
|
||||
export interface DropResult extends DragUpdate {
|
||||
@@ -45,12 +85,12 @@ export interface DropResult extends DragUpdate {
|
||||
}
|
||||
|
||||
export interface DragDropContextProps {
|
||||
onDragStart?(initial: DragStart, provided: HookProvided): void;
|
||||
onDragUpdate?(initial: DragUpdate, provided: HookProvided): void;
|
||||
onDragEnd(result: DropResult, provided: HookProvided): void;
|
||||
onDragStart?(initial: DragStart, provided: ResponderProvided): void;
|
||||
onDragUpdate?(initial: DragUpdate, provided: ResponderProvided): void;
|
||||
onDragEnd(result: DropResult, provided: ResponderProvided): void;
|
||||
}
|
||||
|
||||
export class DragDropContext extends React.Component<DragDropContextProps> {}
|
||||
export class DragDropContext extends React.Component<DragDropContextProps> { }
|
||||
|
||||
/**
|
||||
* Droppable
|
||||
@@ -75,11 +115,12 @@ export interface DroppableProps {
|
||||
type?: TypeId;
|
||||
ignoreContainerClipping?: boolean;
|
||||
isDropDisabled?: boolean;
|
||||
isCombineEnabled?: boolean;
|
||||
direction?: 'vertical' | 'horizontal';
|
||||
children(provided: DroppableProvided, snapshot: DroppableStateSnapshot): React.ReactElement<any>;
|
||||
}
|
||||
|
||||
export class Droppable extends React.Component<DroppableProps> {}
|
||||
export class Droppable extends React.Component<DroppableProps> { }
|
||||
|
||||
/**
|
||||
* Draggable
|
||||
@@ -135,6 +176,23 @@ export interface DraggableProvided {
|
||||
|
||||
export interface DraggableStateSnapshot {
|
||||
isDragging: boolean;
|
||||
isDropAnimating: boolean;
|
||||
draggingOver?: DroppableId;
|
||||
dropAnimation?: DropAnimation;
|
||||
// the id of a draggable that you are combining with
|
||||
combineWith?: DraggableId;
|
||||
// a combine target is being dragged over by
|
||||
combineTargetFor?: DraggableId;
|
||||
// What type of movement is being done: 'FLUID' or 'SNAP'
|
||||
mode?: MovementMode;
|
||||
}
|
||||
|
||||
export interface DropAnimation {
|
||||
duration: number;
|
||||
curve: string;
|
||||
moveTo: Position;
|
||||
opacity?: number;
|
||||
scale?: number;
|
||||
}
|
||||
|
||||
export interface DraggableProps {
|
||||
@@ -146,4 +204,4 @@ export interface DraggableProps {
|
||||
type?: TypeId;
|
||||
}
|
||||
|
||||
export class Draggable extends React.Component<DraggableProps> {}
|
||||
export class Draggable extends React.Component<DraggableProps> { }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import { DragDropContext, Draggable, Droppable, DropResult, DragStart, DragUpdate, HookProvided } from 'react-beautiful-dnd';
|
||||
import { DragDropContext, Draggable, Droppable, DropResult, DragStart, DragUpdate, ResponderProvided } from 'react-beautiful-dnd';
|
||||
|
||||
interface Item {
|
||||
id: string;
|
||||
@@ -48,15 +48,23 @@ class App extends React.Component<{}, AppState> {
|
||||
this.onDragEnd = this.onDragEnd.bind(this);
|
||||
}
|
||||
|
||||
onDragStart(dragStart: DragStart, provided: HookProvided) {
|
||||
onDragStart(dragStart: DragStart, provided: ResponderProvided) {
|
||||
//
|
||||
}
|
||||
|
||||
onDragUpdate(dragUpdate: DragUpdate, provided: HookProvided) {
|
||||
onDragUpdate(dragUpdate: DragUpdate, provided: ResponderProvided) {
|
||||
//
|
||||
}
|
||||
|
||||
onDragEnd(result: DropResult, provided: HookProvided) {
|
||||
onDragEnd(result: DropResult, provided: ResponderProvided) {
|
||||
if (result.combine) {
|
||||
// super simple: just removing the dragging item
|
||||
const items: Item[] = [...this.state.items];
|
||||
items.splice(result.source.index, 1);
|
||||
this.setState({ items });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result.destination) {
|
||||
return;
|
||||
}
|
||||
@@ -73,7 +81,7 @@ class App extends React.Component<{}, AppState> {
|
||||
render() {
|
||||
return (
|
||||
<DragDropContext onDragStart={this.onDragStart} onDragUpdate={this.onDragUpdate} onDragEnd={this.onDragEnd}>
|
||||
<Droppable droppableId="droppable" ignoreContainerClipping={false}>
|
||||
<Droppable droppableId="droppable" ignoreContainerClipping={false} isCombineEnabled={true}>
|
||||
{(provided, snapshot) => (
|
||||
<div ref={provided.innerRef} style={getListStyle(snapshot.isDraggingOver)} {...provided.droppableProps}>
|
||||
{this.state.items.map((item, index) => (
|
||||
|
||||
@@ -252,11 +252,11 @@ class Example extends React.Component<any, any> {
|
||||
getColumns() {
|
||||
var clonedColumns = columns.slice();
|
||||
clonedColumns[2].events = {
|
||||
onClick: function (ev:React.SyntheticEvent<any>, args:{idx:number, rowIdx:number}) {
|
||||
onClick: (ev:React.SyntheticEvent<any>, args:{idx:number, rowIdx:number}) => {
|
||||
var idx = args.idx;
|
||||
var rowIdx = args.rowIdx;
|
||||
this.refs.grid.openCellEditor(rowIdx, idx);
|
||||
}.bind(this)
|
||||
(this.refs.grid as ReactDataGrid<{}>).openCellEditor(rowIdx, idx);
|
||||
}
|
||||
};
|
||||
|
||||
return clonedColumns;
|
||||
|
||||
@@ -198,11 +198,11 @@ class Example extends React.Component<any, any> {
|
||||
getColumns() {
|
||||
var clonedColumns = columns.slice();
|
||||
clonedColumns[2].events = {
|
||||
onClick: function (ev:React.SyntheticEvent<any>, args:{idx:number, rowIdx:number}) {
|
||||
onClick: (ev:React.SyntheticEvent<any>, args:{idx:number, rowIdx:number}) => {
|
||||
var idx = args.idx;
|
||||
var rowIdx = args.rowIdx;
|
||||
this.refs.grid.openCellEditor(rowIdx, idx);
|
||||
}.bind(this)
|
||||
(this.refs.grid as ReactDataGrid)
|
||||
}
|
||||
};
|
||||
|
||||
return clonedColumns;
|
||||
|
||||
@@ -252,11 +252,11 @@ class Example extends React.Component<any, any> {
|
||||
getColumns() {
|
||||
var clonedColumns = columns.slice();
|
||||
clonedColumns[2].events = {
|
||||
onClick: function (ev:React.SyntheticEvent<any>, args:{idx:number, rowIdx:number}) {
|
||||
onClick: (ev:React.SyntheticEvent<any>, args:{idx:number, rowIdx:number}) => {
|
||||
var idx = args.idx;
|
||||
var rowIdx = args.rowIdx;
|
||||
this.refs.grid.openCellEditor(rowIdx, idx);
|
||||
}.bind(this)
|
||||
(this.refs.grid as ReactDataGrid).openCellEditor(rowIdx, idx);
|
||||
}
|
||||
};
|
||||
|
||||
return clonedColumns;
|
||||
|
||||
@@ -102,17 +102,17 @@ export default class DocViewerExample extends React.Component {
|
||||
<View>
|
||||
<Text>Doc Viewer React Native</Text>
|
||||
<Button
|
||||
onPress={this.handlePress.bind(this)}
|
||||
onPress={this.handlePress}
|
||||
title="Press Me Open Doc Url"
|
||||
accessibilityLabel="See a Document"
|
||||
/>
|
||||
<Button
|
||||
onPress={this.handlePressBinaryinUrl.bind(this)}
|
||||
onPress={this.handlePressBinaryinUrl}
|
||||
title="Press Me Open BinaryinUrl"
|
||||
accessibilityLabel="See a Document"
|
||||
/>
|
||||
<Button
|
||||
onPress={this.handlePressb64.bind(this)}
|
||||
onPress={this.handlePressb64}
|
||||
title="Press Me Open Base64 String"
|
||||
accessibilityLabel="See a Document"
|
||||
/>
|
||||
|
||||
Vendored
+7
-10
@@ -8,6 +8,7 @@
|
||||
// James Garbutt <https://github.com/43081j>
|
||||
// Bartek Szczepański <https://github.com/barnski>
|
||||
// Pirasis Leelatanon <https://github.com/1pete>
|
||||
// Stanislav Dzhus <https://github.com/blablapolicja>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Imported from: https://github.com/types/npm-redis
|
||||
@@ -159,8 +160,8 @@ export interface Commands<R> {
|
||||
/**
|
||||
* Set multiple hash fields to multiple values.
|
||||
*/
|
||||
hmset: OverloadedSetCommand<string | number, boolean, R>;
|
||||
HMSET: OverloadedSetCommand<string | number, boolean, R>;
|
||||
hmset: OverloadedSetCommand<string | number, 'OK', R>;
|
||||
HMSET: OverloadedSetCommand<string | number, 'OK', R>;
|
||||
|
||||
/**
|
||||
* Listen for messages published to the given channels.
|
||||
@@ -393,8 +394,8 @@ export interface Commands<R> {
|
||||
/**
|
||||
* Remove all keys from the current database.
|
||||
*/
|
||||
flushdb(cb?: Callback<string>): R;
|
||||
FLUSHDB(cb?: Callback<string>): R;
|
||||
flushdb(cb?: Callback<'OK'>): R;
|
||||
FLUSHDB(cb?: Callback<'OK'>): R;
|
||||
|
||||
/**
|
||||
* Add one or more geospatial items in the geospatial index represented using a sorted set.
|
||||
@@ -1169,9 +1170,7 @@ export interface Commands<R> {
|
||||
ZSCAN: OverloadedKeyCommand<string, [string, string[]], R>;
|
||||
}
|
||||
|
||||
export const RedisClient: {
|
||||
new (options: ClientOpts): RedisClient;
|
||||
};
|
||||
export const RedisClient: new (options: ClientOpts) => RedisClient;
|
||||
|
||||
export interface RedisClient extends Commands<boolean>, EventEmitter {
|
||||
connected: boolean;
|
||||
@@ -1221,9 +1220,7 @@ export interface RedisClient extends Commands<boolean>, EventEmitter {
|
||||
BATCH(args?: Array<Array<string | number | Callback<any>>>): Multi;
|
||||
}
|
||||
|
||||
export const Multi: {
|
||||
new (): Multi;
|
||||
};
|
||||
export const Multi: new () => Multi;
|
||||
|
||||
export interface Multi extends Commands<Multi> {
|
||||
exec(cb?: Callback<any[]>): boolean;
|
||||
|
||||
@@ -9,6 +9,7 @@ const args: any[] = [];
|
||||
const resCallback: (err: Error | null, res: any) => void = () => {};
|
||||
const numCallback: (err: Error | null, res: number) => void = () => {};
|
||||
const strCallback: (err: Error | null, res: string) => void = () => {};
|
||||
const okCallback: (err: Error | null, res: 'OK') => void = () => {};
|
||||
const messageHandler: (channel: string, message: any) => void = () => {};
|
||||
|
||||
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
|
||||
@@ -66,7 +67,7 @@ client.unref();
|
||||
client.append(str, str, numCallback);
|
||||
client.bitcount(str, numCallback);
|
||||
client.bitcount(str, num, num, numCallback);
|
||||
client.set(str, str, strCallback);
|
||||
client.set(str, str, okCallback);
|
||||
client.get(str, strCallback);
|
||||
client.exists(str, numCallback);
|
||||
|
||||
@@ -80,15 +81,15 @@ client.once(str, messageHandler);
|
||||
client.get('test');
|
||||
client.get('test', resCallback);
|
||||
client.set('test', 'test');
|
||||
client.set('test', 'test', resCallback);
|
||||
client.set('test', 'test', okCallback);
|
||||
client.mset(args, resCallback);
|
||||
|
||||
client.incr(str, resCallback);
|
||||
|
||||
// Friendlier hash commands
|
||||
client.hgetall(str, resCallback);
|
||||
client.hmset(str, value, resCallback);
|
||||
client.hmset(str, str, str, str, str, resCallback);
|
||||
client.hmset(str, value, okCallback);
|
||||
client.hmset(str, str, str, str, str, okCallback);
|
||||
|
||||
// Publish / Subscribe
|
||||
client.publish(str, value);
|
||||
@@ -133,3 +134,5 @@ client.hincrbyfloat('a', 'b', 1.5, (error, value) => value.startsWith('1'));
|
||||
client.HINCRBYFLOAT('a', 'b', 1.5, (error, value) => value.startsWith('1'));
|
||||
client.zincrby('a', 1, 'b', strCallback);
|
||||
client.ZINCRBY('a', 1, 'b', strCallback);
|
||||
|
||||
client.flushdb(okCallback);
|
||||
|
||||
Vendored
+12
@@ -224,6 +224,18 @@ declare namespace Sortable {
|
||||
* Element is dropped into the list from another list
|
||||
*/
|
||||
onAdd?: (event: SortableEvent) => void;
|
||||
/**
|
||||
* Created a clone of an element
|
||||
*/
|
||||
onClone?: (event: SortableEvent) => void;
|
||||
/**
|
||||
* Element is chosen
|
||||
*/
|
||||
onChoose?: (event: SortableEvent) => void;
|
||||
/**
|
||||
* Element is unchosen
|
||||
*/
|
||||
onUnchoose?: (event: SortableEvent) => void;
|
||||
/**
|
||||
* Changed sorting within list
|
||||
*/
|
||||
|
||||
Vendored
+7
-1
@@ -1,6 +1,7 @@
|
||||
// Type definitions for typography 0.16
|
||||
// Project: https://github.com/KyleAMathews/typography.js
|
||||
// Definitions by: Boye <https://github.com/boyeborg>
|
||||
// Krzysztof Żuraw <https://github.com/krzysztofzuraw>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -11,7 +12,7 @@ interface BaseLine {
|
||||
|
||||
export interface VerticalRhythm {
|
||||
rhythm: (value: number) => string;
|
||||
scale: (value: number) => object;
|
||||
scale: (value: number) => BaseLine;
|
||||
adjustFontSizeTo: (value?: number | string) => object;
|
||||
linesForFontSize: (fontSize: number) => number;
|
||||
establishBaseline: () => BaseLine;
|
||||
@@ -55,6 +56,11 @@ declare class Typography {
|
||||
createStyles(): string;
|
||||
toJSON(): object;
|
||||
injectStyles(): void;
|
||||
rhythm: VerticalRhythm["rhythm"];
|
||||
scale: VerticalRhythm["scale"];
|
||||
adjustFontSizeTo: VerticalRhythm["adjustFontSizeTo"];
|
||||
linesForFontSize: VerticalRhythm["linesForFontSize"];
|
||||
establishBaseline: VerticalRhythm["establishBaseline"];
|
||||
}
|
||||
|
||||
export default Typography;
|
||||
|
||||
@@ -10,3 +10,8 @@ const typography = new Typography({
|
||||
typography.createStyles(); // $ExpectType string
|
||||
typography.toJSON(); // $ExpectType object
|
||||
typography.options; // $ExpectType TypographyOptions
|
||||
typography.rhythm(2); // $ExpectType string
|
||||
typography.scale(2 / 5); // $ExpectType BaseLine
|
||||
typography.adjustFontSizeTo(); // $ExpectType object
|
||||
typography.linesForFontSize(1); // $ExpectType number
|
||||
typography.establishBaseline(); // $ExpectType BaseLine
|
||||
|
||||
@@ -401,7 +401,7 @@ Page({
|
||||
this.setData({
|
||||
animationData:animation.export()
|
||||
})
|
||||
}.bind(this), 1000)
|
||||
}, 1000)
|
||||
},
|
||||
rotateAndScale: function () {
|
||||
// 旋转同时放大
|
||||
|
||||
Vendored
+1
-1
@@ -5172,8 +5172,8 @@ declare namespace XrmEnum {
|
||||
Lookup = "lookup",
|
||||
Memo = "memo",
|
||||
Money = "money",
|
||||
MultiOptionSet = "multioptionset",
|
||||
OptionSet = "optionset",
|
||||
MultiSelectOptionSet = "multiselectoptionset",
|
||||
String = "string"
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -2,12 +2,12 @@
|
||||
// Project: https://github.com/yargs/yargs-parser#readme
|
||||
// Definitions by: Miles Johnson <https://github.com/milesj>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Arguments as YargsArguments } from 'yargs';
|
||||
|
||||
declare namespace yargsParser {
|
||||
type Arguments = YargsArguments;
|
||||
type Arguments = YargsArguments<{}>;
|
||||
|
||||
interface DetailedArguments {
|
||||
argv: Arguments;
|
||||
|
||||
Vendored
+214
-140
@@ -6,253 +6,278 @@
|
||||
// Jeff Kenney <https://github.com/jeffkenney>
|
||||
// Jimi (Dimitris) Charalampidis <https://github.com/JimiC>
|
||||
// Teddy Cross <https://github.com/tkazec>
|
||||
// Steffen Viken Valvåg <https://github.com/steffenvv>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
// The following TSLint rules have been disabled:
|
||||
// unified-signatures: Because there is useful information in the argument names of the overloaded signatures
|
||||
|
||||
// Convention:
|
||||
// Use 'union types' when:
|
||||
// - parameter types have similar signature type (i.e. 'string | string[]')
|
||||
// - parameter types have similar signature type (i.e. 'string | ReadonlyArray<string>')
|
||||
// - parameter names have the same semantic meaning (i.e. ['command', 'commands'] , ['key', 'keys'])
|
||||
// An example for not using 'union types' is the declaration of 'env' where `prefix` and `enable` parameters
|
||||
// have different semantics. On the other hand, in the declaration of 'usage', a `command: string` parameter
|
||||
// has the same semantic meaning with declaring an overload method by using `commands: string[]`, thus
|
||||
// it's prefered to use `command: string | string[]`
|
||||
// has the same semantic meaning with declaring an overload method by using `commands: ReadonlyArray<string>`,
|
||||
// thus it's preferred to use `command: string | ReadonlyArray<string>`
|
||||
// Use parameterless declaration instead of declaring all parameters optional,
|
||||
// when all parameters are optional and more than one
|
||||
|
||||
declare namespace yargs {
|
||||
interface Argv {
|
||||
(): Arguments;
|
||||
(args: string[], cwd?: string): Arguments;
|
||||
// The type parameter T is the expected shape of the parsed options.
|
||||
// Arguments<T> is those options plus _ and $0, and an indexer falling
|
||||
// back to any for unknown options.
|
||||
//
|
||||
// For the return type / argv property, we create a mapped type over
|
||||
// Arguments<T> to simplify the inferred type signature in client code.
|
||||
interface Argv<T = {}> {
|
||||
(): { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||
(args: ReadonlyArray<string>, cwd?: string): { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||
|
||||
alias(shortName: string | string[], longName: string | string[]): Argv;
|
||||
alias(aliases: { [shortName: string]: string | string[] }): Argv;
|
||||
// Aliases for previously declared options can inherit the types of those options.
|
||||
alias<K1 extends keyof T, K2 extends string>(shortName: K1, longName: K2 | ReadonlyArray<K2>): Argv<T & { [key in K2]: T[K1] }>;
|
||||
alias<K1 extends keyof T, K2 extends string>(shortName: K2, longName: K1 | ReadonlyArray<K1>): Argv<T & { [key in K2]: T[K1] }>;
|
||||
alias(shortName: string | ReadonlyArray<string>, longName: string | ReadonlyArray<string>): Argv<T>;
|
||||
alias(aliases: { [shortName: string]: string | ReadonlyArray<string> }): Argv<T>;
|
||||
|
||||
argv: Arguments;
|
||||
argv: { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||
|
||||
array(key: string | string[]): Argv;
|
||||
array<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToArray<T[key]> }>;
|
||||
array<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: Array<string | number> | undefined }>;
|
||||
|
||||
boolean(key: string | string[]): Argv;
|
||||
boolean<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: boolean | undefined }>;
|
||||
boolean<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: boolean | undefined }>;
|
||||
|
||||
check(func: (argv: Arguments, aliases: { [alias: string]: string }) => any, global?: boolean): Argv;
|
||||
check(func: (argv: Arguments<T>, aliases: { [alias: string]: string }) => any, global?: boolean): Argv<T>;
|
||||
|
||||
choices(key: string, values: Choices): Argv;
|
||||
choices(choices: { [argName: string]: Choices }): Argv;
|
||||
choices<K extends keyof T, C extends ReadonlyArray<any>>(key: K, values: C): Argv<Omit<T, K> & { [key in K]: C[number] | undefined }>;
|
||||
choices<K extends string, C extends ReadonlyArray<any>>(key: K, values: C): Argv<T & { [key in K]: C[number] | undefined }>;
|
||||
choices<C extends { [key: string]: ReadonlyArray<any> }>(choices: C): Argv<Omit<T, keyof C> & { [key in keyof C]: C[key][number] | undefined }>;
|
||||
|
||||
coerce(key: string | string[], func: (arg: any) => any): Argv;
|
||||
coerce(opts: { [key: string]: (arg: any) => any; }): Argv;
|
||||
coerce<K extends keyof T, V>(key: K | ReadonlyArray<K>, func: (arg: any) => V): Argv<Omit<T, K> & { [key in K]: V | undefined }>;
|
||||
coerce<K extends string, V>(key: K | ReadonlyArray<K>, func: (arg: any) => V): Argv<T & { [key in K]: V | undefined }>;
|
||||
coerce<O extends { [key: string]: (arg: any) => any }>(opts: O): Argv<Omit<T, keyof O> & { [key in keyof O]: ReturnType<O[key]> | undefined }>;
|
||||
|
||||
command(command: string | string[], description: string, builder?: (args: Argv) => Argv, handler?: (args: Arguments) => void): Argv;
|
||||
command(command: string | string[], description: string, builder?: { [key: string]: Options }, handler?: (args: Arguments) => void): Argv;
|
||||
command(command: string | string[], description: string, module: CommandModule): Argv;
|
||||
command(command: string | string[], showInHelp: false, builder?: (args: Argv) => Argv, handler?: (args: Arguments) => void): Argv;
|
||||
command(command: string | string[], showInHelp: false, builder?: { [key: string]: Options }, handler?: (args: Arguments) => void): Argv;
|
||||
command(command: string | string[], showInHelp: false, module: CommandModule): Argv;
|
||||
command(module: CommandModule): Argv;
|
||||
command<U>(command: string | ReadonlyArray<string>, description: string, builder?: (args: Argv<T>) => Argv<U>, handler?: (args: Arguments<U>) => void): Argv<T>;
|
||||
command<O extends { [key: string]: Options }>(command: string | ReadonlyArray<string>, description: string, builder?: O, handler?: (args: Arguments<InferredOptionTypes<O>>) => void): Argv<T>;
|
||||
command(command: string | ReadonlyArray<string>, description: string, module: CommandModule<T, any>): Argv<T>;
|
||||
command<U>(command: string | ReadonlyArray<string>, showInHelp: false, builder?: (args: Argv<T>) => Argv<U>, handler?: (args: Arguments<U>) => void): Argv<T>;
|
||||
command<O extends { [key: string]: Options }>(command: string | ReadonlyArray<string>, showInHelp: false, builder?: O, handler?: (args: Arguments<InferredOptionTypes<O>>) => void): Argv<T>;
|
||||
command<U>(command: string | ReadonlyArray<string>, showInHelp: false, module: CommandModule<T, U>): Argv<U>;
|
||||
command<U>(module: CommandModule<T, U>): Argv<U>;
|
||||
|
||||
// Advanced API
|
||||
commandDir(dir: string, opts?: RequireDirectoryOptions): Argv;
|
||||
commandDir(dir: string, opts?: RequireDirectoryOptions): Argv<T>;
|
||||
|
||||
completion(): Argv;
|
||||
completion(cmd: string, func?: AsyncCompletionFunction): Argv;
|
||||
completion(cmd: string, func?: SyncCompletionFunction): Argv;
|
||||
completion(cmd: string, description?: string, func?: AsyncCompletionFunction): Argv;
|
||||
completion(cmd: string, description?: string, func?: SyncCompletionFunction): Argv;
|
||||
completion(): Argv<T>;
|
||||
completion(cmd: string, func?: AsyncCompletionFunction): Argv<T>;
|
||||
completion(cmd: string, func?: SyncCompletionFunction): Argv<T>;
|
||||
completion(cmd: string, description?: string, func?: AsyncCompletionFunction): Argv<T>;
|
||||
completion(cmd: string, description?: string, func?: SyncCompletionFunction): Argv<T>;
|
||||
|
||||
config(): Argv;
|
||||
config(key: string | string[], description?: string, parseFn?: (configPath: string) => object): Argv;
|
||||
config(key: string | string[], parseFn: (configPath: string) => object): Argv;
|
||||
config(explicitConfigurationObject: object): Argv;
|
||||
config(): Argv<T>;
|
||||
config(key: string | ReadonlyArray<string>, description?: string, parseFn?: (configPath: string) => object): Argv<T>;
|
||||
config(key: string | ReadonlyArray<string>, parseFn: (configPath: string) => object): Argv<T>;
|
||||
config(explicitConfigurationObject: object): Argv<T>;
|
||||
|
||||
conflicts(key: string, value: string | string[]): Argv;
|
||||
conflicts(conflicts: { [key: string]: string | string[] }): Argv;
|
||||
conflicts(key: string, value: string | ReadonlyArray<string>): Argv<T>;
|
||||
conflicts(conflicts: { [key: string]: string | ReadonlyArray<string> }): Argv<T>;
|
||||
|
||||
count(key: string | string[]): Argv;
|
||||
count<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: number }>;
|
||||
count<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: number }>;
|
||||
|
||||
default(key: string, value: any, description?: string): Argv;
|
||||
default(defaults: { [key: string]: any }, description?: string): Argv;
|
||||
default<K extends keyof T, V>(key: K, value: V, description?: string): Argv<Omit<T, K> & { [key in K]: V }>;
|
||||
default<K extends string, V>(key: K, value: V, description?: string): Argv<T & { [key in K]: V }>;
|
||||
default<D extends { [key: string]: any }>(defaults: D, description?: string): Argv<Omit<T, keyof D> & D>;
|
||||
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use '.demandCommand()' or '.demandOption()' instead
|
||||
*/
|
||||
demand(key: string | string[], msg: string): Argv;
|
||||
demand(key: string | string[], required?: boolean): Argv;
|
||||
demand(positionals: number, msg: string): Argv;
|
||||
demand(positionals: number, required?: boolean): Argv;
|
||||
demand(positionals: number, max: number, msg?: string): Argv;
|
||||
demand<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||
demand(key: string | ReadonlyArray<string>, msg: string): Argv<T>;
|
||||
demand(key: string | ReadonlyArray<string>, required?: boolean): Argv<T>;
|
||||
demand(positionals: number, msg: string): Argv<T>;
|
||||
demand(positionals: number, required?: boolean): Argv<T>;
|
||||
demand(positionals: number, max: number, msg?: string): Argv<T>;
|
||||
|
||||
demandOption(key: string | string[], msg?: string): Argv;
|
||||
demandOption(key: string | string[], demand?: boolean): Argv;
|
||||
demandOption<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||
demandOption(key: string | ReadonlyArray<string>, msg?: string): Argv<T>;
|
||||
demandOption(key: string | ReadonlyArray<string>, demand?: boolean): Argv<T>;
|
||||
|
||||
demandCommand(): Argv;
|
||||
demandCommand(min: number, minMsg?: string): Argv;
|
||||
demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv;
|
||||
demandCommand(): Argv<T>;
|
||||
demandCommand(min: number, minMsg?: string): Argv<T>;
|
||||
demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv<T>;
|
||||
|
||||
describe(key: string | string[], description: string): Argv;
|
||||
describe(descriptions: { [key: string]: string }): Argv;
|
||||
describe(key: string | ReadonlyArray<string>, description: string): Argv<T>;
|
||||
describe(descriptions: { [key: string]: string }): Argv<T>;
|
||||
|
||||
detectLocale(detect: boolean): Argv;
|
||||
detectLocale(detect: boolean): Argv<T>;
|
||||
|
||||
env(): Argv;
|
||||
env(prefix: string): Argv;
|
||||
env(enable: boolean): Argv;
|
||||
env(): Argv<T>;
|
||||
env(prefix: string): Argv<T>;
|
||||
env(enable: boolean): Argv<T>;
|
||||
|
||||
epilog(msg: string): Argv;
|
||||
epilog(msg: string): Argv<T>;
|
||||
|
||||
epilogue(msg: string): Argv;
|
||||
epilogue(msg: string): Argv<T>;
|
||||
|
||||
example(command: string, description: string): Argv;
|
||||
example(command: string, description: string): Argv<T>;
|
||||
|
||||
exitProcess(enabled: boolean): Argv;
|
||||
exitProcess(enabled: boolean): Argv<T>;
|
||||
|
||||
fail(func: (msg: string, err: Error) => any): Argv;
|
||||
fail(func: (msg: string, err: Error) => any): Argv<T>;
|
||||
|
||||
getCompletion(args: string[], done: (completions: string[]) => void): Argv;
|
||||
getCompletion(args: ReadonlyArray<string>, done: (completions: ReadonlyArray<string>) => void): Argv<T>;
|
||||
|
||||
global(key: string | string[]): Argv;
|
||||
global(key: string | ReadonlyArray<string>): Argv<T>;
|
||||
|
||||
group(key: string | string[], groupName: string): Argv;
|
||||
group(key: string | ReadonlyArray<string>, groupName: string): Argv<T>;
|
||||
|
||||
hide(key: string): Argv;
|
||||
hide(key: string): Argv<T>;
|
||||
|
||||
help(): Argv;
|
||||
help(enableExplicit: boolean): Argv;
|
||||
help(option: string, enableExplicit: boolean): Argv;
|
||||
help(option: string, description?: string, enableExplicit?: boolean): Argv;
|
||||
help(): Argv<T>;
|
||||
help(enableExplicit: boolean): Argv<T>;
|
||||
help(option: string, enableExplicit: boolean): Argv<T>;
|
||||
help(option: string, description?: string, enableExplicit?: boolean): Argv<T>;
|
||||
|
||||
implies(key: string, value: string | string[]): Argv;
|
||||
implies(implies: { [key: string]: string | string[] }): Argv;
|
||||
implies(key: string, value: string | ReadonlyArray<string>): Argv<T>;
|
||||
implies(implies: { [key: string]: string | ReadonlyArray<string> }): Argv<T>;
|
||||
|
||||
locale(): string;
|
||||
locale(loc: string): Argv;
|
||||
locale(loc: string): Argv<T>;
|
||||
|
||||
middleware(callbacks: MiddlewareFunction | MiddlewareFunction[]): Argv;
|
||||
middleware(callbacks: MiddlewareFunction<T> | ReadonlyArray<MiddlewareFunction<T>>): Argv<T>;
|
||||
|
||||
nargs(key: string, count: number): Argv;
|
||||
nargs(nargs: { [key: string]: number }): Argv;
|
||||
nargs(key: string, count: number): Argv<T>;
|
||||
nargs(nargs: { [key: string]: number }): Argv<T>;
|
||||
|
||||
normalize(key: string | string[]): Argv;
|
||||
normalize<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToString<T[key]> }>;
|
||||
normalize<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: string | undefined }>;
|
||||
|
||||
number(key: string | string[]): Argv;
|
||||
number<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToNumber<T[key]> }>;
|
||||
number<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: number | undefined }>;
|
||||
|
||||
option(key: string, options: Options): Argv;
|
||||
option(options: { [key: string]: Options }): Argv;
|
||||
option<K extends keyof T, O extends Options>(key: K, options: O): Argv<Omit<T, K> & { [key in K]: InferredOptionType<O> }>;
|
||||
option<K extends string, O extends Options>(key: K, options: O): Argv<T & { [key in K]: InferredOptionType<O> }>;
|
||||
option<O extends { [key: string]: Options }>(options: O): Argv<Omit<T, keyof O> & InferredOptionTypes<O>>;
|
||||
|
||||
options(key: string, options: Options): Argv;
|
||||
options(options: { [key: string]: Options }): Argv;
|
||||
options<K extends keyof T, O extends Options>(key: K, options: O): Argv<Omit<T, K> & { [key in K]: InferredOptionType<O> }>;
|
||||
options<K extends string, O extends Options>(key: K, options: O): Argv<T & { [key in K]: InferredOptionType<O> }>;
|
||||
options<O extends { [key: string]: Options }>(options: O): Argv<Omit<T, keyof O> & InferredOptionTypes<O>>;
|
||||
|
||||
parse(): Arguments;
|
||||
parse(arg: string | string[], context?: object, parseCallback?: ParseCallback): Arguments;
|
||||
parse(): Arguments<T>;
|
||||
parse(arg: string | ReadonlyArray<string>, context?: object, parseCallback?: ParseCallback<T>): Arguments<T>;
|
||||
|
||||
pkgConf(key: string | string[], cwd?: string): Argv;
|
||||
pkgConf(key: string | ReadonlyArray<string>, cwd?: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* 'positional' should be called in a command's builder function, and is not
|
||||
* available on the top-level yargs instance. If so, it will throw an error.
|
||||
*/
|
||||
positional(key: string, opt: PositionalOptions): Argv;
|
||||
positional(key: string, opt: PositionalOptions): Argv<T>;
|
||||
|
||||
recommendCommands(): Argv;
|
||||
recommendCommands(): Argv<T>;
|
||||
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use '.demandCommand()' or '.demandOption()' instead
|
||||
*/
|
||||
require(key: string, msg: string): Argv;
|
||||
require(key: string, required: boolean): Argv;
|
||||
require(keys: number[], msg: string): Argv;
|
||||
require(keys: number[], required: boolean): Argv;
|
||||
require(positionals: number, required: boolean): Argv;
|
||||
require(positionals: number, msg: string): Argv;
|
||||
require<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||
require(key: string, msg: string): Argv<T>;
|
||||
require(key: string, required: boolean): Argv<T>;
|
||||
require(keys: ReadonlyArray<number>, msg: string): Argv<T>;
|
||||
require(keys: ReadonlyArray<number>, required: boolean): Argv<T>;
|
||||
require(positionals: number, required: boolean): Argv<T>;
|
||||
require(positionals: number, msg: string): Argv<T>;
|
||||
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use '.demandCommand()' or '.demandOption()' instead
|
||||
*/
|
||||
required(key: string, msg: string): Argv;
|
||||
required(key: string, required: boolean): Argv;
|
||||
required(keys: number[], msg: string): Argv;
|
||||
required(keys: number[], required: boolean): Argv;
|
||||
required(positionals: number, required: boolean): Argv;
|
||||
required(positionals: number, msg: string): Argv;
|
||||
required<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||
required(key: string, msg: string): Argv<T>;
|
||||
required(key: string, required: boolean): Argv<T>;
|
||||
required(keys: ReadonlyArray<number>, msg: string): Argv<T>;
|
||||
required(keys: ReadonlyArray<number>, required: boolean): Argv<T>;
|
||||
required(positionals: number, required: boolean): Argv<T>;
|
||||
required(positionals: number, msg: string): Argv<T>;
|
||||
|
||||
requiresArg(key: string | string[]): Argv;
|
||||
requiresArg(key: string | ReadonlyArray<string>): Argv<T>;
|
||||
|
||||
/**
|
||||
* @deprecated since version 6.6.0
|
||||
* Use '.global()' instead
|
||||
*/
|
||||
reset(): Argv;
|
||||
reset(): Argv<T>;
|
||||
|
||||
scriptName($0: string): Argv;
|
||||
scriptName($0: string): Argv<T>;
|
||||
|
||||
showCompletionScript(): Argv;
|
||||
showCompletionScript(): Argv<T>;
|
||||
|
||||
showHidden(option?: string | boolean): Argv;
|
||||
showHidden(option: string, description?: string): Argv;
|
||||
showHidden(option?: string | boolean): Argv<T>;
|
||||
showHidden(option: string, description?: string): Argv<T>;
|
||||
|
||||
showHelp(consoleLevel?: string): Argv;
|
||||
showHelp(consoleLevel?: string): Argv<T>;
|
||||
|
||||
showHelpOnFail(enable: boolean, message?: string): Argv;
|
||||
showHelpOnFail(enable: boolean, message?: string): Argv<T>;
|
||||
|
||||
skipValidation(key: string | string[]): Argv;
|
||||
skipValidation(key: string | ReadonlyArray<string>): Argv<T>;
|
||||
|
||||
strict(): Argv;
|
||||
strict(): Argv<T>;
|
||||
|
||||
string(key: string | string[]): Argv;
|
||||
string<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToString<T[key]> }>;
|
||||
string<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: string | undefined }>;
|
||||
|
||||
// Intended to be used with '.wrap()'
|
||||
terminalWidth(): number;
|
||||
|
||||
updateLocale(obj: { [key: string]: string }): Argv;
|
||||
updateLocale(obj: { [key: string]: string }): Argv<T>;
|
||||
|
||||
updateStrings(obj: { [key: string]: string }): Argv;
|
||||
updateStrings(obj: { [key: string]: string }): Argv<T>;
|
||||
|
||||
usage(message: string): Argv;
|
||||
usage(command: string | string[], description: string, builder?: (args: Argv) => Argv, handler?: (args: Arguments) => void): Argv;
|
||||
usage(command: string | string[], showInHelp: boolean, builder?: (args: Argv) => Argv, handler?: (args: Arguments) => void): Argv;
|
||||
usage(command: string | string[], description: string, builder?: { [key: string]: Options }, handler?: (args: Arguments) => void): Argv;
|
||||
usage(commands: string | string[], showInHelp: boolean, builder?: { [key: string]: Options }, handler?: (args: Arguments) => void): Argv;
|
||||
usage(message: string): Argv<T>;
|
||||
usage<U>(command: string | ReadonlyArray<string>, description: string, builder?: (args: Argv<T>) => Argv<U>, handler?: (args: Arguments<U>) => void): Argv<T>;
|
||||
usage<U>(command: string | ReadonlyArray<string>, showInHelp: boolean, builder?: (args: Argv<T>) => Argv<U>, handler?: (args: Arguments<U>) => void): Argv<T>;
|
||||
usage<O extends { [key: string]: Options }>(command: string | ReadonlyArray<string>, description: string, builder?: O, handler?: (args: Arguments<InferredOptionTypes<O>>) => void): Argv<T>;
|
||||
usage<O extends { [key: string]: Options }>(command: string | ReadonlyArray<string>, showInHelp: boolean, builder?: O, handler?: (args: Arguments<InferredOptionTypes<O>>) => void): Argv<T>;
|
||||
|
||||
version(): Argv;
|
||||
version(version: string): Argv;
|
||||
version(enable: boolean): Argv;
|
||||
version(optionKey: string, version: string): Argv;
|
||||
version(optionKey: string, description: string, version: string): Argv;
|
||||
version(): Argv<T>;
|
||||
version(version: string): Argv<T>;
|
||||
version(enable: boolean): Argv<T>;
|
||||
version(optionKey: string, version: string): Argv<T>;
|
||||
version(optionKey: string, description: string, version: string): Argv<T>;
|
||||
|
||||
wrap(columns: number | null): Argv;
|
||||
wrap(columns: number | null): Argv<T>;
|
||||
}
|
||||
|
||||
interface Arguments {
|
||||
type Arguments<T> = T & {
|
||||
/** Non-option arguments */
|
||||
_: string[];
|
||||
/** The script name or node command */
|
||||
$0: string;
|
||||
/** All remaining options */
|
||||
[argName: string]: any;
|
||||
}
|
||||
};
|
||||
|
||||
interface RequireDirectoryOptions {
|
||||
recurse?: boolean;
|
||||
extensions?: string[];
|
||||
extensions?: ReadonlyArray<string>;
|
||||
visit?: (commandObject: any, pathToFile?: string, filename?: string) => any;
|
||||
include?: RegExp | ((pathToFile: string) => boolean);
|
||||
exclude?: RegExp | ((pathToFile: string) => boolean);
|
||||
}
|
||||
|
||||
interface Options {
|
||||
alias?: string | string[];
|
||||
alias?: string | ReadonlyArray<string>;
|
||||
array?: boolean;
|
||||
boolean?: boolean;
|
||||
choices?: Choices;
|
||||
coerce?: (arg: any) => any;
|
||||
config?: boolean;
|
||||
configParser?: (configPath: string) => object;
|
||||
conflicts?: string | string[] | { [key: string]: string | string[] };
|
||||
conflicts?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||
count?: boolean;
|
||||
default?: any;
|
||||
defaultDescription?: string;
|
||||
@@ -268,7 +293,7 @@ declare namespace yargs {
|
||||
global?: boolean;
|
||||
group?: string;
|
||||
hidden?: boolean;
|
||||
implies?: string | string[] | { [key: string]: string | string[] };
|
||||
implies?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||
nargs?: number;
|
||||
normalize?: boolean;
|
||||
number?: boolean;
|
||||
@@ -289,33 +314,82 @@ declare namespace yargs {
|
||||
}
|
||||
|
||||
interface PositionalOptions {
|
||||
alias?: string | string[];
|
||||
alias?: string | ReadonlyArray<string>;
|
||||
choices?: Choices;
|
||||
coerce?: (arg: any) => any;
|
||||
conflicts?: string | string[] | { [key: string]: string | string[] };
|
||||
conflicts?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||
default?: any;
|
||||
desc?: string;
|
||||
describe?: string;
|
||||
description?: string;
|
||||
implies?: string | string[] | { [key: string]: string | string[] };
|
||||
implies?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||
normalize?: boolean;
|
||||
type?: PositionalOptionsType;
|
||||
}
|
||||
|
||||
interface CommandModule {
|
||||
aliases?: string[] | string;
|
||||
builder?: CommandBuilder;
|
||||
command?: string[] | string;
|
||||
/** Remove keys K in T */
|
||||
type Omit<T, K> = { [key in Exclude<keyof T, K>]: T[key] };
|
||||
|
||||
/** Remove undefined as a possible value for keys K in T */
|
||||
type Defined<T, K extends keyof T> = Omit<T, K> & { [key in K]: Exclude<T[key], undefined> };
|
||||
|
||||
/** Convert T to T[] and T | undefined to T[] | undefined */
|
||||
type ToArray<T> = Array<Exclude<T, undefined>> | Extract<T, undefined>;
|
||||
|
||||
/** Gives string[] if T is an array type, otherwise string. Preserves | undefined. */
|
||||
type ToString<T> = (Exclude<T, undefined> extends any[] ? string[] : string) | Extract<T, undefined>;
|
||||
|
||||
/** Gives number[] if T is an array type, otherwise number. Preserves | undefined. */
|
||||
type ToNumber<T> = (Exclude<T, undefined> extends any[] ? number[] : number) | Extract<T, undefined>;
|
||||
|
||||
type InferredOptionType<O extends Options | PositionalOptions> =
|
||||
O extends { default: infer D } ? D :
|
||||
O extends { type: "count" } ? number :
|
||||
O extends { count: true } ? number :
|
||||
O extends { required: string | true } ? RequiredOptionType<O> :
|
||||
O extends { require: string | true } ? RequiredOptionType<O> :
|
||||
O extends { demand: string | true } ? RequiredOptionType<O> :
|
||||
O extends { demandOption: string | true } ? RequiredOptionType<O> :
|
||||
RequiredOptionType<O> | undefined;
|
||||
|
||||
type RequiredOptionType<O extends Options | PositionalOptions> =
|
||||
O extends { type: "array", string: true } ? string[] :
|
||||
O extends { type: "array", number: true } ? number[] :
|
||||
O extends { type: "array", normalize: true } ? string[] :
|
||||
O extends { type: "string", array: true } ? string[] :
|
||||
O extends { type: "number", array: true } ? number[] :
|
||||
O extends { string: true, array: true } ? string[] :
|
||||
O extends { number: true, array: true } ? number[] :
|
||||
O extends { normalize: true, array: true } ? string[] :
|
||||
O extends { type: "array" } ? Array<string | number> :
|
||||
O extends { type: "boolean" } ? boolean :
|
||||
O extends { type: "number" } ? number :
|
||||
O extends { type: "string" } ? string :
|
||||
O extends { array: true } ? Array<string | number> :
|
||||
O extends { boolean: true } ? boolean :
|
||||
O extends { number: true } ? number :
|
||||
O extends { string: true } ? string :
|
||||
O extends { normalize: true } ? string :
|
||||
O extends { choices: ReadonlyArray<infer C> } ? C :
|
||||
O extends { coerce: (arg: any) => infer T } ? T :
|
||||
any;
|
||||
|
||||
type InferredOptionTypes<O extends { [key: string]: Options }> = { [key in keyof O]: InferredOptionType<O[key]> };
|
||||
|
||||
interface CommandModule<T, U> {
|
||||
aliases?: ReadonlyArray<string> | string;
|
||||
builder?: CommandBuilder<T, U>;
|
||||
command?: ReadonlyArray<string> | string;
|
||||
describe?: string | false;
|
||||
handler: (args: any) => void;
|
||||
handler: (args: Argv<U>) => void;
|
||||
}
|
||||
|
||||
type ParseCallback = (err: Error | undefined, argv: Arguments, output: string) => void;
|
||||
type CommandBuilder = { [key: string]: Options } | ((args: Argv) => Argv);
|
||||
type ParseCallback<T> = (err: Error | undefined, argv: Arguments<T>, output: string) => void;
|
||||
type CommandBuilder<T, U> = { [key: string]: Options } | ((args: Argv<T>) => Argv<U>);
|
||||
type SyncCompletionFunction = (current: string, argv: any) => string[];
|
||||
type AsyncCompletionFunction = (current: string, argv: any, done: (completion: string[]) => void) => void;
|
||||
type MiddlewareFunction = (args: Arguments) => void;
|
||||
type Choices = Array<string | true | undefined>;
|
||||
type AsyncCompletionFunction = (current: string, argv: any, done: (completion: ReadonlyArray<string>) => void) => void;
|
||||
type MiddlewareFunction<T> = (args: Arguments<T>) => void;
|
||||
type Choices = ReadonlyArray<string | true | undefined>;
|
||||
type PositionalOptionsType = "boolean" | "number" | "string";
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
|
||||
+266
-1
@@ -424,7 +424,7 @@ function Argv$commandDirWithOptions() {
|
||||
.commandDir('.', {
|
||||
recurse: false,
|
||||
extensions: ['js'],
|
||||
visit: (commandObject: any, pathToFile: string, filename: string) => void 0,
|
||||
visit: (commandObject: any, pathToFile?: string, filename?: string) => void 0,
|
||||
include: /.*\.js$/,
|
||||
exclude: /.*\.spec.js$/,
|
||||
})
|
||||
@@ -666,3 +666,268 @@ function Argv$scriptName() {
|
||||
const ya = yargs
|
||||
.scriptName("my-script");
|
||||
}
|
||||
|
||||
type Color = "red" | "blue" | "green";
|
||||
const colors: ReadonlyArray<Color> = ["red", "blue", "green"];
|
||||
|
||||
function Argv$inferOptionTypes() {
|
||||
// $ExpectType { [x: string]: any; a: (string | number)[] | undefined; b: boolean | undefined; c: number; n: number | undefined; s: string | undefined; _: string[]; $0: string; }
|
||||
yargs
|
||||
.option("a", { type: "array" })
|
||||
.option("b", { type: "boolean" })
|
||||
.option("c", { type: "count" })
|
||||
.option("n", { type: "number" })
|
||||
.option("s", { type: "string" })
|
||||
.argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; a: number; b: boolean; c: string; _: string[]; $0: string; }
|
||||
yargs
|
||||
.option("a", { default: 42 })
|
||||
.option("b", { default: false })
|
||||
.option("c", { default: "tmp" })
|
||||
.argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; a: (string | number)[] | undefined; b: boolean | undefined; n: number | undefined; s: string | undefined; _: string[]; $0: string; }
|
||||
yargs
|
||||
.option("a", { array: true })
|
||||
.option("b", { boolean: true })
|
||||
.option("n", { number: true })
|
||||
.option("s", { string: true })
|
||||
.argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; choices: Color; coerce: Date | undefined; count: number; normalize: string | undefined; _: string[]; $0: string; }
|
||||
yargs
|
||||
.option("choices", { choices: colors, required: true })
|
||||
.option("coerce", { coerce: () => new Date() })
|
||||
.option("count", { count: true })
|
||||
.option("normalize", { normalize: true })
|
||||
.argv;
|
||||
|
||||
// $ExpectType (string | number)[] | undefined
|
||||
yargs.array("x").argv.x;
|
||||
|
||||
// $ExpectType boolean | undefined
|
||||
yargs.boolean("x").argv.x;
|
||||
|
||||
// $ExpectType "red" | "blue" | "green" | undefined
|
||||
yargs.choices("x", colors).argv.x;
|
||||
|
||||
// $ExpectType number | undefined
|
||||
yargs.coerce("x", Date.parse).argv.x;
|
||||
|
||||
// $ExpectType number
|
||||
yargs.count("x").argv.x;
|
||||
|
||||
// $ExpectType Date
|
||||
yargs.default("x", new Date()).argv.x;
|
||||
|
||||
// $ExpectType string | undefined
|
||||
yargs.normalize("x").argv.x;
|
||||
|
||||
// $ExpectType number | undefined
|
||||
yargs.number("x").argv.x;
|
||||
|
||||
// $ExpectType string | undefined
|
||||
yargs.string("x").argv.x;
|
||||
}
|
||||
|
||||
function Argv$inferRequiredOptionTypes() {
|
||||
// $ExpectType string
|
||||
yargs.string("x").demand("x").argv.x;
|
||||
|
||||
// $ExpectType string
|
||||
yargs.string("x").demandOption("x").argv.x;
|
||||
|
||||
// $ExpectType string | undefined
|
||||
yargs.string("x").demandOption("x", false).argv.x;
|
||||
|
||||
// $ExpectType { [x: string]: any; x: string; y: number; _: string[]; $0: string; }
|
||||
yargs.string("x").number("y").demandOption(["x", "y"]).argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; x: string; y: number; _: string[]; $0: string; }
|
||||
yargs.string("x").number("y").demandOption(["x", "y"], true).argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; x: string | undefined; y: number | undefined; _: string[]; $0: string; }
|
||||
yargs.string("x").number("y").demandOption(["x", "y"], false).argv;
|
||||
|
||||
// $ExpectType string
|
||||
yargs.option("x", { string: true, require: true }).argv.x;
|
||||
|
||||
// $ExpectType string
|
||||
yargs.option("x", { string: true, required: true }).argv.x;
|
||||
|
||||
// $ExpectType string
|
||||
yargs.option("x", { string: true, demand: true }).argv.x;
|
||||
|
||||
// $ExpectType string
|
||||
yargs.option("x", { string: true, demandOption: true }).argv.x;
|
||||
|
||||
// $ExpectType string | undefined
|
||||
yargs.option("x", { string: true, demandOption: false }).argv.x;
|
||||
|
||||
// $ExpectType number
|
||||
yargs.option("x", { count: true }).argv.x;
|
||||
|
||||
// $ExpectType number
|
||||
yargs.option("x", { number: true, default: 42 }).argv.x;
|
||||
|
||||
// $ExpectType (string | number)[]
|
||||
yargs.option("x", { array: true, demandOption: true }).argv.x;
|
||||
}
|
||||
|
||||
function Argv$inferMultipleOptionTypes() {
|
||||
// $ExpectType { [x: string]: any; a: string; b: boolean; c: number; d: number; e: number; _: string[]; $0: string; }
|
||||
yargs
|
||||
.option({ a: { default: "a" }, b: { default: false } })
|
||||
.number(["c", "d", "e"])
|
||||
.demandOption(["c", "d", "e"])
|
||||
.argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; a: string; b: boolean; c: number; d: number; e: number; _: string[]; $0: string; }
|
||||
yargs
|
||||
.options({ a: { default: "a" }, b: { default: false } })
|
||||
.number(["c", "d", "e"])
|
||||
.demandOption(["c", "d", "e"])
|
||||
.argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; a: number; b: string; c: boolean; _: string[]; $0: string; }
|
||||
yargs
|
||||
.default({ a: 42, b: "b", c: false })
|
||||
.argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; a: number; b: string; c: Date; _: string[]; $0: string; }
|
||||
yargs
|
||||
.coerce({ a: Date.parse, b: String.prototype.toLowerCase, c: (s: string) => new Date(s) })
|
||||
.demandOption(["a", "b", "c"])
|
||||
.argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; a: number | undefined; b: string | undefined; c: Color; _: string[]; $0: string; }
|
||||
yargs
|
||||
.choices({ a: [1, 2, 3], b: ["black", "white"], c: colors })
|
||||
.demandOption("c")
|
||||
.argv;
|
||||
}
|
||||
|
||||
function Argv$inferOptionTypesForAliases() {
|
||||
// $ExpectType { [x: string]: any; u: string | undefined; url: string | undefined; _: string[]; $0: string; }
|
||||
yargs
|
||||
.option("u", { type: "string" })
|
||||
.alias("u", "url")
|
||||
.argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; v: boolean; loud: boolean; noisy: boolean; verbose: boolean; n: boolean; _: string[]; $0: string; }
|
||||
yargs
|
||||
.option("v", { default: false })
|
||||
.alias("v", ["loud", "noisy", "verbose"])
|
||||
.alias("n", "noisy")
|
||||
.argv;
|
||||
|
||||
// $ExpectType { [x: string]: any; n: number; count: number; num: number; _: string[]; $0: string; }
|
||||
yargs
|
||||
.option("n", { number: true, demandOption: true })
|
||||
.alias("n", "count")
|
||||
.alias("num", ["n", "count"])
|
||||
.argv;
|
||||
}
|
||||
|
||||
function Argv$inferArrayOptionTypes() {
|
||||
// $ExpectType (string | number)[]
|
||||
yargs.option("a", { array: true, demandOption: true }).argv.a;
|
||||
|
||||
// $ExpectType string[]
|
||||
yargs.option("a", { array: true, string: true, demandOption: true }).argv.a;
|
||||
|
||||
// $ExpectType number[]
|
||||
yargs.option("a", { array: true, number: true, demandOption: true }).argv.a;
|
||||
|
||||
// $ExpectType string[]
|
||||
yargs.option("a", { array: true, normalize: true, demandOption: true }).argv.a;
|
||||
|
||||
// $ExpectType string[] | undefined
|
||||
yargs.option("a", { array: true, type: "string" }).argv.a;
|
||||
|
||||
// $ExpectType number[] | undefined
|
||||
yargs.option("a", { array: true, type: "number" }).argv.a;
|
||||
|
||||
// $ExpectType string[] | undefined
|
||||
yargs.option("a", { array: true, normalize: true }).argv.a;
|
||||
|
||||
// $ExpectType string[] | undefined
|
||||
yargs.option("a", { string: true, type: "array" }).argv.a;
|
||||
|
||||
// $ExpectType number[] | undefined
|
||||
yargs.option("a", { number: true, type: "array" }).argv.a;
|
||||
|
||||
// $ExpectType string[] | undefined
|
||||
yargs.option("a", { normalize: true, type: "array" }).argv.a;
|
||||
|
||||
// $ExpectType string[] | undefined
|
||||
yargs.string("a").array("a").argv.a;
|
||||
|
||||
// $ExpectType string[] | undefined
|
||||
yargs.array("a").string("a").argv.a;
|
||||
|
||||
// $ExpectType string[]
|
||||
yargs.string("a").array("a").demandOption("a").argv.a;
|
||||
|
||||
// $ExpectType string[]
|
||||
yargs.array("a").string("a").demandOption("a").argv.a;
|
||||
|
||||
// $ExpectType string[]
|
||||
yargs.string("a").demandOption("a").array("a").argv.a;
|
||||
|
||||
// $ExpectType string[]
|
||||
yargs.array("a").demandOption("a").string("a").argv.a;
|
||||
|
||||
// $ExpectType number[]
|
||||
yargs.number("a").array("a").demandOption("a").argv.a;
|
||||
|
||||
// $ExpectType number[]
|
||||
yargs.array("a").number("a").demandOption("a").argv.a;
|
||||
|
||||
// $ExpectType number[]
|
||||
yargs.array("a").demandOption("a").number("a").argv.a;
|
||||
|
||||
// $ExpectType string[]
|
||||
yargs.normalize("a").array("a").demandOption("a").argv.a;
|
||||
|
||||
// $ExpectType string[]
|
||||
yargs.array("a").normalize("a").demandOption("a").argv.a;
|
||||
|
||||
// $ExpectType string[]
|
||||
yargs.array("a").demandOption("a").normalize("a").argv.a;
|
||||
}
|
||||
|
||||
function Argv$inferRepeatedOptionTypes() {
|
||||
// $ExpectType boolean | undefined
|
||||
yargs.string("a").boolean("a").argv.a;
|
||||
|
||||
// $ExpectType string | undefined
|
||||
yargs.number("a").string("a").argv.a;
|
||||
|
||||
// $ExpectType number | undefined
|
||||
yargs.string("a").number("a").argv.a;
|
||||
|
||||
// $ExpectType boolean | undefined
|
||||
yargs.string("a").option("a", { number: true }).boolean("a").argv.a;
|
||||
|
||||
// $ExpectType boolean | undefined
|
||||
yargs.number("a").option("a", { string: true }).boolean("a").argv.a;
|
||||
|
||||
// $ExpectType string | undefined
|
||||
yargs.boolean("a").option("a", { number: true }).option("a", { string: true }).argv.a;
|
||||
|
||||
// $ExpectType number | undefined
|
||||
yargs.boolean("a").option("a", { string: true }).option("a", { number: true }).argv.a;
|
||||
}
|
||||
|
||||
function Argv$fallbackToAnyForUnknownOptions() {
|
||||
// $ExpectType any
|
||||
yargs.argv.bogus;
|
||||
|
||||
// $ExpectType any
|
||||
yargs
|
||||
.option({a: { type: "string" }, b: { type: "boolean" } })
|
||||
.argv
|
||||
.bogus;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user