Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Alex Jerabek
2018-06-18 16:04:47 -07:00
11 changed files with 127 additions and 11 deletions

View File

@@ -7,6 +7,7 @@
// Jason Dreyzehner <https://github.com/bitjson>
// Synarque <https://github.com/synarque>
// Justin Rockwood <https://github.com/jrockwood>
// Keith Kelly <https://github.com/kwkelly>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -21,6 +22,13 @@ declare namespace inquirer {
| Question<T>
| ReadonlyArray<Question<T>>
| Rx.Observable<Question<T>>;
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

View File

@@ -626,3 +626,47 @@ async function testAsyncPrompt(): Promise<void> {
}
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, " "));
});

View File

@@ -4,7 +4,7 @@
"lib": [
"es6"
],
"noImplicitAny": false,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,

View File

@@ -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" */

29
types/node/index.d.ts vendored
View File

@@ -25,6 +25,7 @@
// Alexander T. <https://github.com/a-tarasyuk>
// Lishude <https://github.com/islishude>
// Andrew Makarov <https://github.com/r3nya>
// Zane Hannan AU <https://github.com/ZaneHannanAU>
// 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<AnySrvRecord | AnySoaRecord | AnyNaptrRecord | AnyRecordWithTtl | AnyMxRecord | AnyTxtRecord>) => 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<string[]>;
export function __promisify__(hostname: string, rrtype: "ANY"): Promise<ReadonlyArray<AnySrvRecord | AnySoaRecord | AnyNaptrRecord | AnyRecordWithTtl | AnyMxRecord | AnyTxtRecord>>;
export function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
export function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
export function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
@@ -2637,6 +2665,7 @@ declare module "dns" {
export function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
}
export function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: ReadonlyArray<AnySrvRecord | AnySoaRecord | AnyNaptrRecord | AnyRecordWithTtl | AnyMxRecord | AnyTxtRecord>) => 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;

View File

@@ -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<dns.AnySrvRecord | dns.AnySoaRecord | dns.AnyNaptrRecord | dns.AnyRecordWithTtl | dns.AnyMxRecord | dns.AnyTxtRecord> = addresses;
});
dns.resolve("nodejs.org", "MX", (err, addresses) => {
const _addresses: dns.MxRecord[] = addresses;
});

View File

@@ -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;
/**

View File

@@ -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<SourceResponse>;

View File

@@ -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 = () => <StripeProvider apiKey="" />;
const TestStripeProviderProps2: React.SFC<{
stripe: StripeProps;
stripe: stripe.Stripe;
}> = props => <StripeProvider stripe={props.stripe} />;
/**
@@ -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 => <StripeProvider stripe={null} />;
/**
* 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 stripe={props.stripe}>
<Elements>
<div />
</Elements>
</StripeProvider>;
/**
* StripeProvider should be able to accept options.
* See: https://stripe.com/docs/stripe-js/reference#stripe-function for options.

View File

@@ -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';

View File

@@ -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();