diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index d9258f7a48..d00c037c71 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -7,6 +7,7 @@ // Jason Dreyzehner // Synarque // Justin Rockwood +// Keith Kelly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -21,6 +22,13 @@ declare namespace inquirer { | Question | ReadonlyArray> | Rx.Observable>; + interface OutputStreamOption { + output: NodeJS.WriteStream + } + interface InputStreamOption { + input: NodeJS.ReadStream + } + type StreamOptions = InputStreamOption | OutputStreamOption | (InputStreamOption & OutputStreamOption); interface Inquirer { restoreDefaultPrompts(): void; @@ -32,8 +40,9 @@ declare namespace inquirer { registerPrompt(name: string, prompt: PromptModule): void; /** * Create a new self-contained prompt module. + * @param opt Object specifying input and output streams for the prompt */ - createPromptModule(): PromptModule; + createPromptModule(opt?: StreamOptions): PromptModule; /** * Public CLI helper interface * @param questions Questions settings array diff --git a/types/inquirer/inquirer-tests.ts b/types/inquirer/inquirer-tests.ts index aa545adae0..85a81d761e 100644 --- a/types/inquirer/inquirer-tests.ts +++ b/types/inquirer/inquirer-tests.ts @@ -626,3 +626,47 @@ async function testAsyncPrompt(): Promise { } testAsyncPrompt(); + +/** + * Different prompt output example + */ + +"use strict"; +//var inquirer = require("../lib/inquirer"); + +var questions = [ + { + type: "input", + name: "first_name", + message: "What's your first name", + prefix: "1 - " + }, + { + type: "input", + name: "last_name", + message: "What's your last name", + default: function() { + return "Doe"; + }, + suffix: "!!" + }, + { + type: "input", + name: "phone", + message: "What's your phone number", + validate: function(value: string): string | boolean { + var pass = value.match( + /^([01]{1})?[\-\.\s]?\(?(\d{3})\)?[\-\.\s]?(\d{3})[\-\.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i + ); + if (pass) { + return true; + } else { + return "Please enter a valid phone number"; + } + } + } +]; + +inquirer.createPromptModule({ output: process.stderr })(questions, function(answers) { + console.log(JSON.stringify(answers, null, " ")); +}); diff --git a/types/mongodb/tsconfig.json b/types/mongodb/tsconfig.json index 8ed16ed7e6..aae592b3bd 100644 --- a/types/mongodb/tsconfig.json +++ b/types/mongodb/tsconfig.json @@ -4,7 +4,7 @@ "lib": [ "es6" ], - "noImplicitAny": false, + "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index a94f3a691d..17176079ca 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -854,6 +854,8 @@ declare module "mongoose" { typeKey?: string; /** defaults to false */ useNestedStrict?: boolean; + /** defaults to false */ + usePushEach?: boolean; /** defaults to true */ validateBeforeSave?: boolean; /** defaults to "__v" */ diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 0cac8c1e45..aed01dd504 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -25,6 +25,7 @@ // Alexander T. // Lishude // Andrew Makarov +// Zane Hannan AU // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** inspector module types */ @@ -2560,11 +2561,19 @@ declare module "dns" { ttl: number; } + export interface AnyRecordWithTtl extends RecordWithTtl { + type: "A" | "AAAA"; + } + export interface MxRecord { priority: number; exchange: string; } + export interface AnyMxRecord extends MxRecord { + type: "MX"; + } + export interface NaptrRecord { flags: string; service: string; @@ -2574,6 +2583,10 @@ declare module "dns" { preference: number; } + export interface AnyNaptrRecord extends NaptrRecord { + type: "NAPTR"; + } + export interface SoaRecord { nsname: string; hostmaster: string; @@ -2584,6 +2597,10 @@ declare module "dns" { minttl: number; } + export interface AnySoaRecord extends SoaRecord { + type: "SOA"; + } + export interface SrvRecord { priority: number; weight: number; @@ -2591,9 +2608,19 @@ declare module "dns" { name: string; } + export interface AnySrvRecord extends SrvRecord { + type: "SRV"; + } + + export interface AnyTxtRecord { + type: "TXT"; + entries: 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: "ANY", callback: (err: NodeJS.ErrnoException, addresses: ReadonlyArray) => 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; @@ -2607,6 +2634,7 @@ declare module "dns" { // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. export namespace resolve { export function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise; + export function __promisify__(hostname: string, rrtype: "ANY"): Promise>; export function __promisify__(hostname: string, rrtype: "MX"): Promise; export function __promisify__(hostname: string, rrtype: "NAPTR"): Promise; export function __promisify__(hostname: string, rrtype: "SOA"): Promise; @@ -2637,6 +2665,7 @@ declare module "dns" { export function __promisify__(hostname: string, options?: ResolveOptions): Promise; } + export function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: ReadonlyArray) => 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; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index a4850ff4ef..d9fe6768f6 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -3142,6 +3142,9 @@ namespace dns_tests { dns.resolve("nodejs.org", "AAAA", (err, addresses) => { const _addresses: string[] = addresses; }); + dns.resolve("nodejs.org", "ANY", (err, addresses) => { + const _addresses: ReadonlyArray = addresses; + }); dns.resolve("nodejs.org", "MX", (err, addresses) => { const _addresses: dns.MxRecord[] = addresses; }); diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index 6ba112efaa..a6892eb189 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -656,6 +656,7 @@ declare namespace Office { */ closeContainer(): void; } + /** * Provides information about what Requirement Sets are supported in current environment. */ @@ -666,7 +667,8 @@ declare namespace Office { * @param minVersion - The minimum required version; e.g., "1.4". */ isSetSupported(name: string, minVersion?: number): boolean; -} + } + /** * Provides options for how a dialog is displayed. */ @@ -1062,11 +1064,11 @@ declare namespace Office { controlForegroundColor: string; } /** - * Dialog object returned as part of the displayDialogAsync callback. The object exposes methods for registering event handlers and closing the dialog + * The object that is returned when `UI.displayDialogAsync` is called. It exposes methods for registering event handlers and closing the dialog. */ - interface DialogHandler { + interface Dialog { /** - * When called from an active add-in dialog, asynchronously closes the dialog. + * Called from a parent page to close the corresponding dialog box. */ close(): void; /** diff --git a/types/react-stripe-elements/index.d.ts b/types/react-stripe-elements/index.d.ts index e8e88757b2..abc08cc3e1 100644 --- a/types/react-stripe-elements/index.d.ts +++ b/types/react-stripe-elements/index.d.ts @@ -30,7 +30,7 @@ export namespace ReactStripeElements { interface StripeProviderOptions { stripeAccount?: string; } - type StripeProviderProps = { apiKey: string; stripe?: never; } & StripeProviderOptions | { apiKey?: never; stripe: StripeProps | null; } & StripeProviderOptions; + type StripeProviderProps = { apiKey: string; stripe?: never; } & StripeProviderOptions | { apiKey?: never; stripe: stripe.Stripe | null; } & StripeProviderOptions; interface StripeProps { createSource(sourceData?: SourceOptions): Promise; diff --git a/types/react-stripe-elements/react-stripe-elements-tests.tsx b/types/react-stripe-elements/react-stripe-elements-tests.tsx index ef1af5fa86..88b703b141 100644 --- a/types/react-stripe-elements/react-stripe-elements-tests.tsx +++ b/types/react-stripe-elements/react-stripe-elements-tests.tsx @@ -16,7 +16,6 @@ import ElementChangeResponse = stripe.elements.ElementChangeResponse; import ElementsOptions = stripe.elements.ElementsOptions; import ElementsCreateOptions = stripe.elements.ElementsCreateOptions; import PatchedTokenResponse = ReactStripeElements.PatchedTokenResponse; -import StripeProps = ReactStripeElements.StripeProps; const cardElementProps: ElementsOptions = { iconStyle: 'solid', @@ -185,7 +184,7 @@ const ElementsDefaultPropsTest: React.SFC = () => ( const TestStripeProviderProps1: React.SFC = () => ; const TestStripeProviderProps2: React.SFC<{ - stripe: StripeProps; + stripe: stripe.Stripe; }> = props => ; /** @@ -193,9 +192,22 @@ const TestStripeProviderProps2: React.SFC<{ * See: https://github.com/stripe/react-stripe-elements#props-shape */ const TestStripeProviderProps3: React.SFC<{ - stripe: StripeProps; + stripe: stripe.Stripe; }> = props => ; +/** + * End-to-end usage of loading stripe.js asynchronously. + * See: https://github.com/stripe/react-stripe-elements#loading-stripejs-asynchronously + */ +const TestStripeProviderProps4: React.SFC<{ + stripe: null | stripe.Stripe +}> = props => + + +
+ + ; + /** * StripeProvider should be able to accept options. * See: https://stripe.com/docs/stripe-js/reference#stripe-function for options. diff --git a/types/superagent/index.d.ts b/types/superagent/index.d.ts index 7daf5f47dc..e5a52ce3cd 100644 --- a/types/superagent/index.d.ts +++ b/types/superagent/index.d.ts @@ -150,7 +150,7 @@ declare namespace request { write(data: string | Buffer, encoding?: string): this; } - type Plugin = (req: Request) => void; + type Plugin = (req: SuperAgentRequest) => void; interface ProgressEvent { direction: 'download' | 'upload'; diff --git a/types/superagent/superagent-tests.ts b/types/superagent/superagent-tests.ts index 66046759f1..0c4b51f31e 100644 --- a/types/superagent/superagent-tests.ts +++ b/types/superagent/superagent-tests.ts @@ -390,3 +390,18 @@ request .then(response => { // reads 404 page as a successful response }); + +// Test that the "Plugin" type from "use" provides a SuperAgentRequest rather than a Request, +// which has additional properties. +const echoPlugin = (request: request.SuperAgentRequest) => { + req.url = '' + req.url; + req.cookies = '' + req.cookies; + if (req.method) { + req.url = '/echo'; + } +}; + +request + .get('/echo') + .use(echoPlugin) + .end();