diff --git a/types/d3-drag/d3-drag-tests.ts b/types/d3-drag/d3-drag-tests.ts index 4283cb259f..581b757717 100644 --- a/types/d3-drag/d3-drag-tests.ts +++ b/types/d3-drag/d3-drag-tests.ts @@ -88,6 +88,12 @@ circleDrag = circleDrag containerAccessor = circleDrag.container(); +// clickDistance(...) --------------------------------------------------------- + +circleDrag = circleDrag.clickDistance(5); + +const distance: number = circleDrag.clickDistance(); + // set and get filter --------------------------------------------------------- let filterFn: (this: SVGCircleElement, datum: CircleDatum, index: number, group: SVGCircleElement[] | NodeListOf) => boolean; diff --git a/types/d3-drag/index.d.ts b/types/d3-drag/index.d.ts index d3a65fb377..7105bd4e4d 100644 --- a/types/d3-drag/index.d.ts +++ b/types/d3-drag/index.d.ts @@ -1,9 +1,9 @@ -// Type definitions for D3JS d3-drag module 1.0 +// Type definitions for D3JS d3-drag module 1.1 // Project: https://github.com/d3/d3-drag/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Last module patch version validated against: 1.0.2 +// Last module patch version validated against: 1.1.0 import { ArrayLike, Selection, ValueFn } from 'd3-selection'; @@ -164,6 +164,20 @@ export interface DragBehavior): this; + /** + * Return the current click distance threshold, which defaults to zero. + */ + clickDistance(): number; + /** + * Set the maximum distance that the mouse can move between mousedown and mouseup that will trigger + * a subsequent click event. If at any point between mousedown and mouseup the mouse is greater than or equal to + * distance from its position on mousedown, the click event follwing mouseup will be suppressed. + * + * @param distance The distance threshold between mousedown and mouseup measured in client coordinates (event.clientX and event.clientY). + * The default is zero. + */ + clickDistance(distance: number): this; + /** * Return the first currently-assigned listener matching the specified typenames, if any. * diff --git a/types/d3-random/d3-random-tests.ts b/types/d3-random/d3-random-tests.ts index 8cd72d9f0e..7385d3e984 100644 --- a/types/d3-random/d3-random-tests.ts +++ b/types/d3-random/d3-random-tests.ts @@ -7,7 +7,7 @@ */ import * as d3Random from 'd3-random'; - +import * as seedrandom from 'seedrandom'; // ------------------------------------------------------------ // Preparatory Steps @@ -19,40 +19,70 @@ let randomNumberGenerator: () => number; // randomUniform // ------------------------------------------------------------ -randomNumberGenerator = d3Random.randomUniform(); -randomNumberGenerator = d3Random.randomUniform(0.2); -randomNumberGenerator = d3Random.randomUniform(0.2, 5); +let prngUniform: d3Random.RandomUniform; + +prngUniform = d3Random.randomUniform; +prngUniform = d3Random.randomUniform.source(seedrandom("Schroedinger's flea.")); + +randomNumberGenerator = prngUniform(); +randomNumberGenerator = prngUniform(0.2); +randomNumberGenerator = prngUniform(0.2, 5); // ------------------------------------------------------------ // randomNormal // ------------------------------------------------------------ -randomNumberGenerator = d3Random.randomNormal(); -randomNumberGenerator = d3Random.randomNormal(3); -randomNumberGenerator = d3Random.randomNormal(3, 4); +let prngNormal: d3Random.RandomNormal; + +prngNormal = d3Random.randomNormal; +prngNormal = d3Random.randomNormal.source(seedrandom("Schroedinger's flea.")); + +randomNumberGenerator = prngNormal(); +randomNumberGenerator = prngNormal(3); +randomNumberGenerator = prngNormal(3, 4); // ------------------------------------------------------------ // randomLogNormal // ------------------------------------------------------------ -randomNumberGenerator = d3Random.randomLogNormal(); -randomNumberGenerator = d3Random.randomLogNormal(3); -randomNumberGenerator = d3Random.randomLogNormal(3, 4); +let prngLogNormal: d3Random.RandomLogNormal; + +prngLogNormal = d3Random.randomLogNormal; +prngLogNormal = d3Random.randomLogNormal.source(seedrandom("Schroedinger's flea.")); + +randomNumberGenerator = prngLogNormal(); +randomNumberGenerator = prngLogNormal(3); +randomNumberGenerator = prngLogNormal(3, 4); // ------------------------------------------------------------ // randomBates // ------------------------------------------------------------ -randomNumberGenerator = d3Random.randomBates(3); +let prngBates: d3Random.RandomBates; + +prngBates = d3Random.randomBates; +prngBates = d3Random.randomBates.source(seedrandom("Schroedinger's flea.")); + +randomNumberGenerator = prngBates(3); // ------------------------------------------------------------ // randomIrwinHall // ------------------------------------------------------------ -randomNumberGenerator = d3Random.randomIrwinHall(3); +let prngIrwinHall: d3Random.RandomIrwinHall; + +prngIrwinHall = d3Random.randomIrwinHall; +prngIrwinHall = d3Random.randomIrwinHall.source(seedrandom("Schroedinger's flea.")); + +randomNumberGenerator = prngIrwinHall(3); // ------------------------------------------------------------ // randomExponential // ------------------------------------------------------------ -randomNumberGenerator = d3Random.randomExponential(1 / 40); +let prngExponential: d3Random.RandomExponential; + +prngExponential = d3Random.randomExponential; +prngExponential = d3Random.randomExponential.source(seedrandom("Schroedinger's flea.")); + +randomNumberGenerator = prngExponential(1 / 40); diff --git a/types/d3-random/index.d.ts b/types/d3-random/index.d.ts index 48c9b245ed..41b6034215 100644 --- a/types/d3-random/index.d.ts +++ b/types/d3-random/index.d.ts @@ -1,55 +1,112 @@ -// Type definitions for D3JS d3-random module v1.0.1 +// Type definitions for D3JS d3-random module 1.1 // Project: https://github.com/d3/d3-random/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/** - * Returns a function for generating random numbers with a uniform distribution). - * The minimum allowed value of a returned number is min, and the maximum is max. - * If min is not specified, it defaults to 0; if max is not specified, it defaults to 1. - * - * @param min The minimum allowed value of a returned number, defaults to 0. - * @param max The maximum allowed value of a returned number, defaults to 1. - */ -export function randomUniform(min?: number, max?: number): () => number; +// Last module patch version validated against: 1.1.0 + +export interface RandomNumberGenerationSource { + /** + * Returns the same type of function for generating random numbers but where the given random number + * generator source is used as the source of randomness instead of Math.random. + * This is useful when a seeded random number generator is preferable to Math.random. + * + * @param source Source (pseudo-)random number generator implementing the Math.random interface. + * The given random number generator must implement the same interface as Math.random and + * only return values in the range [0, 1). + */ + source(source: () => number): this; +} /** - * Returns a function for generating random numbers with a normal (Gaussian) distribution. - * The expected value of the generated numbers is mu, with the given standard deviation sigma. - * If mu is not specified, it defaults to 0; if sigma is not specified, it defaults to 1. - * - * @param mu Expected value, defaults to 0. - * @param sigma Standard deviation, defaults to 1. + * A configurable random number generator for the uniform distribution. */ -export function randomNormal(mu?: number, sigma?: number): () => number; +export interface RandomUniform extends RandomNumberGenerationSource { + /** + * Returns a function for generating random numbers with a uniform distribution). + * The minimum allowed value of a returned number is min, and the maximum is max. + * If min is not specified, it defaults to 0; if max is not specified, it defaults to 1. + * + * @param min The minimum allowed value of a returned number, defaults to 0. + * @param max The maximum allowed value of a returned number, defaults to 1. + */ + (min?: number, max?: number): () => number; +} + +export const randomUniform: RandomUniform; /** - * Returns a function for generating random numbers with a log-normal distribution. The expected value of the random variable’s natural logrithm is mu, - * with the given standard deviation sigma. If mu is not specified, it defaults to 0; if sigma is not specified, it defaults to 1. - * - * @param mu Expected value, defaults to 0. - * @param sigma Standard deviation, defaults to 1. + * A configurable random number generator for the normal (Gaussian) distribution. */ -export function randomLogNormal(mu?: number, sigma?: number): () => number; +export interface RandomNormal extends RandomNumberGenerationSource { + /** + * Returns a function for generating random numbers with a normal (Gaussian) distribution. + * The expected value of the generated numbers is mu, with the given standard deviation sigma. + * If mu is not specified, it defaults to 0; if sigma is not specified, it defaults to 1. + * + * @param mu Expected value, defaults to 0. + * @param sigma Standard deviation, defaults to 1. + */ + (mu?: number, sigma?: number): () => number; +} + +export const randomNormal: RandomNormal; /** - * Returns a function for generating random numbers with a Bates distribution with n independent variables. - * - * @param n Number of independent random variables to use. + * A configurable random number generator for the log-normal distribution. */ -export function randomBates(n: number): () => number; +export interface RandomLogNormal extends RandomNumberGenerationSource { + /** + * Returns a function for generating random numbers with a log-normal distribution. The expected value of the random variable’s natural logrithm is mu, + * with the given standard deviation sigma. If mu is not specified, it defaults to 0; if sigma is not specified, it defaults to 1. + * + * @param mu Expected value, defaults to 0. + * @param sigma Standard deviation, defaults to 1. + */ + (mu?: number, sigma?: number): () => number; +} + +export const randomLogNormal: RandomLogNormal; /** - * Returns a function for generating random numbers with an Irwin–Hall distribution with n independent variables. - * - * @param n Number of independent random variables to use. + * A configurable random number generator for the Bates distribution. */ -export function randomIrwinHall(n: number): () => number; +export interface RandomBates extends RandomNumberGenerationSource { + /** + * Returns a function for generating random numbers with a Bates distribution with n independent variables. + * + * @param n Number of independent random variables to use. + */ + (n: number): () => number; +} + +export const randomBates: RandomBates; /** - * Returns a function for generating random numbers with an exponential distribution with the rate lambda; - * equivalent to time between events in a Poisson process with a mean of 1 / lambda. - * - * @param lambda Expected time between events. + * A configurable random number generator for the Irwin–Hall distribution. */ -export function randomExponential(lambda: number): () => number; +export interface RandomIrwinHall extends RandomNumberGenerationSource { + /** + * Returns a function for generating random numbers with an Irwin–Hall distribution with n independent variables. + * + * @param n Number of independent random variables to use. + */ + (n: number): () => number; +} + +export const randomIrwinHall: RandomIrwinHall; + +/** + * A configurable random number generator for the exponential distribution. + */ +export interface RandomExponential extends RandomNumberGenerationSource { + /** + * Returns a function for generating random numbers with an exponential distribution with the rate lambda; + * equivalent to time between events in a Poisson process with a mean of 1 / lambda. + * + * @param lambda Expected time between events. + */ + (lambda: number): () => number; +} + +export const randomExponential: RandomExponential; diff --git a/types/d3-random/tsconfig.json b/types/d3-random/tsconfig.json index 20a20f04f1..f9544a0527 100644 --- a/types/d3-random/tsconfig.json +++ b/types/d3-random/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "d3-random-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/d3-random/tslint.json b/types/d3-random/tslint.json new file mode 100644 index 0000000000..4ae99abce4 --- /dev/null +++ b/types/d3-random/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "max-line-length": [false, 140] + } +} diff --git a/types/d3-zoom/d3-zoom-tests.ts b/types/d3-zoom/d3-zoom-tests.ts index b583bfc8b6..09974bf299 100644 --- a/types/d3-zoom/d3-zoom-tests.ts +++ b/types/d3-zoom/d3-zoom-tests.ts @@ -165,6 +165,12 @@ svgZoom = svgZoom.translateExtent([[-500, -500], [500, 500]]); let translateExtent: [[number, number], [number, number]]; translateExtent = svgZoom.translateExtent(); +// clickDistance() --------------------------------------------------------- + +svgZoom = svgZoom.clickDistance(5); + +const distance: number = svgZoom.clickDistance(); + // duration() -------------------------------------------------------------- // chainable diff --git a/types/d3-zoom/index.d.ts b/types/d3-zoom/index.d.ts index 62c49b977b..88a9a7b95f 100644 --- a/types/d3-zoom/index.d.ts +++ b/types/d3-zoom/index.d.ts @@ -1,9 +1,9 @@ -// Type definitions for d3JS d3-zoom module 1.1 +// Type definitions for d3JS d3-zoom module 1.2 // Project: https://github.com/d3/d3-zoom/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Last module patch version validated against: 1.1.1 +// Last module patch version validated against: 1.2.0 import { ArrayLike, Selection, TransitionLike, ValueFn } from 'd3-selection'; import { ZoomView, ZoomInterpolator } from 'd3-interpolate'; @@ -461,6 +461,20 @@ export interface ZoomBehavior +// bttf // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -1571,6 +1572,34 @@ declare namespace Ember { @return {Promise} */ finally(callback: (a: T) => V, label?: string): Promise; + + static all(promises: GlobalArray<(Q | Thenable)>): Promise; + static race(promises: GlobalArray>): Promise; + + /** + @method resolve + @param {Any} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` + */ + static resolve(object?: Q | Thenable): Promise; + + /** + @method cast (Deprecated in favor of resolve + @param {Any} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` + */ + static cast(object: Q | Thenable, label?: string): Promise; + + /** + `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. + */ + static reject(reason?: any): Promise; } function all(promises: GlobalArray>): Promise; diff --git a/types/graphql/type/schema.d.ts b/types/graphql/type/schema.d.ts index 5a2cdd0af4..0f02cd78af 100644 --- a/types/graphql/type/schema.d.ts +++ b/types/graphql/type/schema.d.ts @@ -51,7 +51,7 @@ export class GraphQLSchema { getQueryType(): GraphQLObjectType; getMutationType(): GraphQLObjectType; getSubscriptionType(): GraphQLObjectType; - getTypeMap(): GraphQLNamedType; + getTypeMap(): { [typeName: string]: GraphQLNamedType }; getType(name: string): GraphQLType; getPossibleTypes(abstractType: GraphQLAbstractType): Array; diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index cb20b294d2..5a2a0abfe1 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -1065,7 +1065,7 @@ declare module "mongoose" { * @param pathsToValidate only validate the given paths * @returns MongooseError if there are errors during validation, or undefined if there is no error. */ - validateSync(pathsToValidate: string | string[]): Error; + validateSync(pathsToValidate?: string | string[]): Error; /** Hash containing current validation errors. */ errors: Object; diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 8d32f09744..c74f8dcb0b 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -1265,22 +1265,94 @@ declare module "dns" { family: number; } - export function lookup(domain: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function lookup(domain: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function lookup(domain: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void; - export function lookup(domain: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void; - export function lookup(domain: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void; + export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void; + export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; + export interface MxRecord { + priority: number; + exchange: string; + } + + export interface NaptrRecord { + flags: string; + service: string; + regexp: string; + replacement: string; + order: number; + preference: number; + } + + export interface SoaRecord { + nsname: string; + hostmaster: string; + serial: number; + refresh: number; + retry: number; + expire: number; + minttl: number; + } + + export interface SrvRecord { + priority: number; + weight: number; + port: number; + name: string; + } + + export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException, addresses: SoaRecord) => void): void; + export function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void; + export function resolve(hostname: string, rrtype: string, callback: (err: NodeJS.ErrnoException, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][]) => void): void; + + export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void; + export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void; + export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException, address: SoaRecord) => void): void; + export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void; + export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void; + + export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; + export function setServers(servers: string[]): void; + + //Error codes + export var NODATA: string; + export var FORMERR: string; + export var SERVFAIL: string; + export var NOTFOUND: string; + export var NOTIMP: string; + export var REFUSED: string; + export var BADQUERY: string; + export var BADNAME: string; + export var BADFAMILY: string; + export var BADRESP: string; + export var CONNREFUSED: string; + export var TIMEOUT: string; + export var EOF: string; + export var FILE: string; + export var NOMEM: string; + export var DESTRUCTION: string; + export var BADSTR: string; + export var BADFLAGS: string; + export var NONAME: string; + export var BADHINTS: string; + export var NOTINITIALIZED: string; + export var LOADIPHLPAPI: string; + export var ADDRGETNETWORKPARAMS: string; + export var CANCELLED: string; } declare module "net" { diff --git a/types/node/v4/node-tests.ts b/types/node/v4/node-tests.ts index 43ce0f9f42..5274116452 100644 --- a/types/node/v4/node-tests.ts +++ b/types/node/v4/node-tests.ts @@ -1021,4 +1021,25 @@ namespace dns_tests { const _addresses: string | dns.LookupAddress[] = addresses; const _family: number | undefined = family; }); + + dns.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "A", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "AAAA", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "MX", (err, addresses) => { + const _addresses: dns.MxRecord[] = addresses; + }); + + dns.resolve4("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + + dns.resolve6("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); } diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 664a037dd9..ebc2b516d6 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -1807,11 +1807,6 @@ declare module "url" { } declare module "dns" { - export interface MxRecord { - exchange: string, - priority: number - } - // Supported getaddrinfo flags. export const ADDRCONFIG: number; export const V4MAPPED: number; @@ -1835,22 +1830,68 @@ declare module "dns" { family: number; } - export function lookup(domain: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function lookup(domain: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function lookup(domain: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void; - export function lookup(domain: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void; - export function lookup(domain: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void; + export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void; + export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) => void): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[]; + export interface MxRecord { + priority: number; + exchange: string; + } + + export interface NaptrRecord { + flags: string; + service: string; + regexp: string; + replacement: string; + order: number; + preference: number; + } + + export interface SoaRecord { + nsname: string; + hostmaster: string; + serial: number; + refresh: number; + retry: number; + expire: number; + minttl: number; + } + + export interface SrvRecord { + priority: number; + weight: number; + port: number; + name: string; + } + + export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException, addresses: SoaRecord) => void): void; + export function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void; + export function resolve(hostname: string, rrtype: string, callback: (err: NodeJS.ErrnoException, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][]) => void): void; + + export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void; + export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void; + export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException, address: SoaRecord) => void): void; + export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void; + export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void; + + export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; export function setServers(servers: string[]): void; //Error codes diff --git a/types/node/v6/node-tests.ts b/types/node/v6/node-tests.ts index 4792c5edf1..b2ca08898c 100644 --- a/types/node/v6/node-tests.ts +++ b/types/node/v6/node-tests.ts @@ -2091,6 +2091,27 @@ namespace dns_tests { const _addresses: string | dns.LookupAddress[] = addresses; const _family: number | undefined = family; }); + + dns.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "A", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "AAAA", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "MX", (err, addresses) => { + const _addresses: dns.MxRecord[] = addresses; + }); + + dns.resolve4("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + + dns.resolve6("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); } /***************************************************************************** diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index e6f947b677..520928823e 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -2412,7 +2412,6 @@ declare module OfficeExtension { constructor(context: ClientRequestContext, parentObject: ClientObject, name: string, eventInfo: EventInfo); add(handler: (args: T) => IPromise): EventHandlerResult; remove(handler: (args: T) => IPromise): void; - removeAll(): void; } export class EventHandlerResult { diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 20ad9529a9..7fde62feee 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -1808,3 +1808,4 @@ declare namespace R { } export = R; +export as namespace R; diff --git a/types/react-monaco-editor/index.d.ts b/types/react-monaco-editor/index.d.ts new file mode 100644 index 0000000000..7f4a4a543e --- /dev/null +++ b/types/react-monaco-editor/index.d.ts @@ -0,0 +1,78 @@ +// Type definitions for react-monaco-editor 0.8 +// Project: https://github.com/superRaytin/react-monaco-editor +// Definitions by: Joshua Netterfield +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +import * as React from "react"; + +export interface ReactMonacoEditorProps { + /** + * Width of editor. Defaults to 100%. + */ + width?: string | number; + + /** + * Height of editor. Defaults to 500. + */ + height?: string | number; + + /** + * Value of the auto created model in the editor. + * If you specify value property, the component behaves in controlled mode. Otherwise, it behaves in uncontrolled mode. + */ + value?: string; + + /** + * The initial value of the auto created model in the editor. + */ + defaultValue?: string; + + /** + * The initial language of the auto created model in the editor. + */ + language?: string; + + /** + * Theme to be used for rendering. + * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'. + * You can create custom themes via `monaco.editor.defineTheme`. + */ + theme?: string; + + /** + * Refer to Monaco interface IEditorOptions. + */ + options?: monaco.editor.IEditorOptions; + + /** + * An event emitted when the editor has been mounted (similar to componentDidMount of React). + */ + editorDidMount?(editor: monaco.editor.ICodeEditor, monacoModule: typeof monaco): void; + + /** + * An event emitted before the editor mounted (similar to componentWillMount of React). + */ + editorWillMount?(monacoModule: typeof monaco): void; + + /** + * An event emitted when the content of the current model has changed. + */ + onChange?(val: string, ev: monaco.editor.IModelContentChangedEvent2): void; + + /** + * Optional, allow to config loader url and relative path of module, refer to require.config. + */ + requireConfig?: object; + + /** + * Optional, allow to pass a different context then the global window onto which the monaco instance will be loaded. Useful if you want to load the editor in an iframe. + */ + context?: object; +} + +export default class ReactMonacoEditor extends React.Component { + editor: monaco.editor.ICodeEditor; +} diff --git a/types/react-monaco-editor/package.json b/types/react-monaco-editor/package.json new file mode 100644 index 0000000000..03bb1bd23d --- /dev/null +++ b/types/react-monaco-editor/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "monaco-editor": "0.8.3" + } +} diff --git a/types/react-monaco-editor/react-monaco-editor-tests.tsx b/types/react-monaco-editor/react-monaco-editor-tests.tsx new file mode 100644 index 0000000000..d8e8642bf9 --- /dev/null +++ b/types/react-monaco-editor/react-monaco-editor-tests.tsx @@ -0,0 +1,149 @@ +// Adapted from https://github.com/superRaytin/react-monaco-editor/blob/master/examples/index.js + +import * as React from 'react'; +import { render } from 'react-dom'; +import MonacoEditor from 'react-monaco-editor'; + +interface CodeEditorState { + code?: string; +} + +// Using with webpack +class CodeEditor extends React.Component { + constructor(props: object) { + super(props); + this.state = { + code: '// type your code... \n', + }; + } + editor: monaco.editor.ICodeEditor; + editorDidMount = (editor: monaco.editor.ICodeEditor) => { + console.log('editorDidMount', editor, editor.getValue(), editor.getModel()); + this.editor = editor; + } + onChange = (newValue: string, e: monaco.editor.IModelContentChangedEvent2) => { + console.log('onChange', newValue, e); + this.setState({ + code: newValue, + }); + } + changeEditorValue = () => { + if (this.editor) { + this.editor.setValue('// code changed! \n'); + } + } + changeBySetState = () => { + this.setState({code: '// code changed by setState! \n'}); + } + render() { + const code = this.state.code; + const options = { + selectOnLineNumbers: true, + roundedSelection: false, + readOnly: false, + theme: 'vs', + cursorStyle: 'line', + automaticLayout: false, + }; + return ( +
+
+ + +
+
+ +
+ ); + } +} + +// Using with require.config +class AnotherEditor extends React.Component { + constructor(props: object) { + super(props); + const jsonCode = [ + '{', + ' "$schema": "http://myserver/foo-schema.json"', + "}" + ].join('\n'); + this.state = { + code: jsonCode, + }; + } + editorWillMount = (monacoModule: typeof monaco) => { + monacoModule.languages.json.jsonDefaults.setDiagnosticsOptions({ + schemas: [{ + uri: "http://myserver/foo-schema.json", + schema: { + type: "object", + properties: { + p1: { + enum: [ "v1", "v2"] + }, + p2: { + $ref: "http://myserver/bar-schema.json" + } + } + } + }, { + uri: "http://myserver/bar-schema.json", + schema: { + type: "object", + properties: { + q1: { + enum: [ "x1", "x2"] + } + } + } + }] + }); + } + render() { + const code = this.state.code; + const requireConfig = { + url: 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.1/require.min.js', + paths: { + vs: 'https://as.alipayobjects.com/g/cicada/monaco-editor-mirror/0.6.1/min/vs' + } + }; + return ( +
+ +
+ ); + } +} + +class App extends React.Component { + render() { + return ( +
+

Monaco Editor Sample (controlled mode)

+ +
+

Another editor (uncontrolled mode)

+ +
+ ); + } +} + +render( + , + document.getElementById('root') +); diff --git a/types/react-monaco-editor/tsconfig.json b/types/react-monaco-editor/tsconfig.json new file mode 100644 index 0000000000..0b3178ab81 --- /dev/null +++ b/types/react-monaco-editor/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-monaco-editor-tests.tsx" + ] +} diff --git a/types/react-monaco-editor/tslint.json b/types/react-monaco-editor/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-monaco-editor/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 7a02b28e6b..dcaeb52da8 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-native 0.43 +// Type definitions for react-native 0.44 // Project: https://github.com/facebook/react-native // Definitions by: Eloy Durán , Fedor Nezhivoi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -3123,9 +3123,9 @@ export interface ImageStyle extends FlexStyle, TransformsStyle, ShadowStyleIOS { } /* - * @see https://github.com/facebook/react-native/blob/master/Libraries/Image/ImageSourcePropType.js - */ -interface ImageURISource { + * @see https://github.com/facebook/react-native/blob/master/Libraries/Image/ImageSourcePropType.js + */ +export interface ImageURISource { /** * `uri` is a string representing the resource identifier for the image, which * could be an http address, a local file path, or the name of a static image @@ -5097,6 +5097,11 @@ export interface TabBarItemProperties extends ViewProperties { */ badge?: string | number + /** + * Background color for the badge. Available since iOS 10. + */ + badgeColor?: string + /** * A custom icon for the tab. It is ignored when a system icon is defined. */ @@ -5182,6 +5187,11 @@ export interface TabBarIOSProperties extends ViewProperties { * Color of text on unselected tabs */ unselectedTintColor?: string + + /** + * Color of unselected tab icons. Available since iOS 10. + */ + unselectedItemTintColor?: string } export interface TabBarIOSStatic extends React.ComponentClass { @@ -5783,7 +5793,7 @@ export interface ScrollViewPropertiesIOS { * This can be used for paginating through children that have lengths smaller than the scroll view. * Used in combination with snapToAlignment. */ - snapToInterval?: number[] + snapToInterval?: number /** * An array of child indices determining which children get docked to the diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 62e925575b..3d7ddeac07 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -34,6 +34,7 @@ import { ScrollView, ScrollViewProps, RefreshControl, + TabBarIOS, } from 'react-native'; function testDimensions() { @@ -255,3 +256,30 @@ class ScrollerListComponentTest extends React.Component<{}, { dataSource: ListVi ) } } + + +class TabBarTest extends React.Component<{}, {}> { + render() { + return ( + + {}} + renderAsOriginal={ true } + selectedIcon={ undefined } + systemIcon="history" + title="Item 1"> + + + ); + } +} diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 43fe16f484..d5bc7240c7 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -70,12 +70,12 @@ export interface RouteProps { exact?: boolean; strict?: boolean; } -export class Route extends React.Component { } +export class Route extends React.Component { } export interface RouterProps { history: any; } -export class Router extends React.Component { } +export class Router extends React.Component { } export interface StaticRouterProps { basename?: string; @@ -83,12 +83,12 @@ export interface StaticRouterProps { context?: object; } -export class StaticRouter extends React.Component { } +export class StaticRouter extends React.Component { } export interface SwitchProps { children?: React.ReactNode; location?: H.Location; } -export class Switch extends React.Component { } +export class Switch extends React.Component { } export interface match

{ params: P; diff --git a/types/sequelize/v3/index.d.ts b/types/sequelize/v3/index.d.ts index a02ba7d0ed..2f2f973c19 100644 --- a/types/sequelize/v3/index.d.ts +++ b/types/sequelize/v3/index.d.ts @@ -4757,6 +4757,11 @@ declare namespace sequelize { */ fields?: Array; + /** + * Condition for partioal index + */ + where?: WhereOptions; + } /** diff --git a/types/sequelize/v3/sequelize-tests.ts b/types/sequelize/v3/sequelize-tests.ts index 3e972d3119..9f5eac61ad 100644 --- a/types/sequelize/v3/sequelize-tests.ts +++ b/types/sequelize/v3/sequelize-tests.ts @@ -1261,7 +1261,7 @@ s.define( 'UserWithUniqueUsername', { username : { type : Sequelize.STRING, unique : { name : 'user_and_email', msg : 'User and email must be unique' } }, email : { type : Sequelize.STRING, unique : 'user_and_email' } } ); -/* NOTE https://github.com/DefinitelyTyped/DefinitelyTyped/pull/5590 + s.define( 'UserWithUniqueUsername', { user_id : { type : Sequelize.INTEGER }, email : { type : Sequelize.STRING } @@ -1269,13 +1269,15 @@ s.define( 'UserWithUniqueUsername', { indexes : [ { name : 'user_and_email_index', - msg : 'User and email must be unique', unique : true, method : 'BTREE', - fields : ['user_id', { attribute : 'email', collate : 'en_US', order : 'DESC', length : 5 }] + fields : ['user_id', { attribute : 'email', collate : 'en_US', order : 'DESC', length : 5 }], + where : { + user_id : { $not: null } + } }] } ); - */ + s.define( 'TaskBuild', { title : { type : Sequelize.STRING, defaultValue : 'a task!' }, foo : { type : Sequelize.INTEGER, defaultValue : 2 }, diff --git a/types/xmlbuilder/index.d.ts b/types/xmlbuilder/index.d.ts index 20dabf97ca..d7ffd2193c 100644 --- a/types/xmlbuilder/index.d.ts +++ b/types/xmlbuilder/index.d.ts @@ -85,5 +85,5 @@ declare class XMLElementOrXMLNode { } declare namespace xmlbuilder { - function create(name: string, xmldec?: Object, doctype?: any, options?: Object): XMLElementOrXMLNode; + function create(nameOrObjSpec: string | { [name:string]: Object }, xmldec?: Object, doctype?: any, options?: Object): XMLElementOrXMLNode; } diff --git a/types/xmlbuilder/xmlbuilder-tests.ts b/types/xmlbuilder/xmlbuilder-tests.ts index 69794640ba..8be8f780f9 100644 --- a/types/xmlbuilder/xmlbuilder-tests.ts +++ b/types/xmlbuilder/xmlbuilder-tests.ts @@ -41,3 +41,10 @@ xml('root') .up() .ele('atttest', 'text') .end(); + +xml({ + displayNotification: { + level: 'error', + message: 'an error occurred' + } +}); \ No newline at end of file diff --git a/types/xrm/index.d.ts b/types/xrm/index.d.ts index 956dc969a2..6e6a1d5117 100644 --- a/types/xrm/index.d.ts +++ b/types/xrm/index.d.ts @@ -1,9 +1,9 @@ // Type definitions for Microsoft Dynamics xRM API 8.2 // Project: http://www.microsoft.com/en-us/download/details.aspx?id=44567 -// Definitions by: David Berry -// Matt Ngan -// Markus Mauch -// Daryl LaBar +// Definitions by: David Berry , +// Matt Ngan , +// Markus Mauch , +// Daryl LaBar , // Tully H // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -24,198 +24,12 @@ declare namespace Xrm { /** * Provides a namespace container for the context, data and ui objects. */ - Page: { - /** - * Provides methods to retrieve information specific to an organization, a user, or parameters passed to a page. - */ - context: Context; - - /** - * Provides methods to work with the form. - */ - data: Data; - - /** - * Contains properties and methods to retrieve information about the user interface as well as collections for several subcomponents of the form. - */ - ui: Ui; - - /** - * Gets all attributes. - * - * @return An array of attributes. - */ - getAttribute(): Page.Attribute[]; - - /** - * Gets an attribute matching attributeName. - * - * @tparam T An Attribute type. - * @param {string} attributeName Name of the attribute. - * - * @return The attribute. - */ - getAttribute(attributeName: string): T; - - /** - * Gets an attribute matching attributeName. - * - * @param {string} attributeName Name of the attribute. - * - * @return The attribute. - */ - getAttribute(attributeName: string): Page.Attribute; - - /** - * Gets an attribute by index. - * - * @param {number} index The attribute index. - * - * @return The attribute. - */ - getAttribute(index: number): Page.Attribute; - - /** - * Gets an attribute. - * - * @param {Collection.MatchingDelegate{Attribute}} delegateFunction A matching delegate function - * - * @return An array of attribute. - */ - getAttribute(delegateFunction: Collection.MatchingDelegate): Page.Attribute[]; - - /** - * Gets all controls. - * - * @return An array of controls. - */ - getControl(): Page.Control[]; - - /** - * Gets a control matching controlName. - * - * @tparam T A Control type - * @param {string} controlName Name of the control. - * - * @return The control. - */ - getControl(controlName: string): T; - - /** - * Gets a control matching controlName. - * - * @param {string} controlName Name of the control. - * - * @return The control. - */ - getControl(controlName: string): Page.Control; - - /** - * Gets a control by index. - * - * @tparam T A Control type - * @param {number} index The control index. - * - * @return The control. - */ - getControl(index: number): T; - - /** - * Gets a control by index. - * - * @param {number} index The control index. - * - * @return The control. - */ - getControl(index: number): Page.Control; - - /** - * Gets a control. - * - * @param {Collection.MatchingDelegate{Control}} delegateFunction A matching delegate function. - * - * @return An array of control. - */ - getControl(delegateFunction: Collection.MatchingDelegate): Page.Control[]; - }; + Page: Page; /** * Provides a container for useful functions not directly related to the current page. */ - Utility: { - /** - * Displays an alert dialog, with an "OK" button. - * - * @param {string} message The message. - * @param {function()} onCloseCallback The "OK" callback. - */ - alertDialog(message: string, onCloseCallback: () => void): void; - - /** - * Displays a confirmation dialog, with "OK" and "Cancel" buttons. - * - * @param {string} message The message. - * @param {function()} yesCloseCallback The "OK" callback. - * @param {function()} noCloseCallback The "Cancel" callback. - */ - confirmDialog(message: string, yesCloseCallback: () => void, noCloseCallback: () => void): void; - - /** - * Query if 'entityType' is an Activity entity. - * - * @param {string} entityType Type of the entity. - * - * @return true if the entity is an Activity, false if not. - */ - isActivityType(entityType: string): boolean; - - /** - * Opens quick create. - * - * @param {string} entityLogicalName The logical name of the entity to create. - * @param {Page.LookupValue} createFromEntity (Optional) Designates a record that will provide default values - * based on mapped attribute values. - * @param {OpenParameters} parameters (Optional) A dictionary object that passes extra query string - * parameters to the form. Invalid query string parameters will cause an - * error. - * @return {Async.XrmPromise} Returns an asynchronous promise. - */ - openQuickCreate(entityLogicalName: string, createFromEntity?: Page.LookupValue, parameters?: Utility.OpenParameters): - Async.XrmPromise; - - /** - * Opens an entity form. - * - * @param {string} name The entity's logical name. - * @param {string} id (Optional) The unique identifier for the record. - * @param {FormParameters} parameters (Optional) A dictionary object that passes extra query string parameters to the form. - * @param {WindowOptions} windowOptions (Optional) Options for controlling the window. - */ - openEntityForm(name: string, id?: string, parameters?: Utility.FormOpenParameters, windowOptions?: Utility.WindowOptions): void; - - /** - * Opens an HTML Web Resource in a new browser window. - * - * @param {string} webResourceName Name of the HTML web resource. Can be used to pass URL - * parameters. See Remarks. - * @param {string} webResourceData (Optional) Data to pass into the Web Resource's data parameter. - * It is advised to use encodeURIcomponent() to encode the value. - * @param {number} width (Optional) The width of the new window. - * @param {number} height (Optional) The height of the new window. - * - * @return A Window reference, containing the opened Web Resource. - * - * @remarks This function will not work with Microsoft Dynamics CRM for tablets. - * Valid WebResource URL Parameters: typename - * type - * id - * orgname - * userlcid - * data (identical to this method's webResourceData parameter) - * formid - */ - openWebResource(webResourceName: string, webResourceData?: string, width?: number, height?: number): Window; - }; + Utility: Utility; /** * Provides methods to create and manage records in the mobile clients (for phones tablets). @@ -227,17 +41,7 @@ declare namespace Xrm { * * @see {@link https://msdn.microsoft.com/en-us/library/mt790281.aspx} for details. */ - Panel: { - /** - * Displays the web page represented by a URL in the static area in the side pane, which appears on all pages in the web client. - * - * @param {string} url URL of the page to be loaded in the side pane static area. - * @param {string} url Title of the side pane static area. - * - * @remarks This method is only supported for the web client. - */ - LoadPanel(url: string, title: string): void; - }; + Panel: Panel; } /** @@ -443,6 +247,121 @@ declare namespace Xrm { process: Page.data.ProcessManager; } + interface Page { + /** + * Provides methods to retrieve information specific to an organization, a user, or parameters passed to a page. + */ + context: Context; + + /** + * Provides methods to work with the form. + */ + data: Data; + + /** + * Contains properties and methods to retrieve information about the user interface as well as collections for several subcomponents of the form. + */ + ui: Ui; + + /** + * Gets all attributes. + * + * @return An array of attributes. + */ + getAttribute(): Page.Attribute[]; + + /** + * Gets an attribute matching attributeName. + * + * @tparam T An Attribute type. + * @param {string} attributeName Name of the attribute. + * + * @return The attribute. + */ + getAttribute(attributeName: string): T; + + /** + * Gets an attribute matching attributeName. + * + * @param {string} attributeName Name of the attribute. + * + * @return The attribute. + */ + getAttribute(attributeName: string): Page.Attribute; + + /** + * Gets an attribute by index. + * + * @param {number} index The attribute index. + * + * @return The attribute. + */ + getAttribute(index: number): Page.Attribute; + + /** + * Gets an attribute. + * + * @param {Collection.MatchingDelegate{Attribute}} delegateFunction A matching delegate function + * + * @return An array of attribute. + */ + getAttribute(delegateFunction: Collection.MatchingDelegate): Page.Attribute[]; + + /** + * Gets all controls. + * + * @return An array of controls. + */ + getControl(): Page.Control[]; + + /** + * Gets a control matching controlName. + * + * @tparam T A Control type + * @param {string} controlName Name of the control. + * + * @return The control. + */ + getControl(controlName: string): T; + + /** + * Gets a control matching controlName. + * + * @param {string} controlName Name of the control. + * + * @return The control. + */ + getControl(controlName: string): Page.Control; + + /** + * Gets a control by index. + * + * @tparam T A Control type + * @param {number} index The control index. + * + * @return The control. + */ + getControl(index: number): T; + + /** + * Gets a control by index. + * + * @param {number} index The control index. + * + * @return The control. + */ + getControl(index: number): Page.Control; + + /** + * Gets a control. + * + * @param {Collection.MatchingDelegate{Control}} delegateFunction A matching delegate function. + * + * @return An array of control. + */ + getControl(delegateFunction: Collection.MatchingDelegate): Page.Control[]; + } + /** * Interface for the Xrm.Page.ui object. */ @@ -552,6 +471,81 @@ declare namespace Xrm { quickForms: Collection.ItemCollection; } + interface Utility { + /** + * Displays an alert dialog, with an "OK" button. + * + * @param {string} message The message. + * @param {function()} onCloseCallback The "OK" callback. + */ + alertDialog(message: string, onCloseCallback: () => void): void; + + /** + * Displays a confirmation dialog, with "OK" and "Cancel" buttons. + * + * @param {string} message The message. + * @param {function()} yesCloseCallback The "OK" callback. + * @param {function()} noCloseCallback The "Cancel" callback. + */ + confirmDialog(message: string, yesCloseCallback: () => void, noCloseCallback: () => void): void; + + /** + * Query if 'entityType' is an Activity entity. + * + * @param {string} entityType Type of the entity. + * + * @return true if the entity is an Activity, false if not. + */ + isActivityType(entityType: string): boolean; + + /** + * Opens quick create. + * + * @param {string} entityLogicalName The logical name of the entity to create. + * @param {Page.LookupValue} createFromEntity (Optional) Designates a record that will provide default values + * based on mapped attribute values. + * @param {OpenParameters} parameters (Optional) A dictionary object that passes extra query string + * parameters to the form. Invalid query string parameters will cause an + * error. + * @return {Async.XrmPromise} Returns an asynchronous promise. + */ + openQuickCreate(entityLogicalName: string, createFromEntity?: Page.LookupValue, parameters?: Utility.OpenParameters): + Async.XrmPromise; + + /** + * Opens an entity form. + * + * @param {string} name The entity's logical name. + * @param {string} id (Optional) The unique identifier for the record. + * @param {FormParameters} parameters (Optional) A dictionary object that passes extra query string parameters to the form. + * @param {WindowOptions} windowOptions (Optional) Options for controlling the window. + */ + openEntityForm(name: string, id?: string, parameters?: Utility.FormOpenParameters, windowOptions?: Utility.WindowOptions): void; + + /** + * Opens an HTML Web Resource in a new browser window. + * + * @param {string} webResourceName Name of the HTML web resource. Can be used to pass URL + * parameters. See Remarks. + * @param {string} webResourceData (Optional) Data to pass into the Web Resource's data parameter. + * It is advised to use encodeURIcomponent() to encode the value. + * @param {number} width (Optional) The width of the new window. + * @param {number} height (Optional) The height of the new window. + * + * @return A Window reference, containing the opened Web Resource. + * + * @remarks This function will not work with Microsoft Dynamics CRM for tablets. + * Valid WebResource URL Parameters: typename + * type + * id + * orgname + * userlcid + * data (identical to this method's webResourceData parameter) + * formid + */ + openWebResource(webResourceName: string, webResourceData?: string, width?: number, height?: number): Window; + } + /** * Interface for methods to create and manage records in the mobile clients (for phones tablets). */ @@ -666,6 +660,18 @@ declare namespace Xrm { deleteRecord(entityType: string, id: string): Async.XrmPromise; } + interface Panel { + /** + * Displays the web page represented by a URL in the static area in the side pane, which appears on all pages in the web client. + * + * @param {string} url URL of the page to be loaded in the side pane static area. + * @param {string} url Title of the side pane static area. + * + * @remarks This method is only supported for the web client. + */ + LoadPanel(url: string, title: string): void; + } + /** * A definition module for asynchronous interface declarations. */ @@ -1595,6 +1601,15 @@ declare namespace Xrm { * @sa EnumAttribute */ interface BooleanAttribute extends EnumAttribute { + /** + * Gets the initial value of the attribute. + * + * @return The initial value. + * + * @remarks Valid for OptionSet and boolean attribute types + */ + getInitialValue(): boolean; + /** * Gets the value. * @@ -1666,6 +1681,15 @@ declare namespace Xrm { */ getFormat(): OptionSetAttributeFormat; + /** + * Gets the initial value of the attribute. + * + * @return The initial value. + * + * @remarks Valid for OptionSet and boolean attribute types + */ + getInitialValue(): number; + /** * Gets the option matching a value. * diff --git a/types/xrm/xrm-tests.ts b/types/xrm/xrm-tests.ts index 5d9d99b644..5b5b12c333 100644 --- a/types/xrm/xrm-tests.ts +++ b/types/xrm/xrm-tests.ts @@ -143,7 +143,7 @@ const resultSet: Xrm.Page.AutoCompleteResultSet = { // accounts in CRM. window.open("http://www.microsoft.com/en-us/dynamics/crm-customer-center/create-or-edit-an-account.aspx"); } - } as Xrm.Page.AutoCompleteCommand + } }; resultSet.results.push({ id: 0,