From b5d057481543d43e5fce7e33ff4f54d48d142194 Mon Sep 17 00:00:00 2001 From: l-jonas Date: Thu, 10 May 2018 21:42:12 +0200 Subject: [PATCH 01/19] Add types for in-app-purchase (#25651) * Add types for in-app-purchase * in-app-purchase: Change order of validateOnce overloads --- .../in-app-purchase/in-app-purchase-tests.ts | 38 +++++++ types/in-app-purchase/index.d.ts | 107 ++++++++++++++++++ types/in-app-purchase/tsconfig.json | 23 ++++ types/in-app-purchase/tslint.json | 1 + 4 files changed, 169 insertions(+) create mode 100644 types/in-app-purchase/in-app-purchase-tests.ts create mode 100644 types/in-app-purchase/index.d.ts create mode 100644 types/in-app-purchase/tsconfig.json create mode 100644 types/in-app-purchase/tslint.json diff --git a/types/in-app-purchase/in-app-purchase-tests.ts b/types/in-app-purchase/in-app-purchase-tests.ts new file mode 100644 index 0000000000..4e142e53e2 --- /dev/null +++ b/types/in-app-purchase/in-app-purchase-tests.ts @@ -0,0 +1,38 @@ +import * as iap from 'in-app-purchase'; + +iap.config({ + /* Configurations for Amazon Store */ + amazonAPIVersion: 2, // tells the module to use API version 2 + secret: 'abcdefghijklmnoporstuvwxyz', // this comes from Amazon + + /* Configurations for Apple */ + applePassword: 'abcdefg...', // this comes from iTunes Connect (You need this to valiate subscriptions) + + /* Configurations for Google Play */ + googlePublicKeyPath: 'path/to/public/key/directory/', // this is the path to the directory containing iap-sanbox/iap-live files + googleAccToken: 'abcdef...', // optional, for Google Play subscriptions + googleRefToken: 'dddd...', // optional, for Google Play subscritions + clientId: 'aaaa', // optional, for Google Play subscriptions + clientSecret: 'bbbb', // optional, for Google Play subscriptions + refreshToken: 'cccc', // optional, for Google Play subscriptions + + /* Configurations for Roku */ + rokuApiKey: 'aaaa...', // this comes from Roku Developer Dashboard + + /* Configurations all platforms */ + test: true, // For Apple and Googl Play to force Sandbox validation only + verbose: true // Output debug logs to stdout stream +}); +iap.setup() + .then(() => iap.validate('abcdef')) + .then((validatedData) => { + const options = { + ignoreCanceled: true, // Apple ONLY (for now...): purchaseData will NOT contain cancceled items + ignoreExpired: true // purchaseData will NOT contain exipired subscription items + }; + + const purchaseData = iap.getPurchaseData(validatedData, options); + }) + .catch((error) => { + // error... + }); diff --git a/types/in-app-purchase/index.d.ts b/types/in-app-purchase/index.d.ts new file mode 100644 index 0000000000..b27daf2c20 --- /dev/null +++ b/types/in-app-purchase/index.d.ts @@ -0,0 +1,107 @@ +// Type definitions for in-app-purchase 1.9 +// Project: https://github.com/voltrue2/in-app-purchase#readme +// Definitions by: Jonas Lochmann +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export const UNITY = 'unity'; +export const APPLE = 'apple'; +export const GOOGLE = 'google'; +export const WINDOWS = 'windows'; +export const AMAZON = 'amazon'; +export const ROKU = 'roku'; + +export function config(params: Config): void; +export function setup(): Promise; +export function setup(callback: (err: any) => void): void; +export function getService(receipt: Receipt): Service; + +export function validate(receipt: Receipt): Promise; +export function validate(receipt: Receipt, callback: (err: any, res: ValidationResponse) => void): void; +export function validate(service: Service, receipt: Receipt, callback: (err: any, res: ValidationResponse) => void): void; + +export function validateOnce(receipt: Receipt, secretOrPubKey: any): Promise; +export function validateOnce(receipt: Receipt, secretOrPubKey: any, callback: (err: any, res: ValidationResponse) => void): void; +export function validateOnce(service: Service, secretOrPubKey: any, receipt: Receipt, callback: (err: any, res: ValidationResponse) => void): void; + +export function isValidated(response: ValidationResponse): boolean; +export function isExpired(item: PurchasedItem): boolean; +export function getPurchaseData(purchaseData?: ValidationResponse, options?: { + ignoreCanceled: boolean; + ignoreExpired: boolean; +}): PurchasedItem[] | null; + +export function refreshGoogleToken(): Promise; +export function refreshGoogleToken(callback: (err: any) => void): void; + +// for test use only, resets the google setup +export function reset(): void; + +export interface Config { + /* Configurations for Amazon Store */ + amazonAPIVersion?: number; + secret?: string; + + /* Configurations for Apple */ + + // this comes from iTunes Connect (You need this to valiate subscriptions) + applePassword?: string; + + /* Configurations for Google Play */ + // this is the path to the directory containing iap-sanbox/iap-live files + googlePublicKeyPath?: string; + // optional, for Google Play subscriptions + googleAccToken?: string; + // optional, for Google Play subscritions + googleRefToken?: string; + // optional, for Google Play subscriptions + clientId?: string; + // optional, for Google Play subscriptions + clientSecret?: string; + // optional, for Google Play subscriptions + refreshToken?: string; + + /* Configurations for Roku */ + // this comes from Roku Developer Dashboard + rokuApiKey?: string; + + /* Configurations all platforms */ + // For Apple and Googl Play to force Sandbox validation only + test?: boolean; + // Output debug logs to stdout stream + verbose?: boolean; +} + +export type Service = typeof UNITY | typeof APPLE | typeof GOOGLE | typeof WINDOWS | typeof AMAZON | typeof ROKU; + +export type UnityReceipt = object | string; +export type AppleReceipt = string; +export type GoogleReceipt = { + date: string; + signature: string; +} | string; +export type WindowsReceipt = string; +export type AmazonReceipt = object | string; +export type RokuReceipt = string; + +export type Receipt = UnityReceipt | AppleReceipt | GoogleReceipt | WindowsReceipt | AmazonReceipt | RokuReceipt; + +export interface ValidationResponse { + service: Service; + status: number; + // there are more fields depending on the used service +} + +export interface PurchasedItem { + bundleId?: string; // only Apple + orderId?: string; // only Google + transactionId: string; + productId: string; + purchaseDate: number; + // iTunes, windows and amazon subscription only + // Google subscriptions only with google play store api info + expirationDate?: number; + quantity: number; + // this was created based on the source code of in-app-purchase + // eventually there are more fields +} diff --git a/types/in-app-purchase/tsconfig.json b/types/in-app-purchase/tsconfig.json new file mode 100644 index 0000000000..7752182f8a --- /dev/null +++ b/types/in-app-purchase/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "in-app-purchase-tests.ts" + ] +} diff --git a/types/in-app-purchase/tslint.json b/types/in-app-purchase/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/in-app-purchase/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b5591375e35240eb4fc2b33580ee5104a3409f24 Mon Sep 17 00:00:00 2001 From: Jip Sterk <17934897+JipSterk@users.noreply.github.com> Date: Thu, 10 May 2018 21:46:04 +0200 Subject: [PATCH 02/19] Added dom-to-image typings (#25650) * Added dom-to-image typings * changed string to blob * blob is now in the right place * updated to reflect new changes --- types/dom-to-image/index.d.ts | 42 +++++++++++++++++++ .../test/dom-to-image-global-tests.ts | 38 +++++++++++++++++ .../test/dom-to-image-import-default-tests.ts | 40 ++++++++++++++++++ .../test/dom-to-image-module-tests.ts | 40 ++++++++++++++++++ types/dom-to-image/tsconfig.json | 27 ++++++++++++ types/dom-to-image/tslint.json | 3 ++ 6 files changed, 190 insertions(+) create mode 100644 types/dom-to-image/index.d.ts create mode 100644 types/dom-to-image/test/dom-to-image-global-tests.ts create mode 100644 types/dom-to-image/test/dom-to-image-import-default-tests.ts create mode 100644 types/dom-to-image/test/dom-to-image-module-tests.ts create mode 100644 types/dom-to-image/tsconfig.json create mode 100644 types/dom-to-image/tslint.json diff --git a/types/dom-to-image/index.d.ts b/types/dom-to-image/index.d.ts new file mode 100644 index 0000000000..b6e186f53b --- /dev/null +++ b/types/dom-to-image/index.d.ts @@ -0,0 +1,42 @@ +// Type definitions for dom-to-image 2.6 +// Project: https://github.com/tsayen/dom-to-image +// Definitions by: Jip Sterk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +export interface DomToImage { + toSvg(node: Node, options?: Options): Promise; + toPng(node: Node, options?: Options): Promise; + toJpeg(node: Node, options?: Options): Promise; + toBlob(node: Node, options?: Options): Promise; + toPixelData(node: Node, options?: Options): Promise; +} + +export interface Options { + filter?: (node: Node) => boolean; + bgcolor?: string; + width?: number; + height?: number; + style?: {}; + quality?: number; + imagePlaceholder?: string; + cachebust?: boolean; +} + +export const DomToImage: DomToImage; + +type DomToImage_ = DomToImage; +type Options_ = Options; + +export default DomToImage; + +declare global { + namespace DomToImage { + type Options = Options_; + type DomToImage = DomToImage_; + } + + const DomToImage: DomToImage.DomToImage; +} diff --git a/types/dom-to-image/test/dom-to-image-global-tests.ts b/types/dom-to-image/test/dom-to-image-global-tests.ts new file mode 100644 index 0000000000..a21be8bd01 --- /dev/null +++ b/types/dom-to-image/test/dom-to-image-global-tests.ts @@ -0,0 +1,38 @@ +const node = new Node(); + +const options: DomToImage.Options = { + filter, + bgcolor: '#24292e', + style: { + width: '100px' + }, + width: 100, + height: 100, + quality: 0.1, + imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', + cachebust: true +}; + +function filter(node: Node): boolean { + return true; +} + +async function testToSvg() { + const svg = await DomToImage.toSvg(node, { filter }); +} + +async function testToPng() { + const png = await DomToImage.toPng(node, { bgcolor: '#24292e', style: { width: '100px' } }); +} + +async function testToJpeg() { + const jpeg = await DomToImage.toJpeg(node, { width: 100, height: 100 }); +} + +async function testToBlob() { + const blob = await DomToImage.toBlob(node, { quality: 0.1, }); +} + +async function testToPixelData() { + const pixelData = await DomToImage.toPixelData(node, { imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', cachebust: true }); +} diff --git a/types/dom-to-image/test/dom-to-image-import-default-tests.ts b/types/dom-to-image/test/dom-to-image-import-default-tests.ts new file mode 100644 index 0000000000..0f300ffa38 --- /dev/null +++ b/types/dom-to-image/test/dom-to-image-import-default-tests.ts @@ -0,0 +1,40 @@ +import domToImage, { Options } from 'dom-to-image'; + +const node = new Node(); + +const options: Options = { + filter, + bgcolor: '#24292e', + style: { + width: '100px' + }, + width: 100, + height: 100, + quality: 0.1, + imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', + cachebust: true +}; + +function filter(node: Node): boolean { + return true; +} + +async function testToSvg() { + const svg = await domToImage.toSvg(node, { filter }); +} + +async function testToPng() { + const png = await domToImage.toPng(node, { bgcolor: '#24292e', style: { width: '100px' } }); +} + +async function testToJpeg() { + const jpeg = await domToImage.toJpeg(node, { width: 100, height: 100 }); +} + +async function testToBlob() { + const blob = await domToImage.toBlob(node, { quality: 0.1, }); +} + +async function testToPixelData() { + const pixelData = await domToImage.toPixelData(node, { imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', cachebust: true }); +} diff --git a/types/dom-to-image/test/dom-to-image-module-tests.ts b/types/dom-to-image/test/dom-to-image-module-tests.ts new file mode 100644 index 0000000000..571a28f5b6 --- /dev/null +++ b/types/dom-to-image/test/dom-to-image-module-tests.ts @@ -0,0 +1,40 @@ +import { Options, DomToImage } from 'dom-to-image'; + +const node = new Node(); + +const options: Options = { + filter, + bgcolor: '#24292e', + style: { + width: '100px' + }, + width: 100, + height: 100, + quality: 0.1, + imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', + cachebust: true +}; + +function filter(node: Node): boolean { + return true; +} + +async function testToSvg() { + const svg = await DomToImage.toSvg(node, { filter }); +} + +async function testToPng() { + const png = await DomToImage.toPng(node, { bgcolor: '#24292e', style: { width: '100px' } }); +} + +async function testToJpeg() { + const jpeg = await DomToImage.toJpeg(node, { width: 100, height: 100 }); +} + +async function testToBlob() { + const blob = await DomToImage.toBlob(node, { quality: 0.1, }); +} + +async function testToPixelData() { + const pixelData = await DomToImage.toPixelData(node, { imagePlaceholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP', cachebust: true }); +} diff --git a/types/dom-to-image/tsconfig.json b/types/dom-to-image/tsconfig.json new file mode 100644 index 0000000000..10fc769913 --- /dev/null +++ b/types/dom-to-image/tsconfig.json @@ -0,0 +1,27 @@ + +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "test/dom-to-image-module-tests.ts", + "test/dom-to-image-global-tests.ts", + "test/dom-to-image-import-default-tests.ts" + ] +} \ No newline at end of file diff --git a/types/dom-to-image/tslint.json b/types/dom-to-image/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/dom-to-image/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file From 2404865eb1428336013ddc773ff16c5d9349d166 Mon Sep 17 00:00:00 2001 From: Sindre Date: Thu, 10 May 2018 21:55:12 +0200 Subject: [PATCH 03/19] Yup: allow options object in string().matches() function (#25634) * overloads string().matches() to add options object * Yup: fix lint feedback --- types/yup/index.d.ts | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index 93a60450e7..699d1893bf 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for yup 0.24 // Project: https://github.com/jquense/yup -// Definitions by: Dominik Hardtke , Vladyslav Tserman , Moreton Bay Regional Council +// Definitions by: Dominik Hardtke , +// Vladyslav Tserman , +// Moreton Bay Regional Council , +// Sindre Seppola // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -34,8 +37,8 @@ export interface Schema { meta(): any; describe(): SchemaDescription; concat(schema: this): this; - validate(value: T, options?: ValidateOptions): Promise; - validateSync(value: T, options?: ValidateOptions): ValidationError|T; + validate(value: T, options?: ValidateOptions): Promise; + validateSync(value: T, options?: ValidateOptions): ValidationError | T; isValid(value: T, options?: any): Promise; isValidSync(value: T, options?: any): boolean; cast(value: any, options?: any): T; @@ -57,8 +60,8 @@ export interface Schema { } export interface MixedSchemaConstructor { - (): MixedSchema; - new(options?: { type?: string, [key: string]: any }): MixedSchema; + (): MixedSchema; + new(options?: { type?: string, [key: string]: any }): MixedSchema; } // tslint:disable-next-line:no-empty-interface @@ -73,7 +76,7 @@ export interface StringSchemaConstructor { export interface StringSchema extends Schema { min(limit: number | Ref, message?: string): StringSchema; max(limit: number | Ref, message?: string): StringSchema; - matches(regex: RegExp, message?: string): StringSchema; + matches(regex: RegExp, messageOrOptions?: string | { message?: string; excludeEmptyString?: boolean }): StringSchema; email(message?: string): StringSchema; url(message?: string): StringSchema; ensure(): StringSchema; @@ -133,7 +136,7 @@ export interface ArraySchema extends Schema { export interface ObjectSchemaConstructor { (fields?: { [field in keyof T]: Schema }): ObjectSchema; - new (): ObjectSchema<{}>; + new(): ObjectSchema<{}>; } export interface ObjectSchema extends Schema { @@ -155,8 +158,8 @@ export interface WhenOptionsBuilder { } export type WhenOptions = WhenOptionsBuilder -| { is: boolean | ((value: any) => boolean), then: any, otherwise: any } -| object; + | { is: boolean | ((value: any) => boolean), then: any, otherwise: any } + | object; export interface ValidateOptions { /** @@ -245,12 +248,12 @@ export interface Lazy extends Schema { } export interface LocaleObject { - mixed?: { [key in keyof MixedSchema]?: string }; - string?: { [key in keyof StringSchema]?: string }; - number?: { [key in keyof NumberSchema]?: string }; - boolean?: { [key in keyof BooleanSchema]?: string }; - bool?: { [key in keyof BooleanSchema]?: string }; - date?: { [key in keyof DateSchema]?: string }; - array?: { [key in keyof ArraySchema]?: string }; - object?: { [key in keyof ObjectSchema]?: string }; + mixed?: { [key in keyof MixedSchema]?: string }; + string?: { [key in keyof StringSchema]?: string }; + number?: { [key in keyof NumberSchema]?: string }; + boolean?: { [key in keyof BooleanSchema]?: string }; + bool?: { [key in keyof BooleanSchema]?: string }; + date?: { [key in keyof DateSchema]?: string }; + array?: { [key in keyof ArraySchema]?: string }; + object?: { [key in keyof ObjectSchema]?: string }; } From 8c67ace1b8dfbf86eb649573807418ccdc9925d7 Mon Sep 17 00:00:00 2001 From: Camila Rondinini Date: Thu, 10 May 2018 15:55:42 -0400 Subject: [PATCH 04/19] Event Stream: Make split argument optional (#25657) --- types/event-stream/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/event-stream/index.d.ts b/types/event-stream/index.d.ts index f7b10b34a2..35fb2c8b4c 100644 --- a/types/event-stream/index.d.ts +++ b/types/event-stream/index.d.ts @@ -36,7 +36,7 @@ export declare function mapSync(syncFunction: Function): MapStream; * * @param matcher */ -export declare function split(matcher: string | RegExp): MapStream; +export declare function split(matcher?: string | RegExp): MapStream; /** * Create a through stream that emits separator between each chunk, just like Array#join From b1ae5471b09e6530b4f1c4c3f1b5dd997e598f53 Mon Sep 17 00:00:00 2001 From: Sherman Chen Date: Fri, 11 May 2018 04:56:51 +0900 Subject: [PATCH 05/19] @types/node-forge: Add forge.pki.certificateFromPem (#25672) --- types/node-forge/index.d.ts | 1 + types/node-forge/node-forge-tests.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index 2784d95fa3..703c78aa9b 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -48,6 +48,7 @@ declare module "node-forge" { function publicKeyFromPem(pem: PEM): Key; function privateKeyFromPem(pem: PEM): Key; function certificateToPem(cert: Certificate, maxline?: number): PEM; + function certificateFromPem(pem: PEM, computeHash?: boolean, strict?: boolean): Certificate; interface oids { [key: string]: string; diff --git a/types/node-forge/node-forge-tests.ts b/types/node-forge/node-forge-tests.ts index 29b8267714..1bb8dff08c 100644 --- a/types/node-forge/node-forge-tests.ts +++ b/types/node-forge/node-forge-tests.ts @@ -8,6 +8,7 @@ let x: string = forge.ssh.privateKeyToOpenSSH(key); let pemKey: forge.pki.PEM = publicKeyPem; let publicKeyRsa = forge.pki.publicKeyFromPem(pemKey); let privateKeyRsa = forge.pki.privateKeyFromPem(privateKeyPem); +let certPem = forge.pki.certificateFromPem(pemKey); let cert = forge.pki.createCertificate(); { From f8cac97960ce5dc31c3568d44b7cfb58dcb4238e Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Thu, 10 May 2018 12:58:03 -0700 Subject: [PATCH 06/19] Expand google-map-react options spec to cover all valid options (#25665) --- .../google-map-react-tests.tsx | 15 +++++- types/google-map-react/index.d.ts | 47 ++++++++++++++++--- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/types/google-map-react/google-map-react-tests.tsx b/types/google-map-react/google-map-react-tests.tsx index 464f840658..552e75d362 100644 --- a/types/google-map-react/google-map-react-tests.tsx +++ b/types/google-map-react/google-map-react-tests.tsx @@ -1,9 +1,20 @@ -import GoogleMapReact, { BootstrapURLKeys } from 'google-map-react'; +import GoogleMapReact, { BootstrapURLKeys, MapOptions } from 'google-map-react'; import * as React from 'react'; const center = { lat: 0, lng: 0 }; const key: BootstrapURLKeys = { key: 'my-google-maps-key' }; const client: BootstrapURLKeys = { client: 'my-client-identifier', v: '3.28' , language: 'en' }; +const options: MapOptions = { + zoomControl: false, + gestureHandling: 'cooperative', + styles: [ + { + featureType: "administrative", + elementType: "all", + stylers: [ {saturation: "-100"} ] + } + ], +}; -; +; diff --git a/types/google-map-react/index.d.ts b/types/google-map-react/index.d.ts index 7f34a68cc4..ca5348323a 100644 --- a/types/google-map-react/index.d.ts +++ b/types/google-map-react/index.d.ts @@ -8,15 +8,48 @@ import * as React from 'react'; export type BootstrapURLKeys = ({ key: string; } | { client: string; v: string; }) & { language?: string }; -export interface Options { - styles?: any[]; - scrollwheel?: boolean; - panControl?: boolean; +export interface MapTypeStyle { + elementType: string; + featureType: string; + stylers: any[]; +} + +export interface MapOptions { + // Any options from https://developers.google.com/maps/documentation/javascript/reference/3/#MapOptions + // excluding 'zoom' and 'center' which get set via props. + backgroundColor?: string; + clickableIcons?: boolean; + disableDefaultUI?: boolean; + disableDoubleClickZoom?: boolean; + draggable?: boolean; + draggableCursor?: string; + draggingCursor?: string; + fullscreenControl?: boolean; + fullscreenControlOptions?: {position: number}; + gestureHandling?: string; + heading?: number; + keyboardShortcuts?: boolean; mapTypeControl?: boolean; - minZoomOverride?: boolean; + mapTypeControlOptions?: any; + mapTypeId?: string; minZoom?: number; maxZoom?: number; - gestureHandling?: string; + noClear?: boolean; + panControl?: boolean; + panControlOptions?: {position: number}; + rotateControl?: boolean; + rotateControlOptions?: {position: number}; + scaleControl?: boolean; + scaleControlOptions?: any; + scrollwheel?: boolean; + streetView?: any; + streetViewControl?: boolean; + streetViewControlOptions?: {position: number}; + styles?: MapTypeStyle[]; + tilt?: number; + zoomControl?: boolean; + zoomControlOptions?: {position: number}; + minZoomOverride?: boolean; // Not a standard option; specific to google-map-react: https://github.com/google-map-react/google-map-react/pull/154 } export interface Maps { @@ -87,7 +120,7 @@ export interface Props { defaultZoom?: number; zoom?: number; hoverDistance?: number; - options?: Options | ((maps: Maps) => Options); + options?: MapOptions | ((maps: Maps) => MapOptions); margin?: any[]; debounced?: boolean; draggable?: boolean; From 7aa84a641783f1af2e6156bf7ff53665504aeb99 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 11 May 2018 05:58:19 +1000 Subject: [PATCH 07/19] [@types/graphql] Switch void for more correct `undefined | null` typing (#25639) * [@types/graphql] Switch void for more correct `undefined | null` typing * Moved Maybe.d.ts to a better place * Moved and fixed up Maybe imports --- types/graphql/error/GraphQLError.d.ts | 13 +- types/graphql/execution/execute.d.ts | 23 ++-- types/graphql/execution/values.d.ts | 5 +- types/graphql/graphql.d.ts | 19 +-- types/graphql/index.d.ts | 1 + types/graphql/language/visitor.d.ts | 3 +- types/graphql/subscription/subscribe.d.ts | 21 +-- types/graphql/tsconfig.json | 4 +- types/graphql/tsutils/Maybe.d.ts | 4 + types/graphql/type/definition.d.ts | 129 +++++++++--------- types/graphql/type/directives.d.ts | 11 +- types/graphql/type/schema.d.ts | 27 ++-- types/graphql/utilities/TypeInfo.d.ts | 20 +-- types/graphql/utilities/astFromValue.d.ts | 3 +- types/graphql/utilities/buildASTSchema.d.ts | 5 +- types/graphql/utilities/getOperationAST.d.ts | 5 +- .../graphql/utilities/introspectionQuery.d.ts | 31 +++-- types/graphql/utilities/valueFromAST.d.ts | 5 +- .../utilities/valueFromASTUntyped.d.ts | 3 +- .../graphql/validation/ValidationContext.d.ts | 23 ++-- .../rules/NoUndefinedVariables.d.ts | 3 +- .../validation/rules/NoUnusedVariables.d.ts | 3 +- .../rules/SingleFieldSubscriptions.d.ts | 3 +- 23 files changed, 197 insertions(+), 167 deletions(-) create mode 100644 types/graphql/tsutils/Maybe.d.ts diff --git a/types/graphql/error/GraphQLError.d.ts b/types/graphql/error/GraphQLError.d.ts index 0be931bee0..ce31564fb1 100644 --- a/types/graphql/error/GraphQLError.d.ts +++ b/types/graphql/error/GraphQLError.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { getLocation } from "../language"; import { ASTNode } from "../language/ast"; import { Source } from "../language/source"; @@ -58,7 +59,7 @@ export class GraphQLError extends Error { /** * The original error thrown from a field resolver during execution. */ - readonly originalError: Error | void; + readonly originalError: Maybe; /** * Extension fields to add to the formatted error. @@ -68,10 +69,10 @@ export class GraphQLError extends Error { constructor( message: string, nodes?: ReadonlyArray | ASTNode | undefined, - source?: Source | void, - positions?: ReadonlyArray | void, - path?: ReadonlyArray | void, - originalError?: Error | void, - extensions?: { [key: string]: any } | void + source?: Maybe, + positions?: Maybe>, + path?: Maybe>, + originalError?: Maybe, + extensions?: Maybe<{ [key: string]: any }> ); } diff --git a/types/graphql/execution/execute.d.ts b/types/graphql/execution/execute.d.ts index 424bb62b5a..7ef4d5ce63 100644 --- a/types/graphql/execution/execute.d.ts +++ b/types/graphql/execution/execute.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLError, locatedError } from "../error"; import { GraphQLSchema } from "../type/schema"; import { @@ -51,9 +52,9 @@ export type ExecutionArgs = { document: DocumentNode; rootValue?: any; contextValue?: any; - variableValues?: { [key: string]: any } | void; - operationName?: string | void; - fieldResolver?: GraphQLFieldResolver | void; + variableValues?: Maybe<{ [key: string]: any }>; + operationName?: Maybe; + fieldResolver?: Maybe>; }; /** @@ -74,9 +75,9 @@ export function execute( document: DocumentNode, rootValue?: any, contextValue?: any, - variableValues?: { [key: string]: any } | void, - operationName?: string | void, - fieldResolver?: GraphQLFieldResolver | void + variableValues?: Maybe<{ [key: string]: any }>, + operationName?: Maybe, + fieldResolver?: Maybe> ): MaybePromise; /** @@ -101,7 +102,7 @@ export function addPath( export function assertValidExecutionArguments( schema: GraphQLSchema, document: DocumentNode, - rawVariableValues: { [key: string]: any } | void + rawVariableValues: Maybe<{ [key: string]: any }> ): void; /** @@ -115,9 +116,9 @@ export function buildExecutionContext( document: DocumentNode, rootValue: any, contextValue: any, - rawVariableValues: { [key: string]: any } | void, - operationName: string | void, - fieldResolver: GraphQLFieldResolver | void + rawVariableValues: Maybe<{ [key: string]: any }>, + operationName: Maybe, + fieldResolver: Maybe> ): ReadonlyArray | ExecutionContext; /** @@ -181,4 +182,4 @@ export function getFieldDef( schema: GraphQLSchema, parentType: GraphQLObjectType, fieldName: string -): GraphQLField | void; +): Maybe>; diff --git a/types/graphql/execution/values.d.ts b/types/graphql/execution/values.d.ts index fb629325e8..e3cb7eb4bc 100644 --- a/types/graphql/execution/values.d.ts +++ b/types/graphql/execution/values.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLError } from "../error"; import { GraphQLInputType, GraphQLField, GraphQLArgument } from "../type/definition"; import { GraphQLDirective } from "../type/directives"; @@ -35,7 +36,7 @@ export function getVariableValues( export function getArgumentValues( def: GraphQLField | GraphQLDirective, node: FieldNode | DirectiveNode, - variableValues?: { [key: string]: any } | void + variableValues?: Maybe<{ [key: string]: any }> ): { [key: string]: any }; /** @@ -54,5 +55,5 @@ export function getDirectiveValues( node: { readonly directives?: ReadonlyArray; }, - variableValues?: { [key: string]: any } | void + variableValues?: Maybe<{ [key: string]: any }> ): undefined | { [key: string]: any }; diff --git a/types/graphql/graphql.d.ts b/types/graphql/graphql.d.ts index 7282ea80f2..59dc3918f1 100644 --- a/types/graphql/graphql.d.ts +++ b/types/graphql/graphql.d.ts @@ -1,3 +1,4 @@ +import Maybe from "./tsutils/Maybe"; import { Source } from "./language/source"; import { GraphQLFieldResolver } from "./type/definition"; import { GraphQLSchema } from "./type/schema"; @@ -38,9 +39,9 @@ export interface GraphQLArgs { source: Source | string; rootValue?: any; contextValue?: any; - variableValues?: { [key: string]: any } | void; - operationName?: string | void; - fieldResolver?: GraphQLFieldResolver | void; + variableValues?: Maybe<{ [key: string]: any }>; + operationName?: Maybe; + fieldResolver?: Maybe>; } export function graphql(args: GraphQLArgs): Promise; @@ -49,9 +50,9 @@ export function graphql( source: Source | string, rootValue?: any, contextValue?: any, - variableValues?: { [key: string]: any } | void, - operationName?: string | void, - fieldResolver?: GraphQLFieldResolver | void + variableValues?: Maybe<{ [key: string]: any }>, + operationName?: Maybe, + fieldResolver?: Maybe> ): Promise; /** @@ -66,7 +67,7 @@ export function graphqlSync( source: Source | string, rootValue?: any, contextValue?: any, - variableValues?: { [key: string]: any } | void, - operationName?: string | void, - fieldResolver?: GraphQLFieldResolver | void + variableValues?: Maybe<{ [key: string]: any }>, + operationName?: Maybe, + fieldResolver?: Maybe> ): ExecutionResult; diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index 68e04d104d..ba9213b7c4 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -13,6 +13,7 @@ // Dylan Stewart // Alessio Dionisi // Divyendu Singh +// Brad Zacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/graphql/language/visitor.d.ts b/types/graphql/language/visitor.d.ts index a137fa318e..be50e6e02e 100644 --- a/types/graphql/language/visitor.d.ts +++ b/types/graphql/language/visitor.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { ASTNode, ASTKindToNode } from "./ast"; import { TypeInfo } from "../utilities/TypeInfo"; @@ -157,4 +158,4 @@ export function visitWithTypeInfo(typeInfo: TypeInfo, visitor: Visitor, kind: string, isLeaving: boolean): VisitFn | void; +export function getVisitFn(visitor: Visitor, kind: string, isLeaving: boolean): Maybe>; diff --git a/types/graphql/subscription/subscribe.d.ts b/types/graphql/subscription/subscribe.d.ts index a9fe6b565e..f5b29ebbb8 100644 --- a/types/graphql/subscription/subscribe.d.ts +++ b/types/graphql/subscription/subscribe.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLSchema } from "../type/schema"; import { DocumentNode } from "../language/ast"; import { GraphQLFieldResolver } from "../type/definition"; @@ -28,10 +29,10 @@ export function subscribe(args: { document: DocumentNode; rootValue?: any; contextValue?: any; - variableValues?: { [key: string]: any } | void; - operationName?: string | void; - fieldResolver?: GraphQLFieldResolver | void; - subscribeFieldResolver?: GraphQLFieldResolver | void; + variableValues?: Maybe<{ [key: string]: any }>; + operationName?: Maybe; + fieldResolver?: Maybe>; + subscribeFieldResolver?: Maybe>; }): Promise | ExecutionResult>; export function subscribe( @@ -39,10 +40,10 @@ export function subscribe( document: DocumentNode, rootValue?: any, contextValue?: any, - variableValues?: { [key: string]: any } | void, - operationName?: string | void, - fieldResolver?: GraphQLFieldResolver | void, - subscribeFieldResolver?: GraphQLFieldResolver | void + variableValues?: Maybe<{ [key: string]: any }>, + operationName?: Maybe, + fieldResolver?: Maybe>, + subscribeFieldResolver?: Maybe> ): Promise | ExecutionResult>; /** @@ -69,6 +70,6 @@ export function createSourceEventStream( rootValue?: any, contextValue?: any, variableValues?: { [key: string]: any }, - operationName?: string | void, - fieldResolver?: GraphQLFieldResolver | void + operationName?: Maybe, + fieldResolver?: Maybe> ): Promise | ExecutionResult>; diff --git a/types/graphql/tsconfig.json b/types/graphql/tsconfig.json index 72f0de0665..3bc66f8bea 100644 --- a/types/graphql/tsconfig.json +++ b/types/graphql/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -21,4 +21,4 @@ "index.d.ts", "graphql-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/graphql/tsutils/Maybe.d.ts b/types/graphql/tsutils/Maybe.d.ts new file mode 100644 index 0000000000..7ad0bc85a4 --- /dev/null +++ b/types/graphql/tsutils/Maybe.d.ts @@ -0,0 +1,4 @@ +// Conveniently represents flow's "Maybe" type https://flow.org/en/docs/types/maybe/ +type Maybe = null | undefined | T + +export default Maybe diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index ed87af50ad..b078acccb1 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { MaybePromise } from "../jsutils/MaybePromise"; import { ScalarTypeDefinitionNode, @@ -254,8 +255,8 @@ export type Thunk = (() => T) | T; */ export class GraphQLScalarType { name: string; - description: string | void; - astNode?: ScalarTypeDefinitionNode | void; + description: Maybe; + astNode?: Maybe; constructor(config: GraphQLScalarTypeConfig); // Serializes an internal value to include in a response. @@ -265,7 +266,7 @@ export class GraphQLScalarType { parseValue(value: any): any; // Parses an externally provided literal value to use as an input. - parseLiteral(valueNode: ValueNode, variables?: { [key: string]: any } | void): any; + parseLiteral(valueNode: ValueNode, variables?: Maybe<{ [key: string]: any }>): any; toString(): string; toJSON(): string; @@ -274,11 +275,11 @@ export class GraphQLScalarType { export interface GraphQLScalarTypeConfig { name: string; - description?: string | void; - astNode?: ScalarTypeDefinitionNode | void; - serialize(value: any): TExternal | void; - parseValue?(value: any): TInternal | void; - parseLiteral?(valueNode: ValueNode, variables: { [key: string]: any } | void): TInternal | void; + description?: Maybe; + astNode?: Maybe; + serialize(value: any): Maybe; + parseValue?(value: any): Maybe; + parseLiteral?(valueNode: ValueNode, variables: Maybe<{ [key: string]: any }>): Maybe; } /** @@ -320,10 +321,10 @@ export interface GraphQLScalarTypeConfig { */ export class GraphQLObjectType { name: string; - description: string | void; - astNode: ObjectTypeDefinitionNode | void; - extensionASTNodes: ReadonlyArray | void; - isTypeOf: GraphQLIsTypeOfFn | void; + description: Maybe; + astNode: Maybe; + extensionASTNodes: Maybe>; + isTypeOf: Maybe>; constructor(config: GraphQLObjectTypeConfig); getFields(): GraphQLFieldMap; @@ -335,19 +336,19 @@ export class GraphQLObjectType { export interface GraphQLObjectTypeConfig { name: string; - interfaces?: Thunk; + interfaces?: Thunk>; fields: Thunk>; - isTypeOf?: GraphQLIsTypeOfFn | void; - description?: string | void; - astNode?: ObjectTypeDefinitionNode | void; - extensionASTNodes?: ReadonlyArray | void; + isTypeOf?: Maybe>; + description?: Maybe; + astNode?: Maybe; + extensionASTNodes?: Maybe>; } export type GraphQLTypeResolver = ( value: TSource, context: TContext, info: GraphQLResolveInfo -) => MaybePromise; +) => MaybePromise>; export type GraphQLIsTypeOfFn = ( source: TSource, @@ -385,9 +386,9 @@ export interface GraphQLFieldConfig; subscribe?: GraphQLFieldResolver; - deprecationReason?: string | void; - description?: string | void; - astNode?: FieldDefinitionNode | void; + deprecationReason?: Maybe; + description?: Maybe; + astNode?: Maybe; } export type GraphQLFieldConfigArgumentMap = { [key: string]: GraphQLArgumentConfig }; @@ -395,8 +396,8 @@ export type GraphQLFieldConfigArgumentMap = { [key: string]: GraphQLArgumentConf export interface GraphQLArgumentConfig { type: GraphQLInputType; defaultValue?: any; - description?: string | void; - astNode?: InputValueDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export type GraphQLFieldConfigMap = { @@ -405,22 +406,22 @@ export type GraphQLFieldConfigMap = { export interface GraphQLField { name: string; - description: string | void; + description: Maybe; type: GraphQLOutputType; args: GraphQLArgument[]; resolve?: GraphQLFieldResolver; subscribe?: GraphQLFieldResolver; isDeprecated?: boolean; - deprecationReason?: string | void; - astNode?: FieldDefinitionNode | void; + deprecationReason?: Maybe; + astNode?: Maybe; } export interface GraphQLArgument { name: string; type: GraphQLInputType; defaultValue?: any; - description?: string | void; - astNode?: InputValueDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export type GraphQLFieldMap = { @@ -447,10 +448,10 @@ export type GraphQLFieldMap = { */ export class GraphQLInterfaceType { name: string; - description: string | void; - astNode?: InterfaceTypeDefinitionNode | void; - extensionASTNodes: ReadonlyArray | void; - resolveType: GraphQLTypeResolver | void; + description: Maybe; + astNode?: Maybe; + extensionASTNodes: Maybe>; + resolveType: Maybe>; constructor(config: GraphQLInterfaceTypeConfig); @@ -469,10 +470,10 @@ export interface GraphQLInterfaceTypeConfig { * the default implementation will call `isTypeOf` on each implementing * Object type. */ - resolveType?: GraphQLTypeResolver | void; - description?: string | void; - astNode?: InterfaceTypeDefinitionNode | void; - extensionASTNodes?: ReadonlyArray | void; + resolveType?: Maybe>; + description?: Maybe; + astNode?: Maybe; + extensionASTNodes?: Maybe>; } /** @@ -500,9 +501,9 @@ export interface GraphQLInterfaceTypeConfig { */ export class GraphQLUnionType { name: string; - description: string | void; - astNode?: UnionTypeDefinitionNode | void; - resolveType: GraphQLTypeResolver | void; + description: Maybe; + astNode?: Maybe; + resolveType: Maybe>; constructor(config: GraphQLUnionTypeConfig); @@ -521,9 +522,9 @@ export interface GraphQLUnionTypeConfig { * the default implementation will call `isTypeOf` on each implementing * Object type. */ - resolveType?: GraphQLTypeResolver | void; - description?: string | void; - astNode?: UnionTypeDefinitionNode | void; + resolveType?: Maybe>; + description?: Maybe; + astNode?: Maybe; } /** @@ -549,15 +550,15 @@ export interface GraphQLUnionTypeConfig { */ export class GraphQLEnumType { name: string; - description: string | void; - astNode: EnumTypeDefinitionNode | void; + description: Maybe; + astNode: Maybe; constructor(config: GraphQLEnumTypeConfig); getValues(): GraphQLEnumValue[]; - getValue(name: string): GraphQLEnumValue | void; - serialize(value: any): string | void; - parseValue(value: any): any; - parseLiteral(valueNode: ValueNode, _variables: { [key: string]: any } | void): any; + getValue(name: string): Maybe; + serialize(value: any): Maybe; + parseValue(value: any): Maybe; + parseLiteral(valueNode: ValueNode, _variables: Maybe<{ [key: string]: any }>): Maybe; toString(): string; toJSON(): string; inspect(): string; @@ -566,25 +567,25 @@ export class GraphQLEnumType { export interface GraphQLEnumTypeConfig { name: string; values: GraphQLEnumValueConfigMap; - description?: string | void; - astNode?: EnumTypeDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export type GraphQLEnumValueConfigMap = { [key: string]: GraphQLEnumValueConfig }; export interface GraphQLEnumValueConfig { value?: any; - deprecationReason?: string | void; - description?: string | void; - astNode?: EnumValueDefinitionNode | void; + deprecationReason?: Maybe; + description?: Maybe; + astNode?: Maybe; } export interface GraphQLEnumValue { name: string; - description: string | void; + description: Maybe; isDeprecated?: boolean; - deprecationReason: string | void; - astNode?: EnumValueDefinitionNode | void; + deprecationReason: Maybe; + astNode?: Maybe; value: any; } @@ -610,8 +611,8 @@ export interface GraphQLEnumValue { */ export class GraphQLInputObjectType { name: string; - description: string | void; - astNode: InputObjectTypeDefinitionNode | void; + description: Maybe; + astNode: Maybe; constructor(config: GraphQLInputObjectTypeConfig); getFields(): GraphQLInputFieldMap; toString(): string; @@ -622,15 +623,15 @@ export class GraphQLInputObjectType { export interface GraphQLInputObjectTypeConfig { name: string; fields: Thunk; - description?: string | void; - astNode?: InputObjectTypeDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export interface GraphQLInputFieldConfig { type: GraphQLInputType; defaultValue?: any; - description?: string | void; - astNode?: InputValueDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export type GraphQLInputFieldConfigMap = { @@ -641,8 +642,8 @@ export interface GraphQLInputField { name: string; type: GraphQLInputType; defaultValue?: any; - description?: string | void; - astNode?: InputValueDefinitionNode | void; + description?: Maybe; + astNode?: Maybe; } export type GraphQLInputFieldMap = { [key: string]: GraphQLInputField }; diff --git a/types/graphql/type/directives.d.ts b/types/graphql/type/directives.d.ts index f6e19f674d..ca9e947640 100644 --- a/types/graphql/type/directives.d.ts +++ b/types/graphql/type/directives.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLFieldConfigArgumentMap, GraphQLArgument } from "./definition"; import { DirectiveDefinitionNode } from "../language/ast"; import { DirectiveLocationEnum } from "../language/directiveLocation"; @@ -13,20 +14,20 @@ export function isDirective(directive: any): directive is GraphQLDirective; */ export class GraphQLDirective { name: string; - description: string | void; + description: Maybe; locations: DirectiveLocationEnum[]; args: GraphQLArgument[]; - astNode: DirectiveDefinitionNode | void; + astNode: Maybe; constructor(config: GraphQLDirectiveConfig); } export interface GraphQLDirectiveConfig { name: string; - description?: string | void; + description?: Maybe; locations: DirectiveLocationEnum[]; - args?: GraphQLFieldConfigArgumentMap | void; - astNode?: DirectiveDefinitionNode | void; + args?: Maybe; + astNode?: Maybe; } /** diff --git a/types/graphql/type/schema.d.ts b/types/graphql/type/schema.d.ts index a7bb94f5c5..b5ddc9d8d4 100644 --- a/types/graphql/type/schema.d.ts +++ b/types/graphql/type/schema.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLObjectType } from "./definition"; import { GraphQLType, GraphQLNamedType, GraphQLAbstractType } from "./definition"; import { SchemaDefinitionNode } from "../language/ast"; @@ -35,21 +36,21 @@ export function isSchema(schema: any): schema is GraphQLSchema; * */ export class GraphQLSchema { - astNode: SchemaDefinitionNode | void; + astNode: Maybe; constructor(config: GraphQLSchemaConfig); - getQueryType(): GraphQLObjectType | void; - getMutationType(): GraphQLObjectType | void; - getSubscriptionType(): GraphQLObjectType | void; + getQueryType(): Maybe; + getMutationType(): Maybe; + getSubscriptionType(): Maybe; getTypeMap(): TypeMap; - getType(name: string): GraphQLNamedType | void; + getType(name: string): Maybe; getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray; isPossibleType(abstractType: GraphQLAbstractType, possibleType: GraphQLObjectType): boolean; getDirectives(): ReadonlyArray; - getDirective(name: string): GraphQLDirective | void; + getDirective(name: string): Maybe; } type TypeMap = { [key: string]: GraphQLNamedType }; @@ -72,14 +73,14 @@ export interface GraphQLSchemaValidationOptions { * This option is provided to ease adoption and may be removed in a future * major release. */ - allowedLegacyNames?: ReadonlyArray | void; + allowedLegacyNames?: Maybe>; } export interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions { - query: GraphQLObjectType | void; - mutation?: GraphQLObjectType | void; - subscription?: GraphQLObjectType | void; - types?: GraphQLNamedType[] | void; - directives?: GraphQLDirective[] | void; - astNode?: SchemaDefinitionNode | void; + query: Maybe; + mutation?: Maybe; + subscription?: Maybe; + types?: Maybe; + directives?: Maybe; + astNode?: Maybe; } diff --git a/types/graphql/utilities/TypeInfo.d.ts b/types/graphql/utilities/TypeInfo.d.ts index 1c2f139642..826704a52b 100644 --- a/types/graphql/utilities/TypeInfo.d.ts +++ b/types/graphql/utilities/TypeInfo.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLSchema } from "../type/schema"; import { GraphQLOutputType, @@ -28,14 +29,15 @@ export class TypeInfo { initialType?: GraphQLType ); - getType(): GraphQLOutputType | void; - getParentType(): GraphQLCompositeType | void; - getInputType(): GraphQLInputType | void; - getParentInputType(): GraphQLInputType | void; - getFieldDef(): GraphQLField | void; - getDirective(): GraphQLDirective | void; - getArgument(): GraphQLArgument | void; - getEnumValue(): GraphQLEnumValue | void; + getType(): Maybe; + getParentType(): Maybe; + getInputType(): Maybe; + getParentInputType(): Maybe; + getFieldDef(): GraphQLField>; + getDefaultValue(): Maybe; + getDirective(): Maybe; + getArgument(): Maybe; + getEnumValue(): Maybe; enter(node: ASTNode): any; leave(node: ASTNode): any; } @@ -44,4 +46,4 @@ type getFieldDef = ( schema: GraphQLSchema, parentType: GraphQLType, fieldNode: FieldNode -) => GraphQLField | void; +) => Maybe>; diff --git a/types/graphql/utilities/astFromValue.d.ts b/types/graphql/utilities/astFromValue.d.ts index 9c2198e6d6..e6c9f1ba6c 100644 --- a/types/graphql/utilities/astFromValue.d.ts +++ b/types/graphql/utilities/astFromValue.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { ValueNode } from "../language/ast"; import { GraphQLInputType } from "../type/definition"; @@ -18,4 +19,4 @@ import { GraphQLInputType } from "../type/definition"; * | null | NullValue | * */ -export function astFromValue(value: any, type: GraphQLInputType): ValueNode | void; +export function astFromValue(value: any, type: GraphQLInputType): Maybe; diff --git a/types/graphql/utilities/buildASTSchema.d.ts b/types/graphql/utilities/buildASTSchema.d.ts index ebff50b4f7..e2406c7ee1 100644 --- a/types/graphql/utilities/buildASTSchema.d.ts +++ b/types/graphql/utilities/buildASTSchema.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { DocumentNode, Location, @@ -47,7 +48,7 @@ type TypeDefinitionsMap = { [key: string]: TypeDefinitionNode }; type TypeResolver = (typeRef: NamedTypeNode) => GraphQLNamedType; export class ASTDefinitionBuilder { - constructor(typeDefinitionsMap: TypeDefinitionsMap, options: BuildSchemaOptions | void, resolveType: TypeResolver); + constructor(typeDefinitionsMap: TypeDefinitionsMap, options: Maybe, resolveType: TypeResolver); buildTypes(nodes: ReadonlyArray): Array; @@ -69,7 +70,7 @@ export class ASTDefinitionBuilder { */ export function getDescription( node: { readonly description?: StringValueNode; readonly loc?: Location }, - options: BuildSchemaOptions | void + options: Maybe ): string | undefined; /** diff --git a/types/graphql/utilities/getOperationAST.d.ts b/types/graphql/utilities/getOperationAST.d.ts index 81e9bd4cbe..a36cfa139c 100644 --- a/types/graphql/utilities/getOperationAST.d.ts +++ b/types/graphql/utilities/getOperationAST.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { DocumentNode, OperationDefinitionNode } from "../language/ast"; /** @@ -7,5 +8,5 @@ import { DocumentNode, OperationDefinitionNode } from "../language/ast"; */ export function getOperationAST( documentAST: DocumentNode, - operationName: string | void -): OperationDefinitionNode | void; + operationName: Maybe +): Maybe; diff --git a/types/graphql/utilities/introspectionQuery.d.ts b/types/graphql/utilities/introspectionQuery.d.ts index 750fe0d99c..f2172595f8 100644 --- a/types/graphql/utilities/introspectionQuery.d.ts +++ b/types/graphql/utilities/introspectionQuery.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { DirectiveLocationEnum } from "../language/directiveLocation"; export interface IntrospectionOptions { @@ -16,8 +17,8 @@ export interface IntrospectionQuery { export interface IntrospectionSchema { readonly queryType: IntrospectionNamedTypeRef; - readonly mutationType: IntrospectionNamedTypeRef | void; - readonly subscriptionType: IntrospectionNamedTypeRef | void; + readonly mutationType: Maybe>; + readonly subscriptionType: Maybe>; readonly types: ReadonlyArray; readonly directives: ReadonlyArray; } @@ -42,13 +43,13 @@ export type IntrospectionInputType = IntrospectionScalarType | IntrospectionEnum export interface IntrospectionScalarType { readonly kind: "SCALAR"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; } export interface IntrospectionObjectType { readonly kind: "OBJECT"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly fields: ReadonlyArray; readonly interfaces: ReadonlyArray>; } @@ -56,7 +57,7 @@ export interface IntrospectionObjectType { export interface IntrospectionInterfaceType { readonly kind: "INTERFACE"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly fields: ReadonlyArray; readonly possibleTypes: ReadonlyArray>; } @@ -64,21 +65,21 @@ export interface IntrospectionInterfaceType { export interface IntrospectionUnionType { readonly kind: "UNION"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly possibleTypes: ReadonlyArray>; } export interface IntrospectionEnumType { readonly kind: "ENUM"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly enumValues: ReadonlyArray; } export interface IntrospectionInputObjectType { readonly kind: "INPUT_OBJECT"; readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly inputFields: ReadonlyArray; } @@ -114,30 +115,30 @@ export interface IntrospectionNamedTypeRef; readonly args: ReadonlyArray; readonly type: IntrospectionOutputTypeRef; readonly isDeprecated: boolean; - readonly deprecationReason?: string | void; + readonly deprecationReason?: Maybe; } export interface IntrospectionInputValue { readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly type: IntrospectionInputTypeRef; - readonly defaultValue?: string | void; + readonly defaultValue?: Maybe; } export interface IntrospectionEnumValue { readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly isDeprecated: boolean; - readonly deprecationReason?: string | void; + readonly deprecationReason?: Maybe; } export interface IntrospectionDirective { readonly name: string; - readonly description?: string | void; + readonly description?: Maybe; readonly locations: ReadonlyArray; readonly args: ReadonlyArray; } diff --git a/types/graphql/utilities/valueFromAST.d.ts b/types/graphql/utilities/valueFromAST.d.ts index cd67108aad..c95eca9002 100644 --- a/types/graphql/utilities/valueFromAST.d.ts +++ b/types/graphql/utilities/valueFromAST.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLInputType } from "../type/definition"; import { ValueNode, VariableNode, ListValueNode, ObjectValueNode } from "../language/ast"; @@ -22,7 +23,7 @@ import { ValueNode, VariableNode, ListValueNode, ObjectValueNode } from "../lang * */ export function valueFromAST( - valueNode: ValueNode | void, + valueNode: Maybe, type: GraphQLInputType, - variables?: { [key: string]: any } | void + variables?: Maybe<{ [key: string]: any }> ): any; diff --git a/types/graphql/utilities/valueFromASTUntyped.d.ts b/types/graphql/utilities/valueFromASTUntyped.d.ts index 98d3137694..4ca58ca867 100644 --- a/types/graphql/utilities/valueFromASTUntyped.d.ts +++ b/types/graphql/utilities/valueFromASTUntyped.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { ValueNode } from "../language/ast"; /** @@ -16,4 +17,4 @@ import { ValueNode } from "../language/ast"; * | Null | null | * */ -export function valueFromASTUntyped(valueNode: ValueNode, variables?: { [key: string]: any } | void): any; +export function valueFromASTUntyped(valueNode: ValueNode, variables?: Maybe<{ [key: string]: any }>): any; diff --git a/types/graphql/validation/ValidationContext.d.ts b/types/graphql/validation/ValidationContext.d.ts index 0f8a4ea8f7..24049decdf 100644 --- a/types/graphql/validation/ValidationContext.d.ts +++ b/types/graphql/validation/ValidationContext.d.ts @@ -1,3 +1,4 @@ +import Maybe from "../tsutils/Maybe"; import { GraphQLError } from "../error"; import { DocumentNode, @@ -19,7 +20,11 @@ import { GraphQLDirective } from "../type/directives"; import { TypeInfo } from "../utilities/TypeInfo"; type NodeWithSelectionSet = OperationDefinitionNode | FragmentDefinitionNode; -type VariableUsage = { node: VariableNode; type: GraphQLInputType | void }; +type VariableUsage = { + readonly node: VariableNode; + readonly type: Maybe; + readonly defaultValue: Maybe; +}; /** * An instance of this class is passed as the "this" context to all validators, @@ -37,7 +42,7 @@ export default class ValidationContext { getDocument(): DocumentNode; - getFragment(name: string): FragmentDefinitionNode | void; + getFragment(name: string): Maybe; getFragmentSpreads(node: SelectionSetNode): ReadonlyArray; @@ -47,17 +52,17 @@ export default class ValidationContext { getRecursiveVariableUsages(operation: OperationDefinitionNode): ReadonlyArray; - getType(): GraphQLOutputType | void; + getType(): Maybe; - getParentType(): GraphQLCompositeType | void; + getParentType(): Maybe; - getInputType(): GraphQLInputType | void; + getInputType(): Maybe; - getParentInputType(): GraphQLInputType | void; + getParentInputType(): Maybe; - getFieldDef(): GraphQLField | void; + getFieldDef(): Maybe>; - getDirective(): GraphQLDirective | void; + getDirective(): Maybe; - getArgument(): GraphQLArgument | void; + getArgument(): Maybe; } diff --git a/types/graphql/validation/rules/NoUndefinedVariables.d.ts b/types/graphql/validation/rules/NoUndefinedVariables.d.ts index 611ad01a9b..f340b41ad8 100644 --- a/types/graphql/validation/rules/NoUndefinedVariables.d.ts +++ b/types/graphql/validation/rules/NoUndefinedVariables.d.ts @@ -1,7 +1,8 @@ +import Maybe from "../../tsutils/Maybe"; import ValidationContext from "../ValidationContext"; import { ASTVisitor } from "../../language/visitor"; -export function undefinedVarMessage(varName: string, opName: string | void): string; +export function undefinedVarMessage(varName: string, opName: Maybe): string; /** * No undefined variables diff --git a/types/graphql/validation/rules/NoUnusedVariables.d.ts b/types/graphql/validation/rules/NoUnusedVariables.d.ts index 10282cdacd..1846995a1f 100644 --- a/types/graphql/validation/rules/NoUnusedVariables.d.ts +++ b/types/graphql/validation/rules/NoUnusedVariables.d.ts @@ -1,7 +1,8 @@ +import Maybe from "../../tsutils/Maybe"; import ValidationContext from "../ValidationContext"; import { ASTVisitor } from "../../language/visitor"; -export function unusedVariableMessage(varName: string, opName: string | void): string; +export function unusedVariableMessage(varName: string, opName: Maybe): string; /** * No unused variables diff --git a/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts b/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts index fef0869710..54b1fec36a 100644 --- a/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts +++ b/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts @@ -1,7 +1,8 @@ +import Maybe from "../../tsutils/Maybe"; import ValidationContext from "../ValidationContext"; import { ASTVisitor } from "../../language/visitor"; -export function singleFieldOnlyMessage(name: string | void): string; +export function singleFieldOnlyMessage(name: Maybe): string; /** * Subscriptions must only include one field. From 6280a2d5e928cc9318ed39fa972e411a9dad713e Mon Sep 17 00:00:00 2001 From: Patrick Simmelbauer Date: Thu, 10 May 2018 21:59:07 +0200 Subject: [PATCH 08/19] Add missing parameter to findWrapping (#25678) --- types/prosemirror-transform/index.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/types/prosemirror-transform/index.d.ts b/types/prosemirror-transform/index.d.ts index e74fd9c094..88f97ff9e4 100644 --- a/types/prosemirror-transform/index.d.ts +++ b/types/prosemirror-transform/index.d.ts @@ -509,12 +509,15 @@ export function liftTarget(range: NodeRange): number | null | undefined; * Try to find a valid way to wrap the content in the given range in a * node of the given type. May introduce extra nodes around and inside * the wrapper node, if necessary. Returns null if no valid wrapping - * could be found. + * could be found. When `innerRange` is given, that range's content is + * used as the content to fit into the wrapping, instead of the + * content of range. */ export function findWrapping( range: NodeRange, nodeType: NodeType, - attrs?: { [key: string]: any } + attrs?: { [key: string]: any }, + innerRange?: NodeRange ): Array<{ type: NodeType; attrs?: { [key: string]: any } | null }> | null | undefined; /** * Check whether splitting at the given position is allowed. From ef4570ef0ab345157cbd8adfd9eeb2bb9ff00480 Mon Sep 17 00:00:00 2001 From: Daniel van der Merwe Date: Thu, 10 May 2018 15:59:44 -0400 Subject: [PATCH 09/19] SingleScreenApp can take an appStyle param (#25562) This is undocumented but works --- types/react-native-navigation/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/react-native-navigation/index.d.ts b/types/react-native-navigation/index.d.ts index 75c0d51be0..86b94bff44 100644 --- a/types/react-native-navigation/index.d.ts +++ b/types/react-native-navigation/index.d.ts @@ -64,6 +64,11 @@ export interface SingleScreenApp { drawer?: Drawer; passProps?: object; animationType?: 'none' | 'slide-down' | 'fade'; + appStyle?: { + orientation?: 'auto' | 'landscape' | 'portrait'; + backButtonImage?: any; + hideBackButtonTitle?: boolean; + }; } export interface Screen { From 44252be6abe6d293f75af624d8a478313db666f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lavur=20Debes=20Joensen?= Date: Thu, 10 May 2018 22:00:01 +0200 Subject: [PATCH 10/19] Fix typo fullWdith -> fullWidth (#25676) --- types/chart.js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index 90f6de10a7..04d2e182ee 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -221,7 +221,7 @@ declare namespace Chart { interface ChartTitleOptions { display?: boolean; position?: PositionType; - fullWdith?: boolean; + fullWidth?: boolean; fontSize?: number; fontFamily?: string; fontColor?: ChartColor; From 7531e4e98e9751f20ceb80f8a25d5d8312cb4d41 Mon Sep 17 00:00:00 2001 From: Brian Crowell Date: Thu, 10 May 2018 15:01:14 -0500 Subject: [PATCH 11/19] [natural-sort] Make definitions and tests match module (#25670) The module is a function that takes options and returns a sort function. It is not the sort function itself. The sort function also works on any mixture of numbers and strings, as the module's own usage examples show. The tests are just the usage examples verbatim. --- types/natural-sort/index.d.ts | 11 ++++++++++- types/natural-sort/natural-sort-tests.ts | 7 +++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/types/natural-sort/index.d.ts b/types/natural-sort/index.d.ts index 4e929d4edc..3a88919a25 100644 --- a/types/natural-sort/index.d.ts +++ b/types/natural-sort/index.d.ts @@ -1,9 +1,18 @@ // Type definitions for NaturalSort // Project: https://github.com/studio-b12/natural-sort // Definitions by: Antonio Morales +// Brian Crowell // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace naturalSort; -declare function naturalSort(a: T, b: T): number; +interface Options { + /** Set to true to make the sort case-sensitive. */ + caseSensitive?: boolean; + + /** Set to 'desc' to sort in reverse. */ + direction?: 'desc' +} + +declare function naturalSort(options?: Options): (a: string | number, b: string | number) => number; export = naturalSort; diff --git a/types/natural-sort/natural-sort-tests.ts b/types/natural-sort/natural-sort-tests.ts index b336542520..6218f4e796 100644 --- a/types/natural-sort/natural-sort-tests.ts +++ b/types/natural-sort/natural-sort-tests.ts @@ -1,5 +1,8 @@ import naturalSort = require("natural-sort"); -[5, 3, 2, 4, 1].sort(naturalSort); -["a", "c", "b", "z", "w", "l"].sort(naturalSort); +['10. tenth', 'odd', 1, '', '2. second'].sort(naturalSort()); +[3, 4, 1, 5, 2].sort(naturalSort({direction: 'desc'})); + +['a', 'B'].sort(naturalSort()); +['a', 'B'].sort(naturalSort({caseSensitive: true})); From 63b0e8b632fcd6c7eecb2debcb432a9580e4d213 Mon Sep 17 00:00:00 2001 From: Sinziana Nicolae Date: Thu, 10 May 2018 23:04:01 +0300 Subject: [PATCH 12/19] [react-dates] Add types in DayPickerRangeControllerShape (#25619) * Add types for daySize and verticalBorderSpacing in DayPickerRangeControllerShape * Change order of types --- types/react-dates/index.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/types/react-dates/index.d.ts b/types/react-dates/index.d.ts index f9444c1b7c..92fa68e8d7 100644 --- a/types/react-dates/index.d.ts +++ b/types/react-dates/index.d.ts @@ -166,7 +166,7 @@ declare namespace ReactDates { hideKeyboardShortcutsPanel?: boolean, daySize?: number, isRTL?: boolean, - verticalSpacing?: number, + verticalSpacing?: number, verticalHeight?: number| null, // navigation related props @@ -242,18 +242,20 @@ declare namespace ReactDates { renderCalendarInfo?: () => (string | JSX.Element), onOutsideClick?: (e: any) => void, keepOpenOnDateSelect?: boolean, + hideKeyboardShortcutsPanel?: boolean; noBorder?: boolean, + verticalBorderSpacing?: number, firstDayOfWeek? : 0 | 1 | 2 | 3 | 4 | 5 | 6, // navigation related props navPrev?: string | JSX.Element, navNext?: string | JSX.Element, - hideKeyboardShortcutsPanel?: boolean; onPrevMonthClick?: (newCurrentMonth: momentPropTypes.momentObj) => void, onNextMonthClick?: (newCurrentMonth: momentPropTypes.momentObj) => void, transitionDuration?: number, // day presentation and interaction related props + daySize?: number, renderCalendarDay?: (day: momentPropTypes.momentObj) => (string | JSX.Element), renderDayContents?: (day: momentPropTypes.momentObj) => (string | JSX.Element), minimumNights?: number, From d19c85c26e9cc95bb1153bf47bd7bd7b08be73d3 Mon Sep 17 00:00:00 2001 From: Vasily Nesterov Date: Fri, 11 May 2018 01:15:04 +0500 Subject: [PATCH 13/19] [react-google-maps-loader] Create type definitions (#25662) --- types/react-google-maps-loader/index.d.ts | 28 +++++++++++++++++++ .../react-google-maps-loader-tests.tsx | 23 +++++++++++++++ types/react-google-maps-loader/tsconfig.json | 25 +++++++++++++++++ types/react-google-maps-loader/tslint.json | 1 + 4 files changed, 77 insertions(+) create mode 100644 types/react-google-maps-loader/index.d.ts create mode 100644 types/react-google-maps-loader/react-google-maps-loader-tests.tsx create mode 100644 types/react-google-maps-loader/tsconfig.json create mode 100644 types/react-google-maps-loader/tslint.json diff --git a/types/react-google-maps-loader/index.d.ts b/types/react-google-maps-loader/index.d.ts new file mode 100644 index 0000000000..1bea9e2a9c --- /dev/null +++ b/types/react-google-maps-loader/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for react-google-maps-loader 4.2 +// Project: https://github.com/xuopled/react-google-maps-loader +// Definitions by: Vasily Nesterov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +/// +import { Component, ReactNode } from "react"; + +export default ReactGoogleMapsLoader; + +declare class ReactGoogleMapsLoader extends Component< + ReactGoogleMapsLoader.Props +> {} + +declare namespace ReactGoogleMapsLoader { + type GoogleMaps = typeof google.maps; + + interface Params { + key: string; + libraries?: string; + } + + interface Props { + params: Params; + render: (googleMaps: GoogleMaps, error?: string | null) => ReactNode; + } +} diff --git a/types/react-google-maps-loader/react-google-maps-loader-tests.tsx b/types/react-google-maps-loader/react-google-maps-loader-tests.tsx new file mode 100644 index 0000000000..e82c3f6038 --- /dev/null +++ b/types/react-google-maps-loader/react-google-maps-loader-tests.tsx @@ -0,0 +1,23 @@ +import * as React from "react"; +import ReactGoogleMapsLoader from "react-google-maps-loader"; + +const ReactGoogleMapsLoaderTest: React.SFC = () => ( +
} + /> +); + +const ReactGoogleMapsLoaderWithLibrariesTest: React.SFC = () => ( +
} + /> +); + +const ReactGoogleMapsLoaderWithErrorHandlerTest: React.SFC = () => ( +
{error}
} + /> +); diff --git a/types/react-google-maps-loader/tsconfig.json b/types/react-google-maps-loader/tsconfig.json new file mode 100644 index 0000000000..98ee7f63aa --- /dev/null +++ b/types/react-google-maps-loader/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "jsx": "react", + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-google-maps-loader-tests.tsx" + ] +} diff --git a/types/react-google-maps-loader/tslint.json b/types/react-google-maps-loader/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-google-maps-loader/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 5e47df0e65904edba6958ebabc852e90fecbf951 Mon Sep 17 00:00:00 2001 From: ryym Date: Fri, 11 May 2018 05:16:28 +0900 Subject: [PATCH 14/19] Add a link about major version update in 'Make a pull request' section (#25663) --- README.es.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.es.md b/README.es.md index ce94bb0298..c3cff967db 100644 --- a/README.es.md +++ b/README.es.md @@ -87,6 +87,7 @@ Primero, haz un [fork](https://guides.github.com/activities/forking/) en este re * `cd types/my-package-to-edit` * Haz cambios. Recuerda editar las pruebas. + Si realiza cambios importantes, no olvide [actualizar una versión principal](#quiero-actualizar-un-paquete-a-una-nueva-versión-principal). * También puede que quieras añadirte la sección "Definitions by" en el encabezado del paquete. - Esto hará que seas notificado (a través de tu nombre de usuario en GitHub) cada vez que alguien haga un pull request o issue sobre el paquete. - Haz esto añadiendo tu nombre al final de la línea, así como en `// Definitions by: Alice , Bob `. diff --git a/README.md b/README.md index 7c58fe8901..554316e52a 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ First, [fork](https://guides.github.com/activities/forking/) this repository, in * `cd types/my-package-to-edit` * Make changes. Remember to edit tests. + If you make breaking changes, do not forget to [update a major version](#i-want-to-update-a-package-to-a-new-major-version). * You may also want to add yourself to "Definitions by" section of the package header. - This will cause you to be notified (via your GitHub username) whenever someone makes a pull request or issue about the package. - Do this by adding your name to the end of the line, as in `// Definitions by: Alice , Bob `. From f0b4609d77ac319a9cf98f2805df39d98b07c63a Mon Sep 17 00:00:00 2001 From: Inaki Arroyo Date: Thu, 10 May 2018 21:19:38 +0100 Subject: [PATCH 15/19] deline types (#25666) --- types/deline/deline-tests.ts | 13 +++++++++++++ types/deline/index.d.ts | 6 ++++++ types/deline/tsconfig.json | 23 +++++++++++++++++++++++ types/deline/tslint.json | 1 + 4 files changed, 43 insertions(+) create mode 100644 types/deline/deline-tests.ts create mode 100644 types/deline/index.d.ts create mode 100644 types/deline/tsconfig.json create mode 100644 types/deline/tslint.json diff --git a/types/deline/deline-tests.ts b/types/deline/deline-tests.ts new file mode 100644 index 0000000000..35f1696484 --- /dev/null +++ b/types/deline/deline-tests.ts @@ -0,0 +1,13 @@ +import * as dl from "deline"; + +const moduleName = "deline"; + +dl.deline(`deline`); // $ExpectType string +dl.deline(`module name: ${moduleName}`); // $ExpectType string +dl.deline`deline`; // $ExpectType string +dl.deline`tagged template: ${moduleName}`; // $ExpectType string +dl.deline` +tagged template: + +${moduleName} +`; diff --git a/types/deline/index.d.ts b/types/deline/index.d.ts new file mode 100644 index 0000000000..b65cd80d5e --- /dev/null +++ b/types/deline/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for deline 1.0 +// Project: https://github.com/airbnb/deline#readme +// Definitions by: Inaki Arroyo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function deline(strings: string | TemplateStringsArray, ...values: any[]): string; diff --git a/types/deline/tsconfig.json b/types/deline/tsconfig.json new file mode 100644 index 0000000000..ae8ad2e876 --- /dev/null +++ b/types/deline/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "deline-tests.ts" + ] +} diff --git a/types/deline/tslint.json b/types/deline/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/deline/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 478994240a2e2bd5580ccb5d10e18146b39340f3 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 10 May 2018 13:24:02 -0700 Subject: [PATCH 16/19] Revert "Used a conditional type for Sinon's stub class typings (#25656)" (#25686) This reverts commit 49ecfa4536c9f5102cea2db42f750994c70b0a44. --- types/karma-chai-sinon/index.d.ts | 2 +- types/mochaccino/index.d.ts | 2 +- types/should-sinon/index.d.ts | 2 +- types/sinon-as-promised/index.d.ts | 2 +- types/sinon-chai/index.d.ts | 2 +- types/sinon-chrome/index.d.ts | 2 +- types/sinon-express-mock/index.d.ts | 2 +- types/sinon-mongoose/index.d.ts | 2 +- types/sinon-stub-promise/index.d.ts | 2 +- types/sinon-test/index.d.ts | 2 +- types/sinon/index.d.ts | 12 +++--------- types/sinon/sinon-tests.ts | 9 --------- 12 files changed, 13 insertions(+), 28 deletions(-) diff --git a/types/karma-chai-sinon/index.d.ts b/types/karma-chai-sinon/index.d.ts index 1ce2672b23..76ee313a40 100644 --- a/types/karma-chai-sinon/index.d.ts +++ b/types/karma-chai-sinon/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/tubalmartin/karma-chai-sinon // Definitions by: Václav Ostrožlík // Definitions: https://github.com/borisyankov/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.3 /// import Sinon = require("sinon"); diff --git a/types/mochaccino/index.d.ts b/types/mochaccino/index.d.ts index 3f0a2e9688..b230218ee9 100644 --- a/types/mochaccino/index.d.ts +++ b/types/mochaccino/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/pawelgalazka/mochaccino#readme // Definitions by: Thomas-P // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.3 import * as Sinon from "sinon"; export interface Expect { not: Expect; diff --git a/types/should-sinon/index.d.ts b/types/should-sinon/index.d.ts index 467d217aa9..25233c1c61 100644 --- a/types/should-sinon/index.d.ts +++ b/types/should-sinon/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/shouldjs/sinon // Definitions by: AryloYeung // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.3 import * as s from "sinon"; import should = require("should"); diff --git a/types/sinon-as-promised/index.d.ts b/types/sinon-as-promised/index.d.ts index 49e9b29bd3..097e13a1a0 100644 --- a/types/sinon-as-promised/index.d.ts +++ b/types/sinon-as-promised/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/bendrucker/sinon-as-promised // Definitions by: igrayson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.3 import * as s from "sinon"; diff --git a/types/sinon-chai/index.d.ts b/types/sinon-chai/index.d.ts index cff6d0b3a2..8c6d7eb2d0 100644 --- a/types/sinon-chai/index.d.ts +++ b/types/sinon-chai/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/domenic/sinon-chai // Definitions by: Kazi Manzur Rashid , Jed Mao // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.3 /// /// diff --git a/types/sinon-chrome/index.d.ts b/types/sinon-chrome/index.d.ts index 9776b0bb30..263135e060 100644 --- a/types/sinon-chrome/index.d.ts +++ b/types/sinon-chrome/index.d.ts @@ -4,7 +4,7 @@ // CRIMX // kobanyan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.4 /// /// diff --git a/types/sinon-express-mock/index.d.ts b/types/sinon-express-mock/index.d.ts index f3974fc005..10c8ef824d 100644 --- a/types/sinon-express-mock/index.d.ts +++ b/types/sinon-express-mock/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Jared Chapiewsky // Tomek Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.3 import { SinonStub, diff --git a/types/sinon-mongoose/index.d.ts b/types/sinon-mongoose/index.d.ts index 86109b4917..2d9099a060 100644 --- a/types/sinon-mongoose/index.d.ts +++ b/types/sinon-mongoose/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/underscopeio/sinon-mongoose // Definitions by: stevehipwell // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.3 import * as s from "sinon"; diff --git a/types/sinon-stub-promise/index.d.ts b/types/sinon-stub-promise/index.d.ts index d817113cf7..6de3b17b2a 100644 --- a/types/sinon-stub-promise/index.d.ts +++ b/types/sinon-stub-promise/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Thiago Temple // Tim Stackhouse // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.3 /// diff --git a/types/sinon-test/index.d.ts b/types/sinon-test/index.d.ts index 902064a7cb..4cda8702a6 100644 --- a/types/sinon-test/index.d.ts +++ b/types/sinon-test/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/sinonjs/sinon-test // Definitions by: Francis Saul // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.3 import * as Sinon from 'sinon'; diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 0bc7d112fc..2395ee2ed2 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -5,9 +5,8 @@ // Lukas Spieß // Nico Jansen // James Garbutt -// Josh Goldberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.3 // sinon uses DOM dependencies which are absent in browser-less environment like node.js // to avoid compiler errors this monkey patch is used @@ -567,20 +566,15 @@ declare namespace Sinon { } /** - * An instance of a stubbed object type with functions replaced by stubs. + * An instance of a stubbed object type with members replaced by stubs. * * @template TType Object type being stubbed. */ type SinonStubbedInstance = { // TODO: this should really only replace functions on TType with SinonStubs, not all properties // Likely infeasible without mapped conditional types, per https://github.com/Microsoft/TypeScript/issues/12424 - [P in keyof TType]: SinonStubbedMember; + [P in keyof TType]: SinonStub; }; - - /** - * Replaces a type with a Sinon stub if it's a function. - */ - type SinonStubbedMember = T extends Function ? SinonStub : T; } declare const Sinon: Sinon.SinonStatic; diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index c6ffc7a51e..17e8cc6084 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -154,15 +154,6 @@ function testSandbox() { sandbox.createStubInstance(TestCreateStubInstance).someTestMethod('some argument'); } -class OneFunctionOneNumber { - memberFunction() { } - memberNumber: number; -} - -const stubInstance = sinon.createStubInstance(OneFunctionOneNumber); -const memberFunction: sinon.SinonStub = stubInstance.memberFunction; -const memberNumber: number = stubInstance.memberNumber; - function testPromises() { let resolveStub = sinon.stub().resolves(); resolveStub = sinon.stub().resolves(10); From 9cd7841a2631f28b1ec2ba59ad66be009870925c Mon Sep 17 00:00:00 2001 From: Rong Shen Date: Fri, 11 May 2018 04:34:27 +0800 Subject: [PATCH 17/19] add types for jsonic (#25671) --- types/jsonic/index.d.ts | 19 +++++++++++++++++++ types/jsonic/jsonic-tests.ts | 7 +++++++ types/jsonic/tsconfig.json | 16 ++++++++++++++++ types/jsonic/tslint.json | 1 + 4 files changed, 43 insertions(+) create mode 100644 types/jsonic/index.d.ts create mode 100644 types/jsonic/jsonic-tests.ts create mode 100644 types/jsonic/tsconfig.json create mode 100644 types/jsonic/tslint.json diff --git a/types/jsonic/index.d.ts b/types/jsonic/index.d.ts new file mode 100644 index 0000000000..610101b136 --- /dev/null +++ b/types/jsonic/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for jsonic 0.3 +// Project: https://github.com/rjrodger/jsonic +// Definitions by: Rong SHen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function jsonic(text: string): any; +declare namespace jsonic { + interface Options { + depth?: number; + maxitems?: number; + maxchars?: number; + omit?: string[]; + exclude?: string[]; + } + + function stringify(val: any, opts?: Options): string; +} + +export = jsonic; diff --git a/types/jsonic/jsonic-tests.ts b/types/jsonic/jsonic-tests.ts new file mode 100644 index 0000000000..fb0df5dd95 --- /dev/null +++ b/types/jsonic/jsonic-tests.ts @@ -0,0 +1,7 @@ +import * as jsonic from "jsonic"; + +jsonic("a:x, b:y z"); +jsonic.stringify( + { a: "a", b: "b", c: { c1: "c1" } }, + { depth: 1, omit: ["a"], exclude: ["b"] } +); diff --git a/types/jsonic/tsconfig.json b/types/jsonic/tsconfig.json new file mode 100644 index 0000000000..88bfd64ef6 --- /dev/null +++ b/types/jsonic/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "jsonic-tests.ts"] +} diff --git a/types/jsonic/tslint.json b/types/jsonic/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jsonic/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From fd28954b0722e6711a3ff6aacef979a2ff26cb73 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 10 May 2018 13:36:32 -0700 Subject: [PATCH 18/19] Add declarations for cli-progress package (#25661) * Add declarations for cli-progress package * Add missing property * Close comment * Fix lint failure --- types/cli-progress/cli-progress-tests.ts | 92 ++++++++++++++++++ types/cli-progress/index.d.ts | 114 +++++++++++++++++++++++ types/cli-progress/tsconfig.json | 23 +++++ types/cli-progress/tslint.json | 1 + 4 files changed, 230 insertions(+) create mode 100644 types/cli-progress/cli-progress-tests.ts create mode 100644 types/cli-progress/index.d.ts create mode 100644 types/cli-progress/tsconfig.json create mode 100644 types/cli-progress/tslint.json diff --git a/types/cli-progress/cli-progress-tests.ts b/types/cli-progress/cli-progress-tests.ts new file mode 100644 index 0000000000..b9fa6d5057 --- /dev/null +++ b/types/cli-progress/cli-progress-tests.ts @@ -0,0 +1,92 @@ +import progress = require('cli-progress'); + +function test0() { + // Usage + // Multiple examples are available e.g.example.js - just try it $ node example.js + + const _cliProgress = require('cli-progress'); + + // create a new progress bar instance and use shades_classic theme + const bar1 = new _cliProgress.Bar({}, _cliProgress.Presets.shades_classic); + + // start the progress bar with a total value of 200 and start value of 0 + bar1.start(200, 0); + + // update the current value in your application.. + bar1.update(100); + + // stop the progress bar + bar1.stop(); +} + +function test1() { + // Examples + // Example 1 - Set Options + + // change the progress characters + // set fps limit to 5 + // change the output stream and barsize + const bar = new progress.Bar({ + barCompleteChar: '#', + barIncompleteChar: '.', + fps: 5, + stream: process.stdout, + barsize: 65 + }); +} + +function test2() { + // Example 2 - Change Styles defined by Preset + // uee shades preset + // change the barsize + const bar = new progress.Bar({ + barsize: 65 + }, progress.Presets.shades_grey); +} + +function test3() { + // Example 3 - Custom Payload + // create new progress bar with custom token "speed" + const bar = new progress.Bar({ + format: 'progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit' + }); + + // initialize the bar - set payload token "speed" with the default value "N/A" + bar.start(200, 0, { + speed: "N/A" + }); + + // some code/update loop + // ... + + // update bar value. set custom token "speed" to 125 + bar.update(5, { + speed: '125' + }); + + // process finished + bar.stop(); +} + +function test4() { + // Example 4 - Custom Presets + // File mypreset.js + + const _colors = require('colors'); + + module.exports = { + format: _colors.red(' {bar}') + ' {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit', + barCompleteChar: '\u2588', + barIncompleteChar: '\u2591' + }; +} + +function test5() { + // Application + + const _mypreset = require('./mypreset.js'); + + const bar = new progress.Bar({ + barsize: 65 + }, _mypreset); +} diff --git a/types/cli-progress/index.d.ts b/types/cli-progress/index.d.ts new file mode 100644 index 0000000000..3ac9dfe8a3 --- /dev/null +++ b/types/cli-progress/index.d.ts @@ -0,0 +1,114 @@ +// Type definitions for cli-progress 1.8 +// Project: https://github.com/AndiDittrich/Node.CLI-Progress +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +export interface Options { + /** + * progress bar output format. + * The progressbar can be customized by using the following build-in placeholders. They can be combined in any order. + * {bar} - the progress bar, customizable by the options barsize, barCompleteString and barIncompleteString + * {percentage} - the current progress in percent (0-100) + * {total} - the end value + * {value} - the current value set by last update() call + * {eta} - expected time of accomplishment in seconds + * {duration} - elapsed time in seconds + * {eta_formatted} - expected time of accomplishment formatted into appropriate units + * {duration_formatted} - elapsed time formatted into appropriate units + * + * Example: + * progress [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} + * is rendered as + * progress [========================================] 100% | ETA: 0s | 200/200 + */ + format?: string; + + /** the maximum update rate (default: 10) */ + fps?: number; + + /** output stream to use (default: process.stderr) */ + stream?: NodeJS.WritableStream; + + /** automatically call stop() when the value reaches the total (default: false) */ + stopOnComplete?: boolean; + + /** clear the progress bar on complete / stop() call (default: false) */ + clearOnComplete?: boolean; + + /** the length of the progress bar in chars (default: 40) */ + barsize?: number; + + /** character to use as "complete" indicator in the bar (default: "=") */ + barCompleteString?: string; + + /** character to use as "incomplete" indicator in the bar (default: "-") */ + barIncompleteString?: string; + + /** character to use as "complete" indicator in the bar (default: "=") */ + barCompleteChar?: string; + + /** character to use as "incomplete" indicator in the bar (default: "-") */ + barIncompleteChar?: string; + + /** hide the cursor during progress operation; restored on complete (default: false) */ + hideCursor?: boolean; + + /** number of updates with which to calculate the eta; higher numbers give a more stable eta (default: 10) */ + etaBuffer?: number; + + /** disable line wrapping (default: false) - pass null to keep terminal settings; pass true to trim the output to terminal width */ + linewrap?: boolean | null; +} + +export interface Preset { + barCompleteChar: string; + barIncompleteChar: string; + format: string; +} + +export class Bar { + /** Initialize a new Progress bar. An instance can be used multiple times! it's not required to re-create it! */ + constructor(opt: Options, preset?: Preset); + + calculateETA(): void; + + formatTime(t: any, roundToMultipleOf: any): any; + + getTotal(): any; + + /** Increases the current progress value by a specified amount (default +1). Update payload optionally */ + increment(step: number, payload?: object): void; + + render(): void; + + /** Sets the total progress value while progressbar is active. Especially useful handling dynamic tasks. */ + setTotal(total: number): void; + + /** Starts the progress bar and set the total and initial value */ + start(total: number, startValue: number, payload?: object): void; + + /** Stops the progress bar and go to next line */ + stop(): void; + + stopTimer(): void; + + /** Sets the current progress value and optionally the payload with values of custom tokens as a second parameter */ + update(current: number, payload?: object): void; +} + +export const Presets: { + /** Styles as of cli-progress v1.3.0 */ + legacy: Preset; + + /** Unicode Rectangles */ + rect: Preset; + + /** Unicode background shades are used for the bar */ + shades_classic: Preset; + + /** Unicode background shades with grey bar */ + shades_grey: Preset; +}; diff --git a/types/cli-progress/tsconfig.json b/types/cli-progress/tsconfig.json new file mode 100644 index 0000000000..be8771c6c5 --- /dev/null +++ b/types/cli-progress/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "cli-progress-tests.ts" + ] +} diff --git a/types/cli-progress/tslint.json b/types/cli-progress/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cli-progress/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 8cd6bba3b37232c14c4f111c1c95f406fda6895e Mon Sep 17 00:00:00 2001 From: Bryan Hughes Date: Thu, 10 May 2018 15:40:37 -0700 Subject: [PATCH 19/19] Updated Node.js dgram.send() signature with recent changes in Node.js API (#25664) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated “send” signature with recent changse * Fixed some other issues with send() signature and added Node 10 --- types/node/index.d.ts | 4 ++-- types/node/v8/index.d.ts | 4 ++-- types/node/v9/index.d.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index d7ebab4fd0..d228742629 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -2940,8 +2940,8 @@ declare module "dgram" { export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; export class Socket extends events.EventEmitter { - send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error | null, bytes: number) => void): void; - send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error | null, bytes: number) => void): void; + send(msg: Buffer | string | Uint8Array | any[], port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void; + send(msg: Buffer | string | Uint8Array, offset: number, length: number, port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void; bind(port?: number, address?: string, callback?: () => void): void; bind(port?: number, callback?: () => void): void; bind(callback?: () => void): void; diff --git a/types/node/v8/index.d.ts b/types/node/v8/index.d.ts index 5271a8d06a..45f1c85b64 100644 --- a/types/node/v8/index.d.ts +++ b/types/node/v8/index.d.ts @@ -2851,8 +2851,8 @@ declare module "dgram" { export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; export class Socket extends events.EventEmitter { - send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error | null, bytes: number) => void): void; - send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error | null, bytes: number) => void): void; + send(msg: Buffer | string | Uint8Array | any[], port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void; + send(msg: Buffer | string | Uint8Array, offset: number, length: number, port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void; bind(port?: number, address?: string, callback?: () => void): void; bind(port?: number, callback?: () => void): void; bind(callback?: () => void): void; diff --git a/types/node/v9/index.d.ts b/types/node/v9/index.d.ts index 5063a1ee81..5a76e4cc45 100644 --- a/types/node/v9/index.d.ts +++ b/types/node/v9/index.d.ts @@ -2932,8 +2932,8 @@ declare module "dgram" { export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; export class Socket extends events.EventEmitter { - send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error | null, bytes: number) => void): void; - send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error | null, bytes: number) => void): void; + send(msg: Buffer | string | Uint8Array | any[], port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void; + send(msg: Buffer | string | Uint8Array, offset: number, length: number, port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void; bind(port?: number, address?: string, callback?: () => void): void; bind(port?: number, callback?: () => void): void; bind(callback?: () => void): void;