Merge branch 'master' into remove-p-event

This commit is contained in:
Nathan Shively-Sanders
2019-03-04 11:36:17 -08:00
committed by GitHub
33 changed files with 231 additions and 629 deletions
+19
View File
@@ -834,6 +834,12 @@
"sourceRepoURL": "https://github.com/blakeembrey/is-lower-case",
"asOfVersion": "1.1.2"
},
{
"libraryName": "is-online",
"typingsPackageName": "is-online",
"sourceRepoURL": "https://github.com/sindresorhus/is-online",
"asOfVersion": "8.1.0"
},
{
"libraryName": "is-plain-object",
"typingsPackageName": "is-plain-object",
@@ -1152,6 +1158,13 @@
"sourceRepoURL": "https://github.com/sindresorhus/p-event",
"asOfVersion": "3.0.0"
},
{
"libraryName": "p-limit",
"typingsPackageName": "p-limit",
"sourceRepoURL": "https://github.com/sindresorhus/p-limit",
"asOfVersion": "2.2.0"
},
{
"libraryName": "p-map",
"typingsPackageName": "p-map",
@@ -1164,6 +1177,12 @@
"sourceRepoURL": "https://github.com/sindresorhus/p-pipe",
"asOfVersion": "2.0.1"
},
{
"libraryName": "p-queue",
"typingsPackageName": "p-queue",
"sourceRepoURL": "https://github.com/sindresorhus/p-queue",
"asOfVersion": "3.2.1"
},
{
"libraryName": "p-throttle",
"typingsPackageName": "p-throttle",
+14 -5
View File
@@ -1,12 +1,21 @@
// Type definitions for cypress-axe 0.3
// Type definitions for cypress-axe 0.4
// Project: https://github.com/avanslaars/cypress-axe#readme
// Definitions by: Justin Hall <https://github.com/wKovacs64>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
declare namespace Cypress {
interface Chainable<Subject = any> {
injectAxe(): void;
checkA11y(): void;
import { ElementContext, RunOptions } from 'axe-core';
declare module 'axe-core' {
interface Node {}
}
declare global {
namespace Cypress {
interface Chainable<Subject = any> {
injectAxe(): void;
checkA11y(context?: ElementContext, options?: RunOptions): void;
configureAxe(options?: RunOptions): void;
}
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"axe-core": "^3.1.2"
}
}
+6 -1
View File
@@ -1 +1,6 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
"no-empty-interface": false
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
// Type definitions for electron-spellchecker 1.1
// Project: https://github.com/paulcbetts/electron-spellchecker
// Project: https://github.com/electron-userland/electron-spellchecker
// Definitions by: Daniel Perez Alvarez <https://github.com/unindented>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
+35 -1
View File
@@ -1,5 +1,5 @@
// Type definitions for flexmonster 2.6
// Project: https://flexmonster.com
// Project: https://flexmonster.com/
// Definitions by: Flexmonster <https://github.com/flexmonster>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -135,6 +135,7 @@ declare namespace Flexmonster {
showGridAndCharts(type?: string, position?: string, multiple?: boolean): void;
sortingMethod(hierarchyName: string, compareFunction: (a: string, b: string) => boolean): void;
sortValues(axisName: string, type: string, tuple: number[], measure: MeasureObject): void;
toolbar: Toolbar;
updateData(object: DataSource | object[]): void;
version: string;
fusioncharts?: {
@@ -179,6 +180,7 @@ declare namespace Flexmonster {
dataSourceInfo?: string;
dataSourceType?: string;
fieldSeparator?: string;
thousandSeparator?: string;
filename?: string;
ignoreQuotedLineBreaks?: boolean;
proxyUrl?: string;
@@ -191,6 +193,8 @@ declare namespace Flexmonster {
hash?: string;
username?: string;
password?: string;
requestHeader?: object;
subquery?: string;
}
interface Slice {
@@ -276,6 +280,7 @@ declare namespace Flexmonster {
saveAllFormats?: boolean;
showDrillThroughConfigurator?: boolean;
grouping?: boolean;
showAllFieldsDrillThrough?: boolean;
}
interface PrintOptions {
@@ -343,6 +348,7 @@ declare namespace Flexmonster {
useOlapFormattingInExcel?: boolean;
useCustomizeCellForData?: boolean;
excelExportAll?: boolean;
requestHeader?: object;
}
interface Hierarchy {
@@ -463,6 +469,34 @@ declare namespace Flexmonster {
interface Toolbar {
getTabs: () => ToolbarTab[];
// Connect tab
connectLocalCSVHandler: () => void;
connectLocalJSONHandler: () => void;
connectRemoteCSV: () => void;
connectRemoteJSON: () => void;
connectOLAP: () => void;
// Open tab
openLocalReport: () => void;
openRemoteReport: () => void;
// Save tab
saveHandler: () => void;
// Export tab
printHandler: () => void;
exportHandler: (type: string) => void;
// Grid tab
gridHandler: () => void;
// Charts tab
chartsHandler: (type: string) => void;
chartsMultipleHandler: () => void;
// Format tab
formatCellsHandler: () => void;
conditionalFormattingHandler: () => void;
// Options tab
optionsHandler: () => void;
// Fields tab
fieldsHandler: () => void;
// Fullscreen tab
fullscreenHandler: () => void;
}
interface ToolbarTab {
@@ -1,7 +1,7 @@
google.script.url.getLocation(location => {
location.hash; // $ExpectedType string
location.parameter; // $ExpectedType { [key: string]: string }
location.parameters; // $ExpectedType { [key: string]: ReadonlyArray<string> }
location.hash; // $ExpectType string
location.parameter; // $ExpectType { [key: string]: string; }
location.parameters; // $ExpectType { [key: string]: ReadonlyArray<string>; }
});
google.script.history.push(null);
@@ -13,10 +13,10 @@ google.script.history.replace({ timestamp: Date.now() }, { foo: 'bar', fiz: 'baz
google.script.history.replace({ timestamp: Date.now() }, { foo: ['bar', 'cat'], fiz: 'baz' }, 'anchor1');
google.script.history.setChangeHandler(e => {
e.state; // $ExpectedType google.script.history.State
e.location.hash; // $ExpectedType string
e.location.parameter; // $ExpectedType { [key: string]: string }
e.location.parameters; // $ExpectedType { [key: string]: ReadonlyArray<string> }
e.state; // $ExpectType State
e.location.hash; // $ExpectType string
e.location.parameter; // $ExpectType { [key: string]: string; }
e.location.parameters; // $ExpectType { [key: string]: ReadonlyArray<string>; }
});
google.script.host.origin; // $ExpectType string
@@ -25,15 +25,79 @@ google.script.host.editor.focus();
google.script.host.setHeight(450);
google.script.host.setWidth(300);
google.script.run.withSuccessHandler(() => {}).executeScript({ message: 'test for google.script.run' });
google.script.run.withSuccessHandler(() => {}); // $ExpectType Runner
google.script.run.withFailureHandler(() => {}); // $ExpectType Runner
google.script.run.withUserObject({}); // $ExpectType Runner
google.script.run
.withSuccessHandler(value => {})
.withFailureHandler(error => {})
.getEmail();
.withFailureHandler(error => {
error; // $ExpectType Error
});
google.script.run
.withSuccessHandler((value, userObject) => {})
.withFailureHandler((error, userObject) => {})
.withUserObject({})
.getSomeData(Date.now(), { options: 'none' }, 'anchor1', true, null);
.withFailureHandler((error, userObject) => {
error; // $ExpectType Error
})
.withUserObject({});
google.script.run.testFunctionWithoutParameter();
google.script.run.testFunctionWithNumber(0);
google.script.run.testFunctionWithBoolean(true);
google.script.run.testFunctionWithString("");
google.script.run.testFunctionWithNull(null);
google.script.run.testFunctionWithArray([
0,
true,
"",
null,
undefined,
[],
{
number: 0,
boolean: true,
string: "",
nullValue: null,
undef: undefined,
array: [0, true, "", null, undefined, [], {}],
object: {}
}
]);
google.script.run.testFunctionWithObject({
number: 0,
boolean: true,
string: "",
nullValue: null,
undef: undefined,
array: [0, true, "", null, undefined, [], {}],
object: {}
});
google.script.run.testFunctionWithMultipleParameters(
0,
true,
"",
null,
undefined,
[
0,
true,
"",
null,
undefined,
[],
{}
],
{
number: 0,
boolean: true,
string: "",
nullValue: null,
undef: undefined,
array: [0, true, "", null, undefined, [], {}],
object: {}
}
);
google.script.run.testFunctionWithForm(new HTMLFormElement());
google.script.run.testFunctionWithDateError(new Date()); // $ExpectError
google.script.run.testFunctionWithFunctionError(() => {}); // $ExpectError
+7 -5
View File
@@ -1,4 +1,4 @@
// Type definitions for non-npm package Google Apps Script Client-side API 0.0
// Type definitions for non-npm package Google Apps Script Client-side API 0.1
// Project: https://developers.google.com/apps-script/guides/html/reference/host
// Definitions by: clomie <https://github.com/clomie>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -118,12 +118,14 @@ declare namespace google.script {
const run: Runner;
interface Runner {
type Parameter = number | boolean | string | { [index: number]: Parameter } | { [key: string]: Parameter } | null | undefined;
type Runner = {
/**
* Executes the server-side Apps Script function with the corresponding name.
*/
[functionName: string]: (...args: any[]) => void;
[functionName: string]: (first?: Parameter | HTMLFormElement, ...rest: Parameter[]) => void;
} & {
/**
* Sets a callback function to run if the server-side function throws an exception.
* Without a failure handler, failures are logged to the JavaScript console.
@@ -147,5 +149,5 @@ declare namespace google.script {
* User objects cannot, however, be objects constructed with the new operator
*/
withUserObject(object: any): Runner;
}
};
}
@@ -2,7 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
-34
View File
@@ -1,34 +0,0 @@
// Type definitions for is-online 8.0
// Project: https://github.com/sindresorhus/is-online#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = isOnline;
/**
* Check if the internet connection is up.
*
* The following checks are run in parallel:
* - Retrieve [icanhazip.com](https://github.com/major/icanhaz) via HTTPS
* - Query `myip.opendns.com` on OpenDNS (Node.js only)
* - Retrieve Apple's Captive Portal test page (Node.js only)
*
* When the first check succeeds, the returned Promise is resolved to `true`.
*/
declare function isOnline(options?: isOnline.Options): Promise<boolean>;
declare namespace isOnline {
interface Options {
/**
* Milliseconds to wait for a server to respond.
* @default 5000
*/
timeout?: number;
/**
* Internet Protocol version to use. This is an advanced option that is usually not necessary to be set,
* but it can prove useful to specifically assert IPv6 connectivity.
* @default 'v4'
*/
version?: 'v4' | 'v6';
}
}
-6
View File
@@ -1,6 +0,0 @@
import isOnline = require('is-online');
isOnline(); // $ExpectType Promise<boolean>
isOnline({ timeout: 10 }); // $ExpectType Promise<boolean>
isOnline({ version: 'v4' }); // $ExpectType Promise<boolean>
isOnline({ version: 'v6' }); // $ExpectType Promise<boolean>
-23
View File
@@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"is-online-tests.ts"
]
}
-1
View File
@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1,5 +1,5 @@
// Type definitions for mathjs 5.0
// Project: http://mathjs.org/
// Project: https://mathjs.org/
// Definitions by: Ilya Shestakov <https://github.com/siavol>,
// Andy Patterson <https://github.com/andnp>,
// Brad Besserman <https://github.com/bradbesserman>
+6 -6
View File
@@ -962,11 +962,11 @@ declare namespace Office {
*
* *Supported hosts, by platform*
* <table>
* <tr><th> </th><th> Office for Windows desktop </th><th> Office Online (in browser) </th><th> Office for iPad </th></tr>
* <tr><td><strong> Excel </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* <tr><td><strong> Outlook </strong></td><td> Y (Mailbox 1.3) </td><td> </td><td> </td></tr>
* <tr><td><strong> PowerPoint </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* <tr><td><strong> Word </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* <tr><th> </th><th> Office for Windows desktop </th><th> Office Online (in browser) </th><th> Office for iPad </th></tr>
* <tr><td><strong> Excel </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* <tr><td><strong> Outlook </strong></td><td> Y (Mailbox 1.3: without options<br>Mailbox Preview: with options)</td><td> </td><td> </td></tr>
* <tr><td><strong> PowerPoint </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* <tr><td><strong> Word </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* </table>
*
* @param options Optional. An object literal that contains one or more of the following properties.
@@ -974,7 +974,7 @@ declare namespace Office {
* this value indicates of the handled event should continue execution or be canceled.
* For example, an add-in that handles the ItemSend event can set allowEvent = false to cancel sending of the message.
*/
completed(options?: any): void;
completed(options?: { allowEvent: boolean }): void;
}
/**
+6 -6
View File
@@ -962,11 +962,11 @@ declare namespace Office {
*
* *Supported hosts, by platform*
* <table>
* <tr><th> </th><th> Office for Windows desktop </th><th> Office Online (in browser) </th><th> Office for iPad </th></tr>
* <tr><td><strong> Excel </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* <tr><td><strong> Outlook </strong></td><td> Y (Mailbox 1.3) </td><td> </td><td> </td></tr>
* <tr><td><strong> PowerPoint </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* <tr><td><strong> Word </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* <tr><th> </th><th> Office for Windows desktop </th><th> Office Online (in browser) </th><th> Office for iPad </th></tr>
* <tr><td><strong> Excel </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* <tr><td><strong> Outlook </strong></td><td> Y (Mailbox 1.3: without options<br>Mailbox Preview: with options)</td><td> </td><td> </td></tr>
* <tr><td><strong> PowerPoint </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* <tr><td><strong> Word </strong></td><td> Y </td><td> Y </td><td> Y </td></tr>
* </table>
*
* @param options Optional. An object literal that contains one or more of the following properties.
@@ -974,7 +974,7 @@ declare namespace Office {
* this value indicates of the handled event should continue execution or be canceled.
* For example, an add-in that handles the ItemSend event can set allowEvent = false to cancel sending of the message.
*/
completed(options?: any): void;
completed(options?: { allowEvent: boolean }): void;
}
/**
-43
View File
@@ -1,43 +0,0 @@
// Type definitions for p-limit 2.1
// Project: https://github.com/sindresorhus/p-limit#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Linus Unnebäck <https://github.com/LinusU>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
export = pLimit;
/**
* Run multiple promise-returning & async functions with limited concurrency.
* @param concurrency Concurrency limit. Minimum: `1`.
* @returns A `limit` function.
*/
declare function pLimit(concurrency: number): pLimit.Limit;
declare namespace pLimit {
interface Limit {
/**
* Returns the promise returned by calling `fn(...args)`.
*
* @param fn Promise-returning/async function.
* @param args Any arguments to pass through to `fn`.
* Support for passing arguments on to the `fn` is provided in order to be able to avoid
* creating unnecessary closures. You probably don't need this optimization unless you're
* pushing a lot of functions.
*/
<TArgs extends any[], R>(
fn: (...args: TArgs) => PromiseLike<R> | R,
...args: TArgs
): Promise<R>;
/**
* The number of promises that are currently running.
*/
readonly activeCount: number;
/**
* The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
*/
readonly pendingCount: number;
}
}
-23
View File
@@ -1,23 +0,0 @@
import pLimit = require('p-limit');
const limit = pLimit(1);
const input = [
limit(() => Promise.resolve('foo')),
limit(() => Promise.resolve('bar')),
limit(() => Promise.resolve(undefined)),
];
Promise.all(input); // $ExpectType Promise<(string | undefined)[]>
limit((a: string) => '', 'test').then(v => {
v; // $ExpectType string
});
limit((a: string, b: number) => Promise.resolve(''), 'test', 1).then(v => {
v; // $ExpectType string
});
limit.activeCount; // $ExpectType number
limit.activeCount = 1; // $ExpectError
limit.pendingCount; // $ExpectType number
limit.pendingCount = 1; // $ExpectError
-23
View File
@@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"p-limit-tests.ts"
]
}
-1
View File
@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }
-160
View File
@@ -1,160 +0,0 @@
// Type definitions for p-queue 3.1
// Project: https://github.com/sindresorhus/p-queue#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Evan Shortiss <https://github.com/evanshortiss>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="node" />
import { EventEmitter } from 'events';
export = PQueue;
/**
* Promise queue with concurrency control.
*/
declare class PQueue<
TEnqueueOptions extends PQueue.QueueAddOptions = PQueue.DefaultAddOptions
> extends EventEmitter {
/**
* Size of the queue.
*/
readonly size: number;
/**
* Number of pending promises.
*/
readonly pending: number;
/**
* Whether the queue is currently paused.
*/
readonly isPaused: boolean;
constructor(opts?: PQueue.Options<TEnqueueOptions>);
/**
* Adds a sync or async task to the queue. Always returns a promise.
* @param fn Promise-returning/async function.
* @param opts
*/
add<T>(fn: PQueue.Task<T>, opts?: TEnqueueOptions): Promise<T>;
/**
* Same as `.add()`, but accepts an array of sync or async functions
* and returns a promise that resolves when all functions are resolved.
* @param fn Array of Promise-returning/async functions.
*/
addAll<TAll>(fns: Array<PQueue.Task<TAll>>, opts?: TEnqueueOptions): Promise<TAll[]>;
/**
* Returns a promise that settles when the queue becomes empty.
*
* Can be called multiple times. Useful if you for example add
* additional items at a later time.
*/
onEmpty(): Promise<void>;
/**
* Returns a promise that settles when the queue becomes empty, and all
* promises have completed; `queue.size === 0 && queue.pending === 0`.
*
* The difference with `.onEmpty` is that `.onIdle` guarantees that all work
* from the queue has finished. `.onEmpty` merely signals that the queue is
* empty, but it could mean that some promises haven't completed yet.
*/
onIdle(): Promise<void>;
/**
* Start (or resume) executing enqueued tasks within concurrency limit.
* No need to call this if queue is not paused
* (via `options.autoStart = false` or by `.pause()` method.)
*/
start(): void;
/**
* Clear the queue.
*/
clear(): void;
/**
* Put queue execution on hold.
*/
pause(): void;
addListener(event: 'active', listener: () => void): this;
on(event: 'active', listener: () => void): this;
once(event: 'active', listener: () => void): this;
prependListener(event: 'active', listener: () => void): this;
prependOnceListener(event: 'active', listener: () => void): this;
removeListener(event: 'active', listener: () => void): this;
off(event: 'active', listener: () => void): this;
removeAllListeners(event?: 'active'): this;
listeners(event: 'active'): Array<() => void>;
rawListeners(event: 'active'): Array<() => void>;
emit(event: 'active'): boolean;
eventNames(): Array<'active'>;
listenerCount(type: 'active'): number;
}
declare namespace PQueue {
interface QueueAddOptions {
[key: string]: any;
}
interface QueueClassConstructor<TEnqueueOptions extends QueueAddOptions> {
new (): QueueClass<TEnqueueOptions>;
}
interface QueueClass<TEnqueueOptions extends QueueAddOptions> {
size: number;
enqueue(run: () => void, options?: TEnqueueOptions): void;
dequeue(): (() => void) | undefined;
}
interface Options<TEnqueueOptions extends QueueAddOptions> {
/**
* Concurrency limit. Minimum: `1`.
* @default Infinity
*/
concurrency?: number;
/**
* Whether queue tasks within concurrency limit, are auto-executed as soon as they're added.
* @default true
*/
autoStart?: boolean;
/**
* Class with a `enqueue` and `dequeue` method, and a `size` getter. See the
* [Custom QueueClass](https://github.com/sindresorhus/p-queue#custom-queueclass) section.
*/
queueClass?: QueueClassConstructor<TEnqueueOptions>;
/**
* The max number of runs in the given interval of time. Minimum: `1`.
* @default Infinity
*/
intervalCap?: number;
/**
* The length of time in milliseconds before the interval count resets. Must be finite. Minimum: `0`.
* @default 0
*/
interval?: number;
/**
* Whether the task must finish in the given interval or will be carried over into the next interval count.
* @default false
*/
carryoverConcurrencyCount?: boolean;
}
interface DefaultAddOptions {
/**
* Priority of operation. Operations with greater priority will be scheduled first.
* @default 0
*/
priority?: number;
}
type Task<T> = (() => PromiseLike<T>) | (() => T);
}
-49
View File
@@ -1,49 +0,0 @@
import PQueue = require('p-queue');
const queue = new PQueue({ concurrency: 1 });
new PQueue({ autoStart: false });
new PQueue({ intervalCap: 1 });
new PQueue({ interval: 0 });
new PQueue({ carryoverConcurrencyCount: true });
queue.add(() => Promise.resolve('sindresorhus.com')); // $ExpectType Promise<string>
queue.add(() => 'sindresorhus.com'); // $ExpectType Promise<string>
queue.add(() => 'sindresorhus.com', { priority: 1 }); // $ExpectType Promise<string>
queue.addAll([() => Promise.resolve('oh'), () => 'hi']); // $ExpectType Promise<string[]>
queue.addAll<string | number>([() => Promise.resolve('oh'), () => 1]); // $ExpectType Promise<(string | number)[]>
queue.addAll([() => Promise.resolve('oh'), () => 'hi'], { priority: 1 }); // $ExpectType Promise<string[]>
queue.onEmpty(); // $ExpectType Promise<void>
queue.onIdle(); // $ExpectType Promise<void>
queue.start();
queue.pause();
queue.clear();
queue.size; // $ExpectType number
queue.size = 1; // $ExpectError
queue.pending; // $ExpectType number
queue.pending = 5; // $ExpectError
queue.isPaused; // $ExpectType boolean
queue.isPaused = true; // $ExpectError
class QueueClass implements PQueue.QueueClass<{ any: string }> {
private readonly queue: Array<() => void>;
size = 0;
constructor() {
this.queue = [];
}
enqueue(run: () => void, options: { any: string }) {
this.queue.push(run);
}
dequeue() {
return this.queue.shift();
}
}
const queue2 = new PQueue({ queueClass: QueueClass });
queue2.add(() => Promise.resolve(), { any: 'hi' });
-23
View File
@@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"p-queue-tests.ts"
]
}
-1
View File
@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }
-103
View File
@@ -1,103 +0,0 @@
// Type definitions for p-queue 2.3
// Project: https://github.com/sindresorhus/p-queue#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Evan Shortiss <https://github.com/evanshortiss>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
export = PQueue;
declare class PQueue<O extends PQueue.QueueAddOptions = PQueue.DefaultAddOptions> {
/**
* Size of the queue.
*/
size: number;
/**
* Number of pending promises.
*/
pending: number;
/**
* Whether the queue is currently paused.
*/
isPaused: boolean;
constructor(opts?: PQueue.Options<O>);
/**
* Returns the promise returned by calling fn.
* @param fn Promise-returning/async function.
*/
add<T>(fn: PQueue.Task<T>, opts?: O): Promise<T>;
/**
* Same as .add(), but accepts an array of async functions and
* returns a promise that resolves when all async functions are resolved.
* @param fn Array of Promise-returning/async functions.
*/
addAll<TAll>(fns: Array<PQueue.Task<TAll>>, opts?: O): Promise<TAll[]>;
/**
* Returns a promise that settles when the queue becomes empty.
* Can be called multiple times. Useful if you for example add
* additional items at a later time.
*/
onEmpty(): Promise<void>;
/**
* Returns a promise that settles when the queue becomes empty, and all
* promises have completed; queue.size === 0 && queue.pending === 0.
* The difference with .onEmpty is that .onIdle guarantees that all work
* from the queue has finished. .onEmpty merely signals that the queue is
* empty, but it could mean that some promises haven't completed yet.
*/
onIdle(): Promise<void>;
/**
* Start (or resume) executing enqueued tasks within concurrency limit.
* No need to call this if queue is not paused (via options.autoStart = false
* or by .pause() method.)
*/
start(): void;
/**
* Clear the queue.
*/
clear(): void;
/**
* Put queue execution on hold.
*/
pause(): void;
}
declare namespace PQueue {
interface QueueAddOptions {
[key: string]: any;
}
interface QueueClassConstructor<O extends QueueAddOptions> {
new(): QueueClass<O>;
}
interface QueueClass<O extends QueueAddOptions> {
size: number;
enqueue(run: () => void, options?: O): void;
dequeue(): (() => void) | undefined;
}
interface Options<O extends QueueAddOptions> {
concurrency?: number;
autoStart?: boolean;
queueClass?: QueueClassConstructor<O>;
}
interface DefaultAddOptions {
priority?: number;
}
type Task<T> = () => Promise<T>;
}
-51
View File
@@ -1,51 +0,0 @@
import PQueue = require("p-queue");
const queue = new PQueue({ concurrency: 1 });
queue
.add(() => Promise.resolve("sindresorhus.com"))
.then(sindre => {
const str: string = sindre;
});
queue.addAll([() => Promise.resolve("oh"), () => Promise.resolve("hi")]).then(r => {
r.indexOf("h");
});
Promise.resolve((): Promise<string> => Promise.resolve("unicorn"))
.then(task => queue.add(task, { priority: 5 }))
.then(unicorn => {
const str: string = unicorn;
});
queue.onEmpty().then(() => {});
queue.onIdle().then(() => {});
queue.start();
queue.pause();
queue.clear();
let num: number;
num = queue.size;
num = queue.pending;
const paused = queue.isPaused;
class QueueClass implements PQueue.QueueClass<{ any: string }> {
private readonly queue: Array<() => void>;
size = 0;
constructor() {
this.queue = [];
}
enqueue(run: () => void, options: { any: string }) {
this.queue.push(run);
}
dequeue() {
return this.queue.shift();
}
}
const queue2 = new PQueue({ queueClass: QueueClass });
queue2.add(() => Promise.resolve(), { any: "hi" });
-26
View File
@@ -1,26 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"p-queue": [ "p-queue/v2" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"p-queue-tests.ts"
]
}
-1
View File
@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }
+1 -2
View File
@@ -1,5 +1,4 @@
import sinon = require("sinon");
import Bluebird = require("bluebird");
function testSandbox() {
const obj = {};
@@ -427,7 +426,7 @@ function testStub() {
const obj = class {
foo() { }
promiseFunc() { return Promise.resolve('foo'); }
promiseLikeFunc() { return {} as any as Bluebird<string>; }
promiseLikeFunc() { return Promise.resolve('foo') as PromiseLike<string>; }
};
const instance = new obj();
+2 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for tern 0.22
// Type definitions for tern 0.23
// Project: https://github.com/ternjs/tern
// Definitions by: Nikolaj Kappler <https://github.com/nkappler>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -11,5 +11,5 @@
// thus if you want to use undocumented APIs, you should extends these definitions with
// ambient declaration merging: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
export * from "./lib/tern";
export * from "./lib/infer";
export * from "./lib/tern";
+35 -11
View File
@@ -1,12 +1,14 @@
import * as ESTree from "estree";
import { Server } from "../tern";
export { };
// #### Context ####
interface ContextConstructor {
new(defs: any[]): Context;
new(defs: any[], parent: Server): Context;
}
export const Context: ContextConstructor;
export interface Context {
parent?: Server;
topScope: Scope;
/** The primitive number type. */
num: Type;
@@ -15,8 +17,10 @@ export interface Context {
/** The primitive boolean type. */
bool: Type;
}
/** Returns the current context object. */
export function cx(): Context;
export function withContext(context: Context, f: () => void): void;
/** Calls f with the current context bound to context. Basically, all code that does something with the inference engine should be wrapped in such a call. */
export function withContext<R>(context: Context, f: () => R): R;
// #### Analysis ####
/** Parse a piece of code for use by Tern. Will automatically fall back to the error-tolerant parser if the regular parser can’t parse the code. */
@@ -59,6 +63,7 @@ export interface Obj extends Type {
hasProp(prop: string): AVal | null;
/** Looks up the given property, or defines it if it did not yet exist (in which case it will be associated with the given AST node). */
defProp(prop: string, originNode?: ESTree.Node): AVal;
getType(): Obj;
}
interface FnConstructor {
@@ -66,18 +71,27 @@ interface FnConstructor {
}
/** Constructor for the type that implements functions. Inherits from `Obj`. The `AVal` types are used to track the input and output types of the function. */
export const Fn: FnConstructor;
export type Fn = Obj;
export interface Fn extends Obj {
readonly args?: AVal[];
readonly argNames?: string[];
self?: Type;
readonly retval: AVal;
isArrowFn(): boolean;
getType(): Fn;
}
interface ArrConstructor {
/** Constructor that creates an array type with the given content type. */
new(contentType: AVal): Arr;
new(contentType?: AVal): Arr;
}
export const Arr: ArrConstructor;
export type Arr = Obj;
export interface Arr extends Obj {
getType(): Arr;
}
export interface Type extends AVal {
/** The name of the type, if any. */
name: string;
name: string | undefined;
/** The origin file of the type. */
origin: string;
/**
@@ -88,10 +102,9 @@ export interface Type extends AVal {
originNode?: ESTree.Node;
/** Return a string that describes the type. maxDepth indicates the depth to which inner types should be shown. */
toString(maxDepth: number): string;
/** Get an `AVal` that represents the named property of this type. */
getProp(prop: string): AVal;
/** Call the given function for all properties of the object, including properties that are added in the future. */
forAllProps(f: (prop: string, val: AVal, local: boolean) => void): void;
getType(): Type;
}
// #### Abstract Values ####
@@ -131,13 +144,23 @@ export interface AVal {
* Asks the AVal if it contains a function type. Useful when
* you aren’t interested in other kinds of types.
*/
getFunctionType(): Type | undefined;
getFunctionType(): Fn | undefined;
/** Get an `AVal` that represents the named property of this type. */
getProp(prop: string): AVal;
/**
* Asks the AVal if it contains an Object type. Useful when
* you aren’t interested in other kinds of types.
*/
getObjType(): Obj | null;
/**
* Abstract values that are used to represent variables
* or properties will have, when possible, an `originNode`
* property pointing to an AST node.
*/
originNode?: ESTree.Node;
readonly types: Type[];
readonly propertyOf?: Obj;
}
export const ANull: ANull;
@@ -170,7 +193,8 @@ export interface Constraint extends AVal {
// #### Scopes ####
interface ScopeConstructor {
new(parent?: Scope): Scope;
new(): Scope;
new(parent: Scope, originNode: ESTree.Node): Scope;
}
export const Scope: ScopeConstructor;
export interface Scope extends Obj {
@@ -199,7 +223,7 @@ export function findExpressionAround(ast: ESTree.Program, start: number | undefi
/** Similar to `findExpressionAround`, except that it use the same AST walker as `findExpressionAt`. */
export function findClosestExpression(ast: ESTree.Program, start: number | undefined, end: number, scope?: Scope): { node: ESTree.Node, state: Scope } | null;
/** Determine an expression for the given node and scope (as returned by the functions above). Will return an `AVal` or plain `Type`. */
export function expressionType(expr: { node: ESTree.Node, state: Scope }): AVal | Type;
export function expressionType(expr: { node: ESTree.Node, state: Scope | null }): AVal | Type;
/** Find the scope at a given position in the syntax tree. The `scope` parameter can be used to override the scope used for code that isn’t wrapped in any function. */
export function scopeAt(ast: ESTree.Program, pos: number, scope?: Scope): Scope;
/**
+9 -2
View File
@@ -1,5 +1,5 @@
import * as ESTree from "estree";
import { Scope, Type } from "../infer";
import { Context, Scope, Type } from "../infer";
export { };
@@ -48,6 +48,10 @@ interface TernConstructor {
export const Server: TernConstructor;
export interface Server {
readonly cx: Context;
readonly options: ConstructorOptions;
readonly files: File[];
readonly plugins: any;
/**
* Add a set of type definitions to the server. If `atFront` is true, they will be added before all other
* existing definitions. Otherwise, they are added at the back.
@@ -93,10 +97,12 @@ export interface Server {
request<Q extends Query, D extends Document>(
doc: D & { query?: Q },
callback: (
error: Error | undefined,
error: string | null,
response: (D extends { query: undefined } ? {} : D extends { query: Query } ? QueryResult<Q> : {}) | undefined
) => void
): void;
reset(): void;
signal(event: keyof Events, file: File): void;
}
// #### JSON Protocol ####
@@ -156,6 +162,7 @@ export interface File {
scope: Scope;
ast: ESTree.Program;
type?: "full" | "part" | "delete";
asLineChar?(nodePosition: number): Position;
}
export interface BaseQuery {
+4 -4
View File
@@ -394,7 +394,7 @@ export class Editor extends util.Observable {
addCommand(name: string, callback: (ui: boolean, value: {}) => boolean, scope?: {}): void;
addContextToolbar(predicate: () => void, items: string): void;
addContextToolbar(predicate: () => boolean, items: string): void;
addMenuItem(name: string, settings: {}): void;
@@ -414,7 +414,7 @@ export class Editor extends util.Observable {
execCallback(name: string): {};
execCommand(cmd: string, ui: boolean, value?: any, args?: {}): void;
execCommand(cmd: string, ui?: boolean, value?: any, args?: {}): void;
focus(skipFocus: boolean): void;
@@ -838,7 +838,7 @@ export namespace dom {
insertAfter<T>(node: Element, referenceNode: Element): Element | T[];
is(elm: Node, selector: string): void;
is(elm: Node, selector: string): boolean;
isBlock(node: Node): boolean;
@@ -1072,7 +1072,7 @@ export namespace dom {
setContent(content: string, args?: {}): void;
setCursorLocation(node?: html.Node, offset?: number): void;
setCursorLocation(node?: Node, offset?: number): void;
setNode(elm: Element): Element;