diff --git a/types/acorn/index.d.ts b/types/acorn/index.d.ts index 5d02bd716c..e6a9291d1c 100644 --- a/types/acorn/index.d.ts +++ b/types/acorn/index.d.ts @@ -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 {} diff --git a/types/ansi-regex/ansi-regex-tests.ts b/types/ansi-regex/ansi-regex-tests.ts index a5787902f0..d4217e9608 100644 --- a/types/ansi-regex/ansi-regex-tests.ts +++ b/types/ansi-regex/ansi-regex-tests.ts @@ -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'] diff --git a/types/ansi-regex/index.d.ts b/types/ansi-regex/index.d.ts index 34890912dc..52979125f7 100644 --- a/types/ansi-regex/index.d.ts +++ b/types/ansi-regex/index.d.ts @@ -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 +// Florian Keller // 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; diff --git a/types/auth0-js/auth0-js-tests.ts b/types/auth0-js/auth0-js-tests.ts index 6d21de4ed3..6353cc1e40 100644 --- a/types/auth0-js/auth0-js-tests.ts +++ b/types/auth0-js/auth0-js-tests.ts @@ -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', diff --git a/types/auth0-js/index.d.ts b/types/auth0-js/index.d.ts index 7ca266e6ce..a38c928333 100644 --- a/types/auth0-js/index.d.ts +++ b/types/auth0-js/index.d.ts @@ -270,6 +270,13 @@ export class WebAuth { */ passwordlessVerify(options: PasswordlessVerifyOptions, callback: Auth0Callback): void; + /** + * Logs in a user with the verification code sent to the user + * @param options + * @param callback + */ + passwordlessLogin(options: PasswordlessLoginOptions, callback: Auth0Callback): 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; diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts index 566e01c592..92f0a6999b 100644 --- a/types/aws-lambda/aws-lambda-tests.ts +++ b/types/aws-lambda/aws-lambda-tests.ts @@ -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 = { diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index 799f9062fd..4cafe3d2da 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -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 diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index 2d18e0a800..2419afee8f 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -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 */ diff --git a/types/continuation-local-storage/continuation-local-storage-tests.ts b/types/continuation-local-storage/continuation-local-storage-tests.ts index aee44866af..9ab06a89d2 100644 --- a/types/continuation-local-storage/continuation-local-storage-tests.ts +++ b/types/continuation-local-storage/continuation-local-storage-tests.ts @@ -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(); } } diff --git a/types/es-feature-detection/es-feature-detection-tests.ts b/types/es-feature-detection/es-feature-detection-tests.ts index 13b779c1bb..3e769f6636 100644 --- a/types/es-feature-detection/es-feature-detection-tests.ts +++ b/types/es-feature-detection/es-feature-detection-tests.ts @@ -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) { diff --git a/types/ethereumjs-tx/index.d.ts b/types/ethereumjs-tx/index.d.ts index 1d52f5f8a4..a030edee1e 100644 --- a/types/ethereumjs-tx/index.d.ts +++ b/types/ethereumjs-tx/index.d.ts @@ -1,19 +1,37 @@ // Type definitions for ethereumjs-tx 1.0 // Project: https://github.com/ethereumjs/ethereumjs-tx // Definitions by: Leonid Logvinov +// David Mihal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// +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; diff --git a/types/ganache-core/index.d.ts b/types/ganache-core/index.d.ts index 07d0892f24..f96bbf128a 100644 --- a/types/ganache-core/index.d.ts +++ b/types/ganache-core/index.d.ts @@ -16,5 +16,6 @@ export interface GanacheOpts { mnemonic?: string; gasLimit?: number; vmErrorsOnRPCResponse?: boolean; + db_path?: string; } export function provider(opts: GanacheOpts): Provider; diff --git a/types/jpm/jpm-tests.ts b/types/jpm/jpm-tests.ts index 34523f1a14..c6451aea9c 100644 --- a/types/jpm/jpm-tests.ts +++ b/types/jpm/jpm-tests.ts @@ -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; diff --git a/types/js-yaml/index.d.ts b/types/js-yaml/index.d.ts index 20bb5fabc1..49ba2807a7 100644 --- a/types/js-yaml/index.d.ts +++ b/types/js-yaml/index.d.ts @@ -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; diff --git a/types/knockout/index.d.ts b/types/knockout/index.d.ts index e6d180c2c4..047258539a 100644 --- a/types/knockout/index.d.ts +++ b/types/knockout/index.d.ts @@ -48,7 +48,7 @@ interface KnockoutObservableArrayFunctions 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 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 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 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 extends KnockoutSubscribableFunctions { - 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(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; + /** + * 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; + /** + * Creates computed observable + */ (): KnockoutComputed; - (func: () => T, context?: any, options?: any): KnockoutComputed; - (def: KnockoutComputedDefine, context?: any): KnockoutComputed; + /** + * 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 + */ + (evaluatorFunction: () => T, context?: any, options?: any): KnockoutComputed; + /** + * 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 + */ + (options: KnockoutComputedDefine, context?: any): KnockoutComputed; } interface KnockoutReadonlyComputed extends KnockoutReadonlyObservable { @@ -167,11 +213,27 @@ interface KnockoutReadonlyComputed extends KnockoutReadonlyObservable { interface KnockoutComputed extends KnockoutReadonlyComputed, KnockoutObservable, KnockoutComputedFunctions { fn: KnockoutComputedFunctions; - // 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; } @@ -222,6 +284,10 @@ interface KnockoutObservableStatic { interface KnockoutReadonlyObservable extends KnockoutSubscribable, KnockoutObservableFunctions { (): 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 extends KnockoutReadonlyObservable { } interface KnockoutComputedDefine { + /** + * 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(evaluatorFunction: () => T, context?: any): KnockoutComputed; + /** + * 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(options: KnockoutComputedDefine, context?: any): KnockoutComputed; 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; + /** + * Determine if argument is an observable. Returns true for observables, observable arrays, and all computed observables. + * @param instance Object to be checked + */ isObservable(instance: KnockoutObservable | T): instance is KnockoutObservable; - + /** + * 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; + /** + * 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: KnockoutObservable | T): instance is KnockoutObservable; - + /** + * Determine if argument is a computed observable + * @param instance Object to be checked + */ isComputed(instance: any): instance is KnockoutComputed; + /** + * Determine if argument is a computed observable + * @param instance Object to be checked + */ isComputed(instance: KnockoutObservable | T): instance is KnockoutComputed; dataFor(node: any): any; @@ -575,6 +698,9 @@ interface KnockoutStatic { unwrap(value: KnockoutObservable | T): T; unwrap(value: KnockoutObservableArray | 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, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any; - ignoreDependencies(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(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[]; diff --git a/types/meteor/globals/mongo.d.ts b/types/meteor/globals/mongo.d.ts index 108008febe..a62728bea8 100644 --- a/types/meteor/globals/mongo.d.ts +++ b/types/meteor/globals/mongo.d.ts @@ -126,7 +126,7 @@ declare module Mongo { new (name: string, options?: { connection?: Object | null; idGeneration?: string; - transform?: Function; + transform?: Function | null; }): Collection; } interface Collection { @@ -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 | ObjectID | string, options?: { sort?: SortSpecifier; @@ -150,14 +150,14 @@ declare module Mongo { limit?: number; fields?: FieldSpecifier; reactive?: boolean; - transform?: Function; + transform?: Function | null; }): Cursor; findOne(selector?: Selector | 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; } } diff --git a/types/meteor/index.d.ts b/types/meteor/index.d.ts index dfa14ebc59..5bfc2c9469 100644 --- a/types/meteor/index.d.ts +++ b/types/meteor/index.d.ts @@ -9,6 +9,7 @@ // Stefan Holzapfel // Andrey Markeev // Leon Machens +// Arthur Gunn // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 diff --git a/types/meteor/mongo.d.ts b/types/meteor/mongo.d.ts index ced791205b..84b2d53528 100644 --- a/types/meteor/mongo.d.ts +++ b/types/meteor/mongo.d.ts @@ -127,7 +127,7 @@ declare module "meteor/mongo" { new (name: string, options?: { connection?: Object | null; idGeneration?: string; - transform?: Function; + transform?: Function | null; }): Collection; } interface Collection { @@ -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 | 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; findOne(selector?: Selector | 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; } } } diff --git a/types/meteor/test/globals/meteor-tests.ts b/types/meteor/test/globals/meteor-tests.ts index e3a3e750bb..eb512f0633 100644 --- a/types/meteor/test/globals/meteor-tests.ts +++ b/types/meteor/test/globals/meteor-tests.ts @@ -201,7 +201,7 @@ Posts.insert({ title: "Hello world", body: "First post" }); **/ class Animal { - constructor(doc: any) {} + constructor(public doc: any) {} } interface AnimalDAO { diff --git a/types/meteor/test/meteor-tests.ts b/types/meteor/test/meteor-tests.ts index 63f83ef79d..8e14f39fb1 100644 --- a/types/meteor/test/meteor-tests.ts +++ b/types/meteor/test/meteor-tests.ts @@ -213,7 +213,7 @@ Posts.insert({ title: "Hello world", body: "First post" }); **/ class Animal { - constructor(doc: any) {} + constructor(public doc: any) {} } interface AnimalDAO { diff --git a/types/mysql/mysql-tests.ts b/types/mysql/mysql-tests.ts index d8abfe1dcd..c9853bf116 100644 --- a/types/mysql/mysql-tests.ts +++ b/types/mysql/mysql-tests.ts @@ -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"}); diff --git a/types/openpgp/index.d.ts b/types/openpgp/index.d.ts index abd59350b8..edbe0eb77c 100644 --- a/types/openpgp/index.d.ts +++ b/types/openpgp/index.d.ts @@ -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): Array, + + 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; } export namespace packet { diff --git a/types/openpgp/openpgp-tests.ts b/types/openpgp/openpgp-tests.ts index aeabfd2768..30f9adbc8b 100644 --- a/types/openpgp/openpgp-tests.ts +++ b/types/openpgp/openpgp-tests.ts @@ -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 diff --git a/types/openpgp/ts3.2/index.d.ts b/types/openpgp/ts3.2/index.d.ts index 7e5a2ea34d..0bf040bc17 100644 --- a/types/openpgp/ts3.2/index.d.ts +++ b/types/openpgp/ts3.2/index.d.ts @@ -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): Array, + + 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; } export namespace packet { diff --git a/types/openpgp/ts3.2/openpgp-tests.ts b/types/openpgp/ts3.2/openpgp-tests.ts index aeabfd2768..30f9adbc8b 100644 --- a/types/openpgp/ts3.2/openpgp-tests.ts +++ b/types/openpgp/ts3.2/openpgp-tests.ts @@ -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 diff --git a/types/react-beautiful-dnd/index.d.ts b/types/react-beautiful-dnd/index.d.ts index 40a2fb9e73..dfe6f21229 100644 --- a/types/react-beautiful-dnd/index.d.ts +++ b/types/react-beautiful-dnd/index.d.ts @@ -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 // Bradley Ayers // Austin Turner // Mark Nelissen +// Enrico Boccadifuoco // 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 {} +export class DragDropContext extends React.Component { } /** * 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; } -export class Droppable extends React.Component {} +export class Droppable extends React.Component { } /** * 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 {} +export class Draggable extends React.Component { } diff --git a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx index bfa5d8b8f5..93b7903818 100644 --- a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx +++ b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx @@ -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 ( - + {(provided, snapshot) => (
{this.state.items.map((item, index) => ( diff --git a/types/react-data-grid/react-data-grid-tests.tsx b/types/react-data-grid/react-data-grid-tests.tsx index 201e53a3ca..dc23d2a996 100644 --- a/types/react-data-grid/react-data-grid-tests.tsx +++ b/types/react-data-grid/react-data-grid-tests.tsx @@ -252,11 +252,11 @@ class Example extends React.Component { getColumns() { var clonedColumns = columns.slice(); clonedColumns[2].events = { - onClick: function (ev:React.SyntheticEvent, args:{idx:number, rowIdx:number}) { + onClick: (ev:React.SyntheticEvent, 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; diff --git a/types/react-data-grid/v1/react-data-grid-tests.tsx b/types/react-data-grid/v1/react-data-grid-tests.tsx index 371831b43a..5b23c55898 100644 --- a/types/react-data-grid/v1/react-data-grid-tests.tsx +++ b/types/react-data-grid/v1/react-data-grid-tests.tsx @@ -198,11 +198,11 @@ class Example extends React.Component { getColumns() { var clonedColumns = columns.slice(); clonedColumns[2].events = { - onClick: function (ev:React.SyntheticEvent, args:{idx:number, rowIdx:number}) { + onClick: (ev:React.SyntheticEvent, 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; diff --git a/types/react-data-grid/v2/react-data-grid-tests.tsx b/types/react-data-grid/v2/react-data-grid-tests.tsx index aa09041846..c1c39aee05 100644 --- a/types/react-data-grid/v2/react-data-grid-tests.tsx +++ b/types/react-data-grid/v2/react-data-grid-tests.tsx @@ -252,11 +252,11 @@ class Example extends React.Component { getColumns() { var clonedColumns = columns.slice(); clonedColumns[2].events = { - onClick: function (ev:React.SyntheticEvent, args:{idx:number, rowIdx:number}) { + onClick: (ev:React.SyntheticEvent, 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; diff --git a/types/react-native-doc-viewer/react-native-doc-viewer-tests.tsx b/types/react-native-doc-viewer/react-native-doc-viewer-tests.tsx index cdc7e3980e..466900ec6e 100644 --- a/types/react-native-doc-viewer/react-native-doc-viewer-tests.tsx +++ b/types/react-native-doc-viewer/react-native-doc-viewer-tests.tsx @@ -102,17 +102,17 @@ export default class DocViewerExample extends React.Component { Doc Viewer React Native