This commit is contained in:
Zev Spitz
2018-05-11 04:19:09 +02:00
78 changed files with 1076 additions and 236 deletions
+1
View File
@@ -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 <https://github.com/alice>, Bob <https://github.com/bob>`.
+1
View File
@@ -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 <https://github.com/alice>, Bob <https://github.com/bob>`.
+1 -1
View File
@@ -221,7 +221,7 @@ declare namespace Chart {
interface ChartTitleOptions {
display?: boolean;
position?: PositionType;
fullWdith?: boolean;
fullWidth?: boolean;
fontSize?: number;
fontFamily?: string;
fontColor?: ChartColor;
+92
View File
@@ -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);
}
+114
View File
@@ -0,0 +1,114 @@
// Type definitions for cli-progress 1.8
// Project: https://github.com/AndiDittrich/Node.CLI-Progress
// Definitions by: My Self <https://github.com/mhegazy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
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;
};
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+13
View File
@@ -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}
`;
+6
View File
@@ -0,0 +1,6 @@
// Type definitions for deline 1.0
// Project: https://github.com/airbnb/deline#readme
// Definitions by: Inaki Arroyo <https://github.com/iarroyo5>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function deline(strings: string | TemplateStringsArray, ...values: any[]): string;
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+42
View File
@@ -0,0 +1,42 @@
// Type definitions for dom-to-image 2.6
// Project: https://github.com/tsayen/dom-to-image
// Definitions by: Jip Sterk <https://github.com/JipSterk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
export interface DomToImage {
toSvg(node: Node, options?: Options): Promise<string>;
toPng(node: Node, options?: Options): Promise<string>;
toJpeg(node: Node, options?: Options): Promise<string>;
toBlob(node: Node, options?: Options): Promise<Blob>;
toPixelData(node: Node, options?: Options): Promise<string>;
}
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;
}
@@ -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 });
}
@@ -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 });
}
@@ -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 });
}
+27
View File
@@ -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"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -1
View File
@@ -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
@@ -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"} ]
}
],
};
<GoogleMapReact center={center} zoom={3} bootstrapURLKeys={client}/>;
<GoogleMapReact center={center} zoom={3} bootstrapURLKeys={client} options={options} />;
+40 -7
View File
@@ -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;
+7 -6
View File
@@ -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<Error>;
/**
* Extension fields to add to the formatted error.
@@ -68,10 +69,10 @@ export class GraphQLError extends Error {
constructor(
message: string,
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
source?: Source | void,
positions?: ReadonlyArray<number> | void,
path?: ReadonlyArray<string | number> | void,
originalError?: Error | void,
extensions?: { [key: string]: any } | void
source?: Maybe<Source>,
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
originalError?: Maybe<Error>,
extensions?: Maybe<{ [key: string]: any }>
);
}
+12 -11
View File
@@ -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<any, any> | void;
variableValues?: Maybe<{ [key: string]: any }>;
operationName?: Maybe<string>;
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
};
/**
@@ -74,9 +75,9 @@ export function execute(
document: DocumentNode,
rootValue?: any,
contextValue?: any,
variableValues?: { [key: string]: any } | void,
operationName?: string | void,
fieldResolver?: GraphQLFieldResolver<any, any> | void
variableValues?: Maybe<{ [key: string]: any }>,
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
): MaybePromise<ExecutionResult>;
/**
@@ -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<any, any> | void
rawVariableValues: Maybe<{ [key: string]: any }>,
operationName: Maybe<string>,
fieldResolver: Maybe<GraphQLFieldResolver<any, any>>
): ReadonlyArray<GraphQLError> | ExecutionContext;
/**
@@ -181,4 +182,4 @@ export function getFieldDef(
schema: GraphQLSchema,
parentType: GraphQLObjectType,
fieldName: string
): GraphQLField<any, any> | void;
): Maybe<GraphQLField<any, any>>;
+3 -2
View File
@@ -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<any, any> | 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<DirectiveNode>;
},
variableValues?: { [key: string]: any } | void
variableValues?: Maybe<{ [key: string]: any }>
): undefined | { [key: string]: any };
+10 -9
View File
@@ -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<any, any> | void;
variableValues?: Maybe<{ [key: string]: any }>;
operationName?: Maybe<string>;
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
}
export function graphql(args: GraphQLArgs): Promise<ExecutionResult>;
@@ -49,9 +50,9 @@ export function graphql(
source: Source | string,
rootValue?: any,
contextValue?: any,
variableValues?: { [key: string]: any } | void,
operationName?: string | void,
fieldResolver?: GraphQLFieldResolver<any, any> | void
variableValues?: Maybe<{ [key: string]: any }>,
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
): Promise<ExecutionResult>;
/**
@@ -66,7 +67,7 @@ export function graphqlSync(
source: Source | string,
rootValue?: any,
contextValue?: any,
variableValues?: { [key: string]: any } | void,
operationName?: string | void,
fieldResolver?: GraphQLFieldResolver<any, any> | void
variableValues?: Maybe<{ [key: string]: any }>,
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
): ExecutionResult;
+1
View File
@@ -13,6 +13,7 @@
// Dylan Stewart <https://github.com/dyst5422>
// Alessio Dionisi <https://github.com/adnsio>
// Divyendu Singh <https://github.com/divyenduz>
// Brad Zacher <https://github.com/bradzacher>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
+2 -1
View File
@@ -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<ASTKindTo
* Given a visitor instance, if it is leaving or not, and a node kind, return
* the function the visitor runtime should call.
*/
export function getVisitFn(visitor: Visitor<any>, kind: string, isLeaving: boolean): VisitFn<any> | void;
export function getVisitFn(visitor: Visitor<any>, kind: string, isLeaving: boolean): Maybe<VisitFn<any>>;
+11 -10
View File
@@ -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<any, any> | void;
subscribeFieldResolver?: GraphQLFieldResolver<any, any> | void;
variableValues?: Maybe<{ [key: string]: any }>;
operationName?: Maybe<string>;
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
}): Promise<AsyncIterator<ExecutionResult> | 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<any, any> | void,
subscribeFieldResolver?: GraphQLFieldResolver<any, any> | void
variableValues?: Maybe<{ [key: string]: any }>,
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
): Promise<AsyncIterator<ExecutionResult> | ExecutionResult>;
/**
@@ -69,6 +70,6 @@ export function createSourceEventStream(
rootValue?: any,
contextValue?: any,
variableValues?: { [key: string]: any },
operationName?: string | void,
fieldResolver?: GraphQLFieldResolver<any, any> | void
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>
): Promise<AsyncIterable<any> | ExecutionResult>;
+2 -2
View File
@@ -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"
]
}
}
+4
View File
@@ -0,0 +1,4 @@
// Conveniently represents flow's "Maybe" type https://flow.org/en/docs/types/maybe/
type Maybe<T> = null | undefined | T
export default Maybe
+65 -64
View File
@@ -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) | T;
*/
export class GraphQLScalarType {
name: string;
description: string | void;
astNode?: ScalarTypeDefinitionNode | void;
description: Maybe<string>;
astNode?: Maybe<ScalarTypeDefinitionNode>;
constructor(config: GraphQLScalarTypeConfig<any, any>);
// 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<TInternal, TExternal> {
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<string>;
astNode?: Maybe<ScalarTypeDefinitionNode>;
serialize(value: any): Maybe<TExternal>;
parseValue?(value: any): Maybe<TInternal>;
parseLiteral?(valueNode: ValueNode, variables: Maybe<{ [key: string]: any }>): Maybe<TInternal>;
}
/**
@@ -320,10 +321,10 @@ export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
*/
export class GraphQLObjectType {
name: string;
description: string | void;
astNode: ObjectTypeDefinitionNode | void;
extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode> | void;
isTypeOf: GraphQLIsTypeOfFn<any, any> | void;
description: Maybe<string>;
astNode: Maybe<ObjectTypeDefinitionNode>;
extensionASTNodes: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
isTypeOf: Maybe<GraphQLIsTypeOfFn<any, any>>;
constructor(config: GraphQLObjectTypeConfig<any, any>);
getFields(): GraphQLFieldMap<any, any>;
@@ -335,19 +336,19 @@ export class GraphQLObjectType {
export interface GraphQLObjectTypeConfig<TSource, TContext> {
name: string;
interfaces?: Thunk<GraphQLInterfaceType[] | void>;
interfaces?: Thunk<Maybe<GraphQLInterfaceType[]>>;
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>;
isTypeOf?: GraphQLIsTypeOfFn<TSource, TContext> | void;
description?: string | void;
astNode?: ObjectTypeDefinitionNode | void;
extensionASTNodes?: ReadonlyArray<ObjectTypeExtensionNode> | void;
isTypeOf?: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
description?: Maybe<string>;
astNode?: Maybe<ObjectTypeDefinitionNode>;
extensionASTNodes?: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
}
export type GraphQLTypeResolver<TSource, TContext> = (
value: TSource,
context: TContext,
info: GraphQLResolveInfo
) => MaybePromise<GraphQLObjectType | string | void>;
) => MaybePromise<Maybe<GraphQLObjectType | string>>;
export type GraphQLIsTypeOfFn<TSource, TContext> = (
source: TSource,
@@ -385,9 +386,9 @@ export interface GraphQLFieldConfig<TSource, TContext, TArgs = { [argName: strin
args?: GraphQLFieldConfigArgumentMap;
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
deprecationReason?: string | void;
description?: string | void;
astNode?: FieldDefinitionNode | void;
deprecationReason?: Maybe<string>;
description?: Maybe<string>;
astNode?: Maybe<FieldDefinitionNode>;
}
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<string>;
astNode?: Maybe<InputValueDefinitionNode>;
}
export type GraphQLFieldConfigMap<TSource, TContext> = {
@@ -405,22 +406,22 @@ export type GraphQLFieldConfigMap<TSource, TContext> = {
export interface GraphQLField<TSource, TContext, TArgs = { [key: string]: any }> {
name: string;
description: string | void;
description: Maybe<string>;
type: GraphQLOutputType;
args: GraphQLArgument[];
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
isDeprecated?: boolean;
deprecationReason?: string | void;
astNode?: FieldDefinitionNode | void;
deprecationReason?: Maybe<string>;
astNode?: Maybe<FieldDefinitionNode>;
}
export interface GraphQLArgument {
name: string;
type: GraphQLInputType;
defaultValue?: any;
description?: string | void;
astNode?: InputValueDefinitionNode | void;
description?: Maybe<string>;
astNode?: Maybe<InputValueDefinitionNode>;
}
export type GraphQLFieldMap<TSource, TContext> = {
@@ -447,10 +448,10 @@ export type GraphQLFieldMap<TSource, TContext> = {
*/
export class GraphQLInterfaceType {
name: string;
description: string | void;
astNode?: InterfaceTypeDefinitionNode | void;
extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode> | void;
resolveType: GraphQLTypeResolver<any, any> | void;
description: Maybe<string>;
astNode?: Maybe<InterfaceTypeDefinitionNode>;
extensionASTNodes: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
resolveType: Maybe<GraphQLTypeResolver<any, any>>;
constructor(config: GraphQLInterfaceTypeConfig<any, any>);
@@ -469,10 +470,10 @@ export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
* the default implementation will call `isTypeOf` on each implementing
* Object type.
*/
resolveType?: GraphQLTypeResolver<TSource, TContext> | void;
description?: string | void;
astNode?: InterfaceTypeDefinitionNode | void;
extensionASTNodes?: ReadonlyArray<InterfaceTypeExtensionNode> | void;
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
description?: Maybe<string>;
astNode?: Maybe<InterfaceTypeDefinitionNode>;
extensionASTNodes?: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
}
/**
@@ -500,9 +501,9 @@ export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
*/
export class GraphQLUnionType {
name: string;
description: string | void;
astNode?: UnionTypeDefinitionNode | void;
resolveType: GraphQLTypeResolver<any, any> | void;
description: Maybe<string>;
astNode?: Maybe<UnionTypeDefinitionNode>;
resolveType: Maybe<GraphQLTypeResolver<any, any>>;
constructor(config: GraphQLUnionTypeConfig<any, any>);
@@ -521,9 +522,9 @@ export interface GraphQLUnionTypeConfig<TSource, TContext> {
* the default implementation will call `isTypeOf` on each implementing
* Object type.
*/
resolveType?: GraphQLTypeResolver<TSource, TContext> | void;
description?: string | void;
astNode?: UnionTypeDefinitionNode | void;
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
description?: Maybe<string>;
astNode?: Maybe<UnionTypeDefinitionNode>;
}
/**
@@ -549,15 +550,15 @@ export interface GraphQLUnionTypeConfig<TSource, TContext> {
*/
export class GraphQLEnumType {
name: string;
description: string | void;
astNode: EnumTypeDefinitionNode | void;
description: Maybe<string>;
astNode: Maybe<EnumTypeDefinitionNode>;
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<GraphQLEnumValue>;
serialize(value: any): Maybe<string>;
parseValue(value: any): Maybe<any>;
parseLiteral(valueNode: ValueNode, _variables: Maybe<{ [key: string]: any }>): Maybe<any>;
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<string>;
astNode?: Maybe<EnumTypeDefinitionNode>;
}
export type GraphQLEnumValueConfigMap = { [key: string]: GraphQLEnumValueConfig };
export interface GraphQLEnumValueConfig {
value?: any;
deprecationReason?: string | void;
description?: string | void;
astNode?: EnumValueDefinitionNode | void;
deprecationReason?: Maybe<string>;
description?: Maybe<string>;
astNode?: Maybe<EnumValueDefinitionNode>;
}
export interface GraphQLEnumValue {
name: string;
description: string | void;
description: Maybe<string>;
isDeprecated?: boolean;
deprecationReason: string | void;
astNode?: EnumValueDefinitionNode | void;
deprecationReason: Maybe<string>;
astNode?: Maybe<EnumValueDefinitionNode>;
value: any;
}
@@ -610,8 +611,8 @@ export interface GraphQLEnumValue {
*/
export class GraphQLInputObjectType {
name: string;
description: string | void;
astNode: InputObjectTypeDefinitionNode | void;
description: Maybe<string>;
astNode: Maybe<InputObjectTypeDefinitionNode>;
constructor(config: GraphQLInputObjectTypeConfig);
getFields(): GraphQLInputFieldMap;
toString(): string;
@@ -622,15 +623,15 @@ export class GraphQLInputObjectType {
export interface GraphQLInputObjectTypeConfig {
name: string;
fields: Thunk<GraphQLInputFieldConfigMap>;
description?: string | void;
astNode?: InputObjectTypeDefinitionNode | void;
description?: Maybe<string>;
astNode?: Maybe<InputObjectTypeDefinitionNode>;
}
export interface GraphQLInputFieldConfig {
type: GraphQLInputType;
defaultValue?: any;
description?: string | void;
astNode?: InputValueDefinitionNode | void;
description?: Maybe<string>;
astNode?: Maybe<InputValueDefinitionNode>;
}
export type GraphQLInputFieldConfigMap = {
@@ -641,8 +642,8 @@ export interface GraphQLInputField {
name: string;
type: GraphQLInputType;
defaultValue?: any;
description?: string | void;
astNode?: InputValueDefinitionNode | void;
description?: Maybe<string>;
astNode?: Maybe<InputValueDefinitionNode>;
}
export type GraphQLInputFieldMap = { [key: string]: GraphQLInputField };
+6 -5
View File
@@ -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<string>;
locations: DirectiveLocationEnum[];
args: GraphQLArgument[];
astNode: DirectiveDefinitionNode | void;
astNode: Maybe<DirectiveDefinitionNode>;
constructor(config: GraphQLDirectiveConfig);
}
export interface GraphQLDirectiveConfig {
name: string;
description?: string | void;
description?: Maybe<string>;
locations: DirectiveLocationEnum[];
args?: GraphQLFieldConfigArgumentMap | void;
astNode?: DirectiveDefinitionNode | void;
args?: Maybe<GraphQLFieldConfigArgumentMap>;
astNode?: Maybe<DirectiveDefinitionNode>;
}
/**
+14 -13
View File
@@ -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<SchemaDefinitionNode>;
constructor(config: GraphQLSchemaConfig);
getQueryType(): GraphQLObjectType | void;
getMutationType(): GraphQLObjectType | void;
getSubscriptionType(): GraphQLObjectType | void;
getQueryType(): Maybe<GraphQLObjectType>;
getMutationType(): Maybe<GraphQLObjectType>;
getSubscriptionType(): Maybe<GraphQLObjectType>;
getTypeMap(): TypeMap;
getType(name: string): GraphQLNamedType | void;
getType(name: string): Maybe<GraphQLNamedType>;
getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray<GraphQLObjectType>;
isPossibleType(abstractType: GraphQLAbstractType, possibleType: GraphQLObjectType): boolean;
getDirectives(): ReadonlyArray<GraphQLDirective>;
getDirective(name: string): GraphQLDirective | void;
getDirective(name: string): Maybe<GraphQLDirective>;
}
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<string> | void;
allowedLegacyNames?: Maybe<ReadonlyArray<string>>;
}
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<GraphQLObjectType>;
mutation?: Maybe<GraphQLObjectType>;
subscription?: Maybe<GraphQLObjectType>;
types?: Maybe<GraphQLNamedType[]>;
directives?: Maybe<GraphQLDirective[]>;
astNode?: Maybe<SchemaDefinitionNode>;
}
+11 -9
View File
@@ -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<any, any> | void;
getDirective(): GraphQLDirective | void;
getArgument(): GraphQLArgument | void;
getEnumValue(): GraphQLEnumValue | void;
getType(): Maybe<GraphQLOutputType>;
getParentType(): Maybe<GraphQLCompositeType>;
getInputType(): Maybe<GraphQLInputType>;
getParentInputType(): Maybe<GraphQLInputType>;
getFieldDef(): GraphQLField<any, Maybe<any>>;
getDefaultValue(): Maybe<any>;
getDirective(): Maybe<GraphQLDirective>;
getArgument(): Maybe<GraphQLArgument>;
getEnumValue(): Maybe<GraphQLEnumValue>;
enter(node: ASTNode): any;
leave(node: ASTNode): any;
}
@@ -44,4 +46,4 @@ type getFieldDef = (
schema: GraphQLSchema,
parentType: GraphQLType,
fieldNode: FieldNode
) => GraphQLField<any, any> | void;
) => Maybe<GraphQLField<any, any>>;
+2 -1
View File
@@ -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<ValueNode>;
+3 -2
View File
@@ -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<BuildSchemaOptions>, resolveType: TypeResolver);
buildTypes(nodes: ReadonlyArray<NamedTypeNode | TypeDefinitionNode>): Array<GraphQLNamedType>;
@@ -69,7 +70,7 @@ export class ASTDefinitionBuilder {
*/
export function getDescription(
node: { readonly description?: StringValueNode; readonly loc?: Location },
options: BuildSchemaOptions | void
options: Maybe<BuildSchemaOptions>
): string | undefined;
/**
+3 -2
View File
@@ -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<string>
): Maybe<OperationDefinitionNode>;
+16 -15
View File
@@ -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<IntrospectionObjectType>;
readonly mutationType: IntrospectionNamedTypeRef<IntrospectionObjectType> | void;
readonly subscriptionType: IntrospectionNamedTypeRef<IntrospectionObjectType> | void;
readonly mutationType: Maybe<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
readonly subscriptionType: Maybe<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
readonly types: ReadonlyArray<IntrospectionType>;
readonly directives: ReadonlyArray<IntrospectionDirective>;
}
@@ -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<string>;
}
export interface IntrospectionObjectType {
readonly kind: "OBJECT";
readonly name: string;
readonly description?: string | void;
readonly description?: Maybe<string>;
readonly fields: ReadonlyArray<IntrospectionField>;
readonly interfaces: ReadonlyArray<IntrospectionNamedTypeRef<IntrospectionInterfaceType>>;
}
@@ -56,7 +57,7 @@ export interface IntrospectionObjectType {
export interface IntrospectionInterfaceType {
readonly kind: "INTERFACE";
readonly name: string;
readonly description?: string | void;
readonly description?: Maybe<string>;
readonly fields: ReadonlyArray<IntrospectionField>;
readonly possibleTypes: ReadonlyArray<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
}
@@ -64,21 +65,21 @@ export interface IntrospectionInterfaceType {
export interface IntrospectionUnionType {
readonly kind: "UNION";
readonly name: string;
readonly description?: string | void;
readonly description?: Maybe<string>;
readonly possibleTypes: ReadonlyArray<IntrospectionNamedTypeRef<IntrospectionObjectType>>;
}
export interface IntrospectionEnumType {
readonly kind: "ENUM";
readonly name: string;
readonly description?: string | void;
readonly description?: Maybe<string>;
readonly enumValues: ReadonlyArray<IntrospectionEnumValue>;
}
export interface IntrospectionInputObjectType {
readonly kind: "INPUT_OBJECT";
readonly name: string;
readonly description?: string | void;
readonly description?: Maybe<string>;
readonly inputFields: ReadonlyArray<IntrospectionInputValue>;
}
@@ -114,30 +115,30 @@ export interface IntrospectionNamedTypeRef<T extends IntrospectionType = Introsp
export interface IntrospectionField {
readonly name: string;
readonly description?: string | void;
readonly description?: Maybe<string>;
readonly args: ReadonlyArray<IntrospectionInputValue>;
readonly type: IntrospectionOutputTypeRef;
readonly isDeprecated: boolean;
readonly deprecationReason?: string | void;
readonly deprecationReason?: Maybe<string>;
}
export interface IntrospectionInputValue {
readonly name: string;
readonly description?: string | void;
readonly description?: Maybe<string>;
readonly type: IntrospectionInputTypeRef;
readonly defaultValue?: string | void;
readonly defaultValue?: Maybe<string>;
}
export interface IntrospectionEnumValue {
readonly name: string;
readonly description?: string | void;
readonly description?: Maybe<string>;
readonly isDeprecated: boolean;
readonly deprecationReason?: string | void;
readonly deprecationReason?: Maybe<string>;
}
export interface IntrospectionDirective {
readonly name: string;
readonly description?: string | void;
readonly description?: Maybe<string>;
readonly locations: ReadonlyArray<DirectiveLocationEnum>;
readonly args: ReadonlyArray<IntrospectionInputValue>;
}
+3 -2
View File
@@ -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<ValueNode>,
type: GraphQLInputType,
variables?: { [key: string]: any } | void
variables?: Maybe<{ [key: string]: any }>
): any;
+2 -1
View File
@@ -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;
+14 -9
View File
@@ -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<GraphQLInputType>;
readonly defaultValue: Maybe<any>;
};
/**
* 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<FragmentDefinitionNode>;
getFragmentSpreads(node: SelectionSetNode): ReadonlyArray<FragmentSpreadNode>;
@@ -47,17 +52,17 @@ export default class ValidationContext {
getRecursiveVariableUsages(operation: OperationDefinitionNode): ReadonlyArray<VariableUsage>;
getType(): GraphQLOutputType | void;
getType(): Maybe<GraphQLOutputType>;
getParentType(): GraphQLCompositeType | void;
getParentType(): Maybe<GraphQLCompositeType>;
getInputType(): GraphQLInputType | void;
getInputType(): Maybe<GraphQLInputType>;
getParentInputType(): GraphQLInputType | void;
getParentInputType(): Maybe<GraphQLInputType>;
getFieldDef(): GraphQLField<any, any> | void;
getFieldDef(): Maybe<GraphQLField<any, any>>;
getDirective(): GraphQLDirective | void;
getDirective(): Maybe<GraphQLDirective>;
getArgument(): GraphQLArgument | void;
getArgument(): Maybe<GraphQLArgument>;
}
+2 -1
View File
@@ -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>): string;
/**
* No undefined variables
+2 -1
View File
@@ -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>): string;
/**
* No unused variables
@@ -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>): string;
/**
* Subscriptions must only include one field.
@@ -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...
});
+107
View File
@@ -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 <https://github.com/l-jonas>
// 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<void>;
export function setup(callback: (err: any) => void): void;
export function getService(receipt: Receipt): Service;
export function validate(receipt: Receipt): Promise<ValidationResponse>;
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<ValidationResponse>;
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<void>;
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
}
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for jsonic 0.3
// Project: https://github.com/rjrodger/jsonic
// Definitions by: Rong SHen <https://github.com/jacobbubu>
// 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;
+7
View File
@@ -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"] }
);
+16
View File
@@ -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"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/tubalmartin/karma-chai-sinon
// Definitions by: Václav Ostrožlík <https://github.com/vasek17>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
/// <reference types="chai" />
import Sinon = require("sinon");
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/pawelgalazka/mochaccino#readme
// Definitions by: Thomas-P <https://github.com/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;
+10 -1
View File
@@ -1,9 +1,18 @@
// Type definitions for NaturalSort
// Project: https://github.com/studio-b12/natural-sort
// Definitions by: Antonio Morales <https://github.com/a-morales>
// Brian Crowell <https://github.com/fluggo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace naturalSort;
declare function naturalSort<T>(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;
+5 -2
View File
@@ -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}));
+1
View File
@@ -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;
+1
View File
@@ -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();
{
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -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;
+5 -2
View File
@@ -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<S extends Schema = any>(
range: NodeRange<S>,
nodeType: NodeType<S>,
attrs?: { [key: string]: any }
attrs?: { [key: string]: any },
innerRange?: NodeRange<S>
): Array<{ type: NodeType<S>; attrs?: { [key: string]: any } | null }> | null | undefined;
/**
* Check whether splitting at the given position is allowed.
+4 -2
View File
@@ -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,
+28
View File
@@ -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 <https://github.com/vasilysn>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
/// <reference types="googlemaps" />
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;
}
}
@@ -0,0 +1,23 @@
import * as React from "react";
import ReactGoogleMapsLoader from "react-google-maps-loader";
const ReactGoogleMapsLoaderTest: React.SFC = () => (
<ReactGoogleMapsLoader
params={{ key: "secret-key" }}
render={googleMaps => <div />}
/>
);
const ReactGoogleMapsLoaderWithLibrariesTest: React.SFC = () => (
<ReactGoogleMapsLoader
params={{ key: "secret-key", libraries: "places" }}
render={googleMaps => <div />}
/>
);
const ReactGoogleMapsLoaderWithErrorHandlerTest: React.SFC = () => (
<ReactGoogleMapsLoader
params={{ key: "secret-key", libraries: "places" }}
render={(googleMaps, error) => <div>{error}</div>}
/>
);
@@ -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"
]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5
View File
@@ -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 {
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/shouldjs/sinon
// Definitions by: AryloYeung <https://github.com/Arylo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import * as s from "sinon";
import should = require("should");
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/bendrucker/sinon-as-promised
// Definitions by: igrayson <https://github.com/igrayson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import * as s from "sinon";
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/domenic/sinon-chai
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid>, Jed Mao <https://github.com/jedmao>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
/// <reference types="chai" />
/// <reference types="sinon" />
+1 -1
View File
@@ -4,7 +4,7 @@
// CRIMX <https://github.com/crimx>
// kobanyan <https://github.com/kobanyan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.4
/// <reference types="chrome"/>
/// <reference types="sinon"/>
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Jared Chapiewsky <https://github.com/jpchip>
// Tomek Łaziuk <https://github.com/tlaziuk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import {
SinonStub,
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/underscopeio/sinon-mongoose
// Definitions by: stevehipwell <https://github.com/stevehipwell>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import * as s from "sinon";
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Thiago Temple <https://github.com/vintem>
// Tim Stackhouse <https://github.com/tstackhouse>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
/// <reference types="sinon"/>
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/sinonjs/sinon-test
// Definitions by: Francis Saul <https://github.com/mummybot>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import * as Sinon from 'sinon';
+3 -9
View File
@@ -5,9 +5,8 @@
// Lukas Spieß <https://github.com/lumaxis>
// Nico Jansen <https://github.com/nicojs>
// James Garbutt <https://github.com/43081j>
// Josh Goldberg <https://github.com/joshuakgoldberg>
// 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<TType> = {
// 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<TType[P]>;
[P in keyof TType]: SinonStub;
};
/**
* Replaces a type with a Sinon stub if it's a function.
*/
type SinonStubbedMember<T> = T extends Function ? SinonStub : T;
}
declare const Sinon: Sinon.SinonStatic;
-9
View File
@@ -154,15 +154,6 @@ function testSandbox() {
sandbox.createStubInstance<TestCreateStubInstance>(TestCreateStubInstance).someTestMethod('some argument');
}
class OneFunctionOneNumber {
memberFunction() { }
memberNumber: number;
}
const stubInstance = sinon.createStubInstance<OneFunctionOneNumber>(OneFunctionOneNumber);
const memberFunction: sinon.SinonStub = stubInstance.memberFunction;
const memberNumber: number = stubInstance.memberNumber;
function testPromises() {
let resolveStub = sinon.stub().resolves();
resolveStub = sinon.stub().resolves(10);
+20 -17
View File
@@ -1,6 +1,9 @@
// Type definitions for yup 0.24
// Project: https://github.com/jquense/yup
// Definitions by: Dominik Hardtke <https://github.com/dhardtke>, Vladyslav Tserman <https://github.com/vtserman>, Moreton Bay Regional Council <https://github.com/MoretonBayRC>
// Definitions by: Dominik Hardtke <https://github.com/dhardtke>,
// Vladyslav Tserman <https://github.com/vtserman>,
// Moreton Bay Regional Council <https://github.com/MoretonBayRC>,
// Sindre Seppola <https://github.com/sseppola>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -34,8 +37,8 @@ export interface Schema<T> {
meta(): any;
describe(): SchemaDescription;
concat(schema: this): this;
validate(value: T, options?: ValidateOptions): Promise<ValidationError|T>;
validateSync(value: T, options?: ValidateOptions): ValidationError|T;
validate(value: T, options?: ValidateOptions): Promise<ValidationError | T>;
validateSync(value: T, options?: ValidateOptions): ValidationError | T;
isValid(value: T, options?: any): Promise<boolean>;
isValidSync(value: T, options?: any): boolean;
cast(value: any, options?: any): T;
@@ -57,8 +60,8 @@ export interface Schema<T> {
}
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<string> {
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<T> extends Schema<T[]> {
export interface ObjectSchemaConstructor {
<T>(fields?: { [field in keyof T]: Schema<T[field]> }): ObjectSchema<T>;
new (): ObjectSchema<{}>;
new(): ObjectSchema<{}>;
}
export interface ObjectSchema<T> extends Schema<T> {
@@ -155,8 +158,8 @@ export interface WhenOptionsBuilder<T> {
}
export type WhenOptions<T> = WhenOptionsBuilder<T>
| { 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<any> {
}
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<any>]?: string };
object?: { [key in keyof ObjectSchema<any>]?: 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<any>]?: string };
object?: { [key in keyof ObjectSchema<any>]?: string };
}