mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
merged master
This commit is contained in:
@@ -46,6 +46,7 @@ npm-debug.log
|
||||
.settings/launch.json
|
||||
.vs
|
||||
.vscode
|
||||
.history
|
||||
|
||||
# yarn
|
||||
yarn.lock
|
||||
|
||||
+19
-1
@@ -144,6 +144,12 @@
|
||||
"sourceRepoURL": "https://github.com/Azure/azure-mobile-apps-node/",
|
||||
"asOfVersion": "3.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "@babel/parser",
|
||||
"typingsPackageName": "babel__parser",
|
||||
"sourceRepoURL": "https://github.com/babel/babel",
|
||||
"asOfVersion": "7.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "BabylonJS",
|
||||
"typingsPackageName": "babylonjs",
|
||||
@@ -630,6 +636,12 @@
|
||||
"sourceRepoURL": "https://github.com/mikedeboer/node-github",
|
||||
"asOfVersion": "7.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "gitlab",
|
||||
"typingsPackageName": "gitlab",
|
||||
"sourceRepoURL": "https://github.com/jdalrymple/node-gitlab",
|
||||
"asOfVersion": "2.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "graphene-pk11",
|
||||
"typingsPackageName": "graphene-pk11",
|
||||
@@ -948,6 +960,12 @@
|
||||
"sourceRepoURL": "http://maquettejs.org/",
|
||||
"asOfVersion": "2.1.6"
|
||||
},
|
||||
{
|
||||
"libraryName": "maxmind",
|
||||
"typingsPackageName": "maxmind",
|
||||
"sourceRepoURL": "https://github.com/runk/node-maxmind",
|
||||
"asOfVersion": "2.0.5"
|
||||
},
|
||||
{
|
||||
"libraryName": "mendixmodelsdk",
|
||||
"typingsPackageName": "mendixmodelsdk",
|
||||
@@ -988,7 +1006,7 @@
|
||||
"libraryName": "Mobx Cookie",
|
||||
"typingsPackageName": "mobx-cookie",
|
||||
"sourceRepoURL": "https://github.com/will-stone/mobx-cookie",
|
||||
"asOfVersion": "1.1.0"
|
||||
"asOfVersion": "1.1.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "Moment",
|
||||
|
||||
Vendored
+2
-2
@@ -64,7 +64,7 @@ declare class Agenda extends EventEmitter {
|
||||
defaultConcurrency(value: number): this;
|
||||
|
||||
/**
|
||||
* Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is
|
||||
* Takes a number which specifies the max number jobs that can be locked at any given moment. By default it is
|
||||
* 0 for no max.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
@@ -189,7 +189,7 @@ declare namespace Agenda {
|
||||
defaultLockLimit?: number;
|
||||
|
||||
/**
|
||||
* Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is
|
||||
* Takes a number which specifies the max number jobs that can be locked at any given moment. By default it is
|
||||
* 0 for no max.
|
||||
*/
|
||||
lockLimit?: number;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
Vendored
+1
@@ -76,6 +76,7 @@ declare module 'angular' {
|
||||
|
||||
interface IConfirmDialog extends IPresetDialog<IConfirmDialog> {
|
||||
cancel(cancel: string): IConfirmDialog;
|
||||
multiple(multiple: boolean): IConfirmDialog;
|
||||
}
|
||||
|
||||
interface IPromptDialog extends IPresetDialog<IPromptDialog> {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { addPath, enableForDir, removePath } from 'app-module-path';
|
||||
|
||||
addPath('/tmp');
|
||||
|
||||
enableForDir('/tmp');
|
||||
|
||||
removePath('/tmp');
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// Type definitions for app-module-path 2.2
|
||||
// Project: https://github.com/patrick-steele-idem/app-module-path-node
|
||||
// Definitions by: Timur Manyanov <https://github.com/darkwebdev>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
export function addPath(path: string, parent?: any): void;
|
||||
|
||||
export function enableForDir(dir: string): void;
|
||||
|
||||
export function removePath(path: string): void;
|
||||
@@ -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",
|
||||
"app-module-path-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -1 +1,6 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
-2
@@ -4,8 +4,6 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as Promise from 'bluebird';
|
||||
|
||||
export interface ManagementClientOptions {
|
||||
token?: string;
|
||||
domain: string;
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
import Timeout from "await-timeout";
|
||||
|
||||
/**
|
||||
* This test is just a TS-friendly version of the await-timeout README:
|
||||
* https://github.com/vitalets/await-timeout/blob/v0.3.0/README.md
|
||||
*
|
||||
* How to generate this file:
|
||||
* 1. Paste the source code of README.md
|
||||
* 2. Replace every code fence with async () => {}
|
||||
* 3. Comment out all other lines
|
||||
* 4. Add and remove import statements and repeated statements
|
||||
* 5. Declare required globals
|
||||
*/
|
||||
|
||||
// -- Globals --
|
||||
declare const fetch: (url: string) => Promise<any>;
|
||||
declare const console: any;
|
||||
declare const MyTimeoutError: any;
|
||||
|
||||
// --- README ---
|
||||
|
||||
// ## Usage
|
||||
// 1. Just wait some time:
|
||||
async () => {
|
||||
// wait 1000 ms and resolve
|
||||
await Timeout.set(1000);
|
||||
|
||||
// wait 1000 ms and reject with 'Error'
|
||||
await Timeout.set(1000, 'Error');
|
||||
};
|
||||
|
||||
// 2. Use `Timeout` instance inside `try...finally` block to make proper cleanup:
|
||||
async () => {
|
||||
const timer = new Timeout();
|
||||
try {
|
||||
await Promise.race([
|
||||
fetch('https://example.com'),
|
||||
timer.set(1000)
|
||||
.then(() => Promise.reject('Timeout'))
|
||||
]);
|
||||
} finally {
|
||||
timer.clear();
|
||||
}
|
||||
};
|
||||
|
||||
// ## API
|
||||
// ### new Timeout()
|
||||
// Constructs new timeout instance. It does not start timer but creates variable for timer manipulation.
|
||||
async () => {
|
||||
const timer = new Timeout();
|
||||
};
|
||||
// > Note : having separate variable is useful for clearing timeout in `finally` block
|
||||
|
||||
// ### .set(ms, [message]) ⇒ `Promise`
|
||||
// Starts new timer like `setTimeout()` and returns promise. The promise will be resolved after `ms` milliseconds:
|
||||
async () => {
|
||||
const timer = new Timeout();
|
||||
timer.set(1000)
|
||||
.then(() => console.log('1000 ms passed.'));
|
||||
};
|
||||
|
||||
// If you need to reject after timeout:
|
||||
async () => {
|
||||
const timer = new Timeout();
|
||||
timer.set(1000)
|
||||
.then(() => {throw new Error('Timeout'); });
|
||||
};
|
||||
|
||||
// Or reject with custom error:
|
||||
async () => {
|
||||
const timer = new Timeout();
|
||||
timer.set(1000)
|
||||
.then(() => {throw new MyTimeoutError(); });
|
||||
};
|
||||
// The second parameter `message` is just convenient way to reject with `new Error(message)`:
|
||||
async () => {
|
||||
const timer = new Timeout();
|
||||
timer.set(1000, 'Timeout');
|
||||
// is equivalent to
|
||||
timer.set(1000).then(() => {throw new Error('Timeout'); });
|
||||
};
|
||||
|
||||
// If you need to just wait some time - use static version of `.set()` :
|
||||
async () => {
|
||||
Timeout.set(1000).then(/*...*/);
|
||||
};
|
||||
|
||||
// ### .wrap(promise, ms, [message]) ⇒ `Promise`
|
||||
// Wraps existing promise with timeout:
|
||||
// * promise automatically rejected after timeout
|
||||
// * timeout automatically cleared if promise fulfills first
|
||||
async () => {
|
||||
const promise = fetch('https://example.com');
|
||||
|
||||
const timeoutedPromise = Timeout.wrap(promise, 1000, 'Timeout');
|
||||
};
|
||||
// Actually it is a shortcut for :
|
||||
async () => {
|
||||
const promise = fetch('https://example.com');
|
||||
|
||||
const timer = new Timeout();
|
||||
try {
|
||||
const timeoutedPromise = await Promise.race([
|
||||
promise,
|
||||
timer.set(1000, 'Timeout')
|
||||
]);
|
||||
} finally {
|
||||
timer.clear();
|
||||
}
|
||||
};
|
||||
|
||||
// ### .clear()
|
||||
// Clears existing timeout like `clearTimeout()`.
|
||||
async () => {
|
||||
const timer = new Timeout();
|
||||
timer.set(1000)
|
||||
.then(() => console.log('This will never be called, because timeout is cleared on the next line'));
|
||||
timer.clear();
|
||||
};
|
||||
|
||||
// With [ES7 async / await ] `.clear()` can be used in `finally` block:
|
||||
async () => {
|
||||
async function foo() {
|
||||
const timer = new Timeout();
|
||||
try {
|
||||
// some async stuff
|
||||
} finally {
|
||||
timer.clear();
|
||||
}
|
||||
}
|
||||
};
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// Type definitions for await-timeout 0.3
|
||||
// Project: https://github.com/vitalets/await-timeout
|
||||
// Definitions by: Sean Zhu <https://github.com/szhu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export default Timeout;
|
||||
|
||||
declare class Timeout {
|
||||
static set(delay: number): Promise<undefined>;
|
||||
static set(delay: number, message: string): Promise<never>;
|
||||
|
||||
static wrap(promise: Promise<any>, delay: number, error?: string): Promise<any>;
|
||||
|
||||
set(delay: number): Promise<undefined>;
|
||||
set(delay: number, message: string): Promise<never>;
|
||||
clear(): void;
|
||||
}
|
||||
@@ -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",
|
||||
"await-timeout-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
+1
-1
@@ -75,7 +75,7 @@ export namespace Azure.ServiceBus {
|
||||
DefaultMessageTimeToLive: string;
|
||||
DuplicateDetectionHistoryTimeWindow: string;
|
||||
EnablePartitioning: boolean;
|
||||
MaxSizeInMegaBytes: number;
|
||||
MaxSizeInMegabytes: number;
|
||||
RequiresDuplicateDetection: boolean;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -4,16 +4,16 @@
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import { GeneratorOptions } from "@babel/generator";
|
||||
import traverse, { Visitor, NodePath } from "@babel/traverse";
|
||||
import template from "@babel/template";
|
||||
import * as t from "@babel/types";
|
||||
import { ParseOptions } from "@babel/parser";
|
||||
import { ParserOptions } from "@babel/parser";
|
||||
|
||||
export {
|
||||
ParseOptions,
|
||||
ParserOptions,
|
||||
GeneratorOptions,
|
||||
t as types,
|
||||
template,
|
||||
@@ -217,7 +217,7 @@ export interface TransformOptions {
|
||||
*
|
||||
* Default: `{}`
|
||||
*/
|
||||
parserOpts?: ParseOptions | null;
|
||||
parserOpts?: ParserOptions | null;
|
||||
|
||||
/**
|
||||
* List of plugins to load and use
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.0.0-beta.54"
|
||||
"@babel/parser": "^7.1.0",
|
||||
"@babel/types": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
"@babel/generator": [
|
||||
"babel__generator"
|
||||
],
|
||||
"@babel/parser": [
|
||||
"babel__parser"
|
||||
],
|
||||
"@babel/template": [
|
||||
"babel__template"
|
||||
],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Example from https://github.com/babel/babel/tree/master/packages/babel-generator
|
||||
import generate from "@babel/generator";
|
||||
import { parse } from "@babel/parser";
|
||||
import * as t from "@babel/types";
|
||||
|
||||
const code = "class Example {}";
|
||||
const ast = parse(code);
|
||||
declare const ast: t.Node;
|
||||
|
||||
ast.type;
|
||||
ast.loc!.start;
|
||||
|
||||
Vendored
+1
-1
@@ -4,7 +4,7 @@
|
||||
// Johnny Estilles <https://github.com/johnnyestilles>
|
||||
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import * as t from "@babel/types";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.0.0-beta.54"
|
||||
"@babel/types": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
"paths": {
|
||||
"@babel/generator": [
|
||||
"babel__generator"
|
||||
],
|
||||
"@babel/parser": [
|
||||
"babel__parser"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { parse, parseExpression } from "@babel/parser";
|
||||
|
||||
declare function assert(expr: boolean): void;
|
||||
|
||||
const code = `function square(n) {
|
||||
return n * n;
|
||||
}`;
|
||||
|
||||
const node = parse(code);
|
||||
assert(node.type === "File");
|
||||
assert(node.start === 0);
|
||||
assert(node.end === 38);
|
||||
assert(!!node.loc && node.loc.start > node.loc.end);
|
||||
|
||||
parse(code, {
|
||||
sourceType: "module", // default: "script"
|
||||
plugins: ["jsx"] // default: []
|
||||
});
|
||||
Vendored
-107
@@ -1,107 +0,0 @@
|
||||
// Type definitions for @babel/parser 7.0
|
||||
// Project: https://github.com/babel/babel/tree/master/packages/babel-parser
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { File, Expression } from "@babel/types";
|
||||
|
||||
export function parse(code: string, opts?: ParseOptions): File;
|
||||
|
||||
export function parseExpression(input: string, options?: ParseOptions): Expression;
|
||||
|
||||
export interface ParseOptions {
|
||||
/**
|
||||
* By default, import and export declarations can only appear at a program's top level.
|
||||
* Setting this option to true allows them anywhere where a statement is allowed.
|
||||
*/
|
||||
allowImportExportEverywhere?: boolean;
|
||||
|
||||
/**
|
||||
* By default, await use is not allowed outside of an async function. Set this to true to accept such code.
|
||||
*/
|
||||
allowAwaitOutsideFunction?: boolean;
|
||||
|
||||
/**
|
||||
* By default, a return statement at the top level raises an error. Set this to true to accept such code.
|
||||
*/
|
||||
allowReturnOutsideFunction?: boolean;
|
||||
|
||||
allowSuperOutsideMethod?: boolean;
|
||||
|
||||
/**
|
||||
* Indicate the mode the code should be parsed in. Can be one of "script", "module", or "unambiguous".
|
||||
* Defaults to "script". "unambiguous" will make @babel/parser attempt to guess, based on the presence of ES6 import or export
|
||||
* statements. Files with ES6 imports and exports are considered "module" and are otherwise "script".
|
||||
*/
|
||||
sourceType?: "script" | "module" | "unambiguous";
|
||||
|
||||
/**
|
||||
* Correlate output AST nodes with their source filename. Useful when
|
||||
* generating code and source maps from the ASTs of multiple input files.
|
||||
*/
|
||||
sourceFilename?: string;
|
||||
|
||||
/**
|
||||
* By default, the first line of code parsed is treated as line 1. You can provide a line number to alternatively start with. Useful
|
||||
* for integration with other source tools.
|
||||
*/
|
||||
startLine?: number;
|
||||
|
||||
/**
|
||||
* Array containing the plugins that you want to enable.
|
||||
*/
|
||||
plugins?: PluginList;
|
||||
|
||||
strictMode?: boolean;
|
||||
|
||||
/**
|
||||
* Adds a `ranges` property to each node: `[node.start, node.end]`
|
||||
*/
|
||||
ranges?: boolean;
|
||||
|
||||
/**
|
||||
* Adds all parsed tokens to a `tokens` property on the `File` node
|
||||
*/
|
||||
tokens?: boolean;
|
||||
}
|
||||
|
||||
export type PluginList = Array<PluginName | [PluginName, PluginOptions]>;
|
||||
|
||||
export type PluginName =
|
||||
"asyncGenerators" |
|
||||
"bigInt" |
|
||||
"classPrivateMethods" |
|
||||
"classPrivateProperties" |
|
||||
"classProperties" |
|
||||
"decorators" |
|
||||
"doExpressions" |
|
||||
"dynamicImport" |
|
||||
"estree" |
|
||||
"exportDefaultFrom" |
|
||||
"exportNamespaceFrom" |
|
||||
"flow" |
|
||||
"flowComments" |
|
||||
"functionBind" |
|
||||
"functionSent" |
|
||||
"importMeta" |
|
||||
"jsx" |
|
||||
"nullishCoalescingOperator" |
|
||||
"numericSeparator" |
|
||||
"objectRestSpread" |
|
||||
"optionalCatchBinding" |
|
||||
"optionalChaining" |
|
||||
"pipelineOperator" |
|
||||
"throwExpressions" |
|
||||
"typescript";
|
||||
|
||||
export interface PluginOptions {
|
||||
decorators?: {
|
||||
decoratorsBeforeExport?: boolean;
|
||||
};
|
||||
flow?: {
|
||||
all?: boolean;
|
||||
};
|
||||
}
|
||||
Vendored
+3
-3
@@ -4,12 +4,12 @@
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import { ParseOptions } from "@babel/parser";
|
||||
import { ParserOptions } from "@babel/parser";
|
||||
import { Expression, File, Program, Statement } from "@babel/types";
|
||||
|
||||
export interface TemplateBuilderOptions extends ParseOptions {
|
||||
export interface TemplateBuilderOptions extends ParserOptions {
|
||||
/**
|
||||
* A set of placeholder names to automatically accept. Items in this list do not need to match the given placeholder pattern.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.0.0-beta.54"
|
||||
"@babel/parser": "^7.1.0",
|
||||
"@babel/types": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
"@babel/generator": [
|
||||
"babel__generator"
|
||||
],
|
||||
"@babel/parser": [
|
||||
"babel__parser"
|
||||
],
|
||||
"@babel/template": [
|
||||
"babel__template"
|
||||
]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { parse } from "@babel/parser";
|
||||
import traverse, { Visitor } from "@babel/traverse";
|
||||
import * as t from "@babel/types";
|
||||
|
||||
@@ -21,11 +20,7 @@ const MyVisitor2: Visitor = {
|
||||
};
|
||||
|
||||
// Example from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-traverse
|
||||
const code = `function square(n) {
|
||||
return n * n;
|
||||
}`;
|
||||
|
||||
const ast = parse(code);
|
||||
declare const ast: t.Node;
|
||||
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
// Ryan Petrich <https://github.com/rpetrich>
|
||||
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import * as t from "@babel/types";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.0.0-beta.54"
|
||||
"@babel/types": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@babel/parser": [
|
||||
"babel__parser"
|
||||
],
|
||||
"@babel/traverse": [
|
||||
"babel__traverse"
|
||||
]
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
Vendored
+129
-2
@@ -4,13 +4,15 @@
|
||||
// Natan Vivo <https://github.com/nvivo>,
|
||||
// Sven Tschui <https://github.com/sventschui>,
|
||||
// Volker Nauruhn <https://github.com/razorness>,
|
||||
// Ard Timmerman <https://github.com/confususs>
|
||||
// Ard Timmerman <https://github.com/confususs>,
|
||||
// J. Joe Koullas <https://github.com/jjoekoullas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as Backbone from 'backbone';
|
||||
import * as JQuery from 'jquery';
|
||||
import * as Radio from 'backbone.radio';
|
||||
import * as _ from 'underscore';
|
||||
|
||||
export as namespace Marionette;
|
||||
|
||||
@@ -179,6 +181,131 @@ export class Container<TView> {
|
||||
* Find a view by it's cid.
|
||||
*/
|
||||
remove(view: TView): void;
|
||||
|
||||
/**
|
||||
* @see _.forEach
|
||||
*/
|
||||
forEach(iterator: _.ListIterator<TView, void>, context?: any): Container<TView>;
|
||||
|
||||
/**
|
||||
* @see _.each
|
||||
*/
|
||||
each(iterator: _.ListIterator<TView, void>, context?: any): Container<TView>;
|
||||
|
||||
/**
|
||||
* @see _.map
|
||||
*/
|
||||
map<TResult>(iterator: _.ListIterator<TView, TResult>, context?: any): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.find
|
||||
*/
|
||||
find(iterator: _.ListIterator<TView, boolean>, context?: any): Container<TView> | undefined;
|
||||
|
||||
/**
|
||||
* @see _.detect
|
||||
*/
|
||||
detect(iterator: _.ListIterator<TView, boolean>, context?: any): Container<TView> | undefined;
|
||||
|
||||
/**
|
||||
* @see _.filter
|
||||
*/
|
||||
filter(iterator: _.ListIterator<TView, boolean>, context?: any): TView[];
|
||||
|
||||
/**
|
||||
* @see _.select
|
||||
*/
|
||||
select(iterator: _.ListIterator<TView, boolean>, context?: any): TView[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject(iterator: _.ListIterator<TView, boolean>, context?: any): TView[];
|
||||
|
||||
/**
|
||||
* @see _.every
|
||||
*/
|
||||
every(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.all
|
||||
*/
|
||||
all(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
some(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.any
|
||||
*/
|
||||
any(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.include
|
||||
*/
|
||||
include(value: TView, fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
*/
|
||||
contains(value: TView, fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.invoke
|
||||
*/
|
||||
invoke(methodName: string, ...args: any[]): any;
|
||||
|
||||
/**
|
||||
* @see _.toArray
|
||||
*/
|
||||
toArray(): TView[];
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
*/
|
||||
first(): TView | undefined;
|
||||
|
||||
/**
|
||||
* @see _.initial
|
||||
*/
|
||||
initial(n?: number): TView[];
|
||||
|
||||
/**
|
||||
* @see _.rest
|
||||
*/
|
||||
rest(n?: number): TView[];
|
||||
|
||||
/**
|
||||
* @see _.last
|
||||
*/
|
||||
last(n: number): TView[];
|
||||
|
||||
/**
|
||||
* @see _.without
|
||||
*/
|
||||
without(...values: TView[]): TView[];
|
||||
|
||||
/**
|
||||
* @see _.isEmpty
|
||||
*/
|
||||
isEmpty(): boolean;
|
||||
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck(propertyName: string): any[];
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
*/
|
||||
reduce<TResult>(iterator: _.MemoIterator<TView, TResult>, memo?: TResult, context?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
*/
|
||||
partition(iterator: _.ListIterator<TView, boolean>, context?: any): TView[][];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1154,7 +1281,7 @@ export class View<TModel extends Backbone.Model> extends Backbone.View<TModel> i
|
||||
export interface CollectionViewOptions<
|
||||
TModel extends Backbone.Model,
|
||||
TCollection extends Backbone.Collection<TModel> = Backbone.Collection<TModel>
|
||||
> extends Backbone.ViewOptions<TModel>, ViewMixinOptions {
|
||||
> extends Backbone.ViewOptions<TModel>, ViewMixinOptions {
|
||||
/**
|
||||
* Specify a child view to use.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ pdfQueue
|
||||
.on('failed', (job: Queue.Job) => undefined)
|
||||
.on('paused', () => undefined)
|
||||
.on('resumed', () => undefined)
|
||||
.on('cleaned', (jobs: Queue.Job[], status: Queue.JobStatus) => undefined)
|
||||
.on('cleaned', (jobs: Queue.Job[], status: Queue.JobStatusClean) => undefined)
|
||||
.on('drained', () => undefined)
|
||||
.on('removed', (job: Queue.Job) => undefined);
|
||||
|
||||
|
||||
Vendored
+5
-3
@@ -11,6 +11,7 @@
|
||||
// Wuha Team <https://github.com/wuha-team>
|
||||
// Alec Brunelle <https://github.com/aleccool213>
|
||||
// Dan Manastireanu <https://github.com/danmana>
|
||||
// Kjell-Morten Bratsberg Thorsen <https://github.com/kjellmorten>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -194,6 +195,7 @@ declare namespace Bull {
|
||||
}
|
||||
|
||||
type JobStatus = 'completed' | 'waiting' | 'active' | 'delayed' | 'failed';
|
||||
type JobStatusClean = 'completed' | 'wait' | 'active' | 'delayed' | 'failed';
|
||||
|
||||
interface BackoffOptions {
|
||||
/**
|
||||
@@ -635,12 +637,12 @@ declare namespace Bull {
|
||||
|
||||
/**
|
||||
* Tells the queue remove all jobs created outside of a grace period in milliseconds.
|
||||
* You can clean the jobs with the following states: completed, waiting, active, delayed, and failed.
|
||||
* You can clean the jobs with the following states: completed, wait (typo for waiting), active, delayed, and failed.
|
||||
* @param grace Grace period in milliseconds.
|
||||
* @param status Status of the job to clean. Values are completed, wait, active, delayed, and failed. Defaults to completed.
|
||||
* @param limit Maximum amount of jobs to clean per call. If not provided will clean all matching jobs.
|
||||
*/
|
||||
clean(grace: number, status?: JobStatus, limit?: number): Promise<Array<Job<T>>>;
|
||||
clean(grace: number, status?: JobStatusClean, limit?: number): Promise<Array<Job<T>>>;
|
||||
|
||||
/**
|
||||
* Listens to queue events
|
||||
@@ -734,7 +736,7 @@ declare namespace Bull {
|
||||
|
||||
type FailedEventCallback<T = any> = (job: Job<T>, error: Error) => void;
|
||||
|
||||
type CleanedEventCallback<T = any> = (jobs: Array<Job<T>>, status: JobStatus) => void;
|
||||
type CleanedEventCallback<T = any> = (jobs: Array<Job<T>>, status: JobStatusClean) => void;
|
||||
|
||||
type RemovedEventCallback<T = any> = (job: Job<T>) => void;
|
||||
|
||||
|
||||
-238
@@ -1,239 +1 @@
|
||||
// Type definitions for business-rules-engine - v1.0.20
|
||||
// Project: https://github.com/rsamec/form
|
||||
// Definitions by: Roman Samec <https://github.com/rsamec>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace Validation {
|
||||
interface IErrorCustomMessage {
|
||||
(config: any, args: any): string;
|
||||
}
|
||||
interface IPropertyValidator {
|
||||
isAcceptable(s: any): boolean;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
tagName?: string;
|
||||
}
|
||||
interface IStringValidator extends IPropertyValidator {
|
||||
isAcceptable(s: string): boolean;
|
||||
}
|
||||
interface IAsyncPropertyValidator {
|
||||
isAcceptable(s: any): Q.Promise<boolean>;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
isAsync: boolean;
|
||||
tagName?: string;
|
||||
}
|
||||
interface IAsyncStringPropertyValidator extends IAsyncPropertyValidator {
|
||||
isAcceptable(s: string): Q.Promise<boolean>;
|
||||
}
|
||||
enum CompareOperator {
|
||||
LessThan = 0,
|
||||
LessThanEqual = 1,
|
||||
Equal = 2,
|
||||
NotEqual = 3,
|
||||
GreaterThanEqual = 4,
|
||||
GreaterThan = 5,
|
||||
}
|
||||
interface IError {
|
||||
HasError: boolean;
|
||||
ErrorMessage: string;
|
||||
TranslateArgs?: IErrorTranslateArgs;
|
||||
}
|
||||
interface IErrorTranslateArgs {
|
||||
TranslateId: string;
|
||||
MessageArgs: any;
|
||||
CustomMessage?: IErrorCustomMessage;
|
||||
}
|
||||
interface IOptional {
|
||||
(): boolean;
|
||||
}
|
||||
interface IValidationFailure extends IError {
|
||||
IsAsync: boolean;
|
||||
Error: IError;
|
||||
}
|
||||
interface IValidationResult {
|
||||
Name: string;
|
||||
Add(validationResult: IValidationResult): void;
|
||||
Remove(index: number): void;
|
||||
Children: IValidationResult[];
|
||||
HasErrors: boolean;
|
||||
HasErrorsDirty: boolean;
|
||||
ErrorMessage: string;
|
||||
ErrorCount: number;
|
||||
Optional?: IOptional;
|
||||
TranslateArgs?: IErrorTranslateArgs[];
|
||||
}
|
||||
interface IValidate {
|
||||
(args: IError): void;
|
||||
}
|
||||
interface IAsyncValidate {
|
||||
(args: IError): Q.Promise<any>;
|
||||
}
|
||||
interface IValidatorFce {
|
||||
Name: string;
|
||||
ValidationFce?: IValidate;
|
||||
AsyncValidationFce?: IAsyncValidate;
|
||||
}
|
||||
interface IValidator {
|
||||
Validate(context: any): IValidationFailure;
|
||||
ValidateAsync(context: any): Q.Promise<IValidationFailure>;
|
||||
Error: IError;
|
||||
}
|
||||
interface IAbstractValidator<T> {
|
||||
RuleFor(prop: string, validator: IPropertyValidator): any;
|
||||
ValidationFor(prop: string, validatorFce: IValidatorFce): any;
|
||||
Validation(validatorFce: IValidatorFce): any;
|
||||
ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>): any;
|
||||
CreateRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractListRule(name: string): IAbstractValidationRule<any>;
|
||||
ForList: boolean;
|
||||
}
|
||||
interface IAbstractValidationRule<T> {
|
||||
Validate(context: T): IValidationResult;
|
||||
ValidateAsync(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateAll(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateProperty(context: T, propName: string): void;
|
||||
ValidationResult: IValidationResult;
|
||||
Rules: {
|
||||
[name: string]: IPropertyValidationRule<T>;
|
||||
};
|
||||
Validators: {
|
||||
[name: string]: IValidator;
|
||||
};
|
||||
Children: {
|
||||
[name: string]: IAbstractValidationRule<any>;
|
||||
};
|
||||
}
|
||||
interface IPropertyValidationRule<T> {
|
||||
Validators: {
|
||||
[name: string]: any;
|
||||
};
|
||||
Validate(context: IValidationContext<T>): IValidationFailure[];
|
||||
ValidateAsync(context: IValidationContext<T>): Q.Promise<IValidationFailure[]>;
|
||||
}
|
||||
interface IValidationContext<T> {
|
||||
Value: string;
|
||||
Key: string;
|
||||
Data: T;
|
||||
}
|
||||
class Error implements IError {
|
||||
public HasError: boolean;
|
||||
public ErrorMessage: string;
|
||||
constructor();
|
||||
}
|
||||
class ValidationFailure implements IError {
|
||||
public Error: IError;
|
||||
public IsAsync: boolean;
|
||||
constructor(Error: IError, IsAsync: boolean);
|
||||
public HasError : boolean;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs;
|
||||
}
|
||||
class ValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
constructor(Name: string);
|
||||
public IsDirty: boolean;
|
||||
public Children : IValidationResult[];
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public Optional: IOptional;
|
||||
public TranslateArgs: IErrorTranslateArgs[];
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
}
|
||||
class CompositeValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
public Children: IValidationResult[];
|
||||
constructor(Name: string);
|
||||
public Optional: IOptional;
|
||||
public AddFirst(error: IValidationResult): void;
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs[];
|
||||
public LogErrors(headerMessage?: string): void;
|
||||
public Errors : {
|
||||
[name: string]: IValidationResult;
|
||||
};
|
||||
private FlattenErros;
|
||||
public SetDirty(): void;
|
||||
public SetPristine(): void;
|
||||
private SetDirtyEx(node, dirty);
|
||||
private flattenErrors(node, errorCollection);
|
||||
private traverse(node, indent);
|
||||
}
|
||||
class AbstractValidator<T> implements IAbstractValidator<T> {
|
||||
public Validators: {
|
||||
[name: string]: IPropertyValidator[];
|
||||
};
|
||||
public AbstractValidators: {
|
||||
[name: string]: IAbstractValidator<any>;
|
||||
};
|
||||
public ValidationFunctions: {
|
||||
[name: string]: IValidatorFce[];
|
||||
};
|
||||
public RuleFor(prop: string, validator: IPropertyValidator): void;
|
||||
public ValidationFor(prop: string, fce: IValidatorFce): void;
|
||||
public Validation(fce: IValidatorFce): void;
|
||||
public ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>, forList?: boolean): void;
|
||||
public CreateAbstractRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateAbstractListRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateRule(name: string): IAbstractValidationRule<T>;
|
||||
public ForList: boolean;
|
||||
}
|
||||
class MessageLocalization {
|
||||
static customMsg: string;
|
||||
static defaultMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static ValidationMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static GetValidationMessage(validator: any): string;
|
||||
}
|
||||
}
|
||||
declare module "node-validation" {export = Validation;}
|
||||
|
||||
+230
-235
@@ -4,242 +4,237 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Source: typings/business-rules-engine/Validation.d.ts
|
||||
|
||||
import * as Q from "q";
|
||||
|
||||
declare namespace Validation {
|
||||
interface IErrorCustomMessage {
|
||||
(config: any, args: any): string;
|
||||
}
|
||||
interface IPropertyValidator {
|
||||
isAcceptable(s: any): boolean;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
tagName?: string;
|
||||
}
|
||||
interface IStringValidator extends IPropertyValidator {
|
||||
isAcceptable(s: string): boolean;
|
||||
}
|
||||
interface IAsyncPropertyValidator {
|
||||
isAcceptable(s: any): Q.Promise<boolean>;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
isAsync: boolean;
|
||||
tagName?: string;
|
||||
}
|
||||
interface IAsyncStringPropertyValidator extends IAsyncPropertyValidator {
|
||||
isAcceptable(s: string): Q.Promise<boolean>;
|
||||
}
|
||||
enum CompareOperator {
|
||||
LessThan = 0,
|
||||
LessThanEqual = 1,
|
||||
Equal = 2,
|
||||
NotEqual = 3,
|
||||
GreaterThanEqual = 4,
|
||||
GreaterThan = 5,
|
||||
}
|
||||
interface IError {
|
||||
HasError: boolean;
|
||||
ErrorMessage: string;
|
||||
TranslateArgs?: IErrorTranslateArgs;
|
||||
}
|
||||
interface IErrorTranslateArgs {
|
||||
TranslateId: string;
|
||||
MessageArgs: any;
|
||||
CustomMessage?: IErrorCustomMessage;
|
||||
}
|
||||
interface IOptional {
|
||||
(): boolean;
|
||||
}
|
||||
interface IValidationFailure extends IError {
|
||||
IsAsync: boolean;
|
||||
Error: IError;
|
||||
}
|
||||
interface IValidationResult {
|
||||
Name: string;
|
||||
Add(validationResult: IValidationResult): void;
|
||||
Remove(index: number): void;
|
||||
Children: IValidationResult[];
|
||||
HasErrors: boolean;
|
||||
HasErrorsDirty: boolean;
|
||||
ErrorMessage: string;
|
||||
ErrorCount: number;
|
||||
Optional?: IOptional;
|
||||
TranslateArgs?: IErrorTranslateArgs[];
|
||||
}
|
||||
interface IValidate {
|
||||
(args: IError): void;
|
||||
}
|
||||
interface IAsyncValidate {
|
||||
(args: IError): Q.Promise<any>;
|
||||
}
|
||||
interface IValidatorFce {
|
||||
Name: string;
|
||||
ValidationFce?: IValidate;
|
||||
AsyncValidationFce?: IAsyncValidate;
|
||||
}
|
||||
interface IValidator {
|
||||
Validate(context: any): IValidationFailure;
|
||||
ValidateAsync(context: any): Q.Promise<IValidationFailure>;
|
||||
Error: IError;
|
||||
}
|
||||
interface IAbstractValidator<T> {
|
||||
RuleFor(prop: string, validator: IPropertyValidator): any;
|
||||
ValidationFor(prop: string, validatorFce: IValidatorFce): any;
|
||||
Validation(validatorFce: IValidatorFce): any;
|
||||
ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>): any;
|
||||
CreateRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractListRule(name: string): IAbstractValidationRule<any>;
|
||||
ForList: boolean;
|
||||
}
|
||||
interface IAbstractValidationRule<T> {
|
||||
Validate(context: T): IValidationResult;
|
||||
ValidateAsync(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateAll(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateProperty(context: T, propName: string): void;
|
||||
ValidationResult: IValidationResult;
|
||||
Rules: {
|
||||
[name: string]: IPropertyValidationRule<T>;
|
||||
};
|
||||
Validators: {
|
||||
[name: string]: IValidator;
|
||||
};
|
||||
Children: {
|
||||
[name: string]: IAbstractValidationRule<any>;
|
||||
};
|
||||
}
|
||||
interface IPropertyValidationRule<T> {
|
||||
Validators: {
|
||||
[name: string]: any;
|
||||
};
|
||||
Validate(context: IValidationContext<T>): IValidationFailure[];
|
||||
ValidateAsync(context: IValidationContext<T>): Q.Promise<IValidationFailure[]>;
|
||||
}
|
||||
interface IValidationContext<T> {
|
||||
Value: string;
|
||||
Key: string;
|
||||
Data: T;
|
||||
}
|
||||
class Error implements IError {
|
||||
public HasError: boolean;
|
||||
public ErrorMessage: string;
|
||||
constructor();
|
||||
}
|
||||
class ValidationFailure implements IError {
|
||||
public Error: IError;
|
||||
public IsAsync: boolean;
|
||||
constructor(Error: IError, IsAsync: boolean);
|
||||
public HasError : boolean;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs;
|
||||
}
|
||||
class ValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
constructor(Name: string);
|
||||
public IsDirty: boolean;
|
||||
public Children : IValidationResult[];
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public Optional: IOptional;
|
||||
public TranslateArgs: IErrorTranslateArgs[];
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
}
|
||||
class CompositeValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
public Children: IValidationResult[];
|
||||
constructor(Name: string);
|
||||
public Optional: IOptional;
|
||||
public AddFirst(error: IValidationResult): void;
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs[];
|
||||
public LogErrors(headerMessage?: string): void;
|
||||
public Errors : {
|
||||
[name: string]: IValidationResult;
|
||||
};
|
||||
private FlattenErros;
|
||||
public SetDirty(): void;
|
||||
public SetPristine(): void;
|
||||
private SetDirtyEx(node, dirty);
|
||||
private flattenErrors(node, errorCollection);
|
||||
private traverse(node, indent);
|
||||
}
|
||||
class AbstractValidator<T> implements IAbstractValidator<T> {
|
||||
public Validators: {
|
||||
[name: string]: IPropertyValidator[];
|
||||
};
|
||||
public AbstractValidators: {
|
||||
[name: string]: IAbstractValidator<any>;
|
||||
};
|
||||
public ValidationFunctions: {
|
||||
[name: string]: IValidatorFce[];
|
||||
};
|
||||
public RuleFor(prop: string, validator: IPropertyValidator): void;
|
||||
public ValidationFor(prop: string, fce: IValidatorFce): void;
|
||||
public Validation(fce: IValidatorFce): void;
|
||||
public ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>, forList?: boolean): void;
|
||||
public CreateAbstractRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateAbstractListRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateRule(name: string): IAbstractValidationRule<T>;
|
||||
public ForList: boolean;
|
||||
}
|
||||
class MessageLocalization {
|
||||
static customMsg: string;
|
||||
static defaultMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static ValidationMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static GetValidationMessage(validator: any): string;
|
||||
}
|
||||
export interface IErrorCustomMessage {
|
||||
(config: any, args: any): string;
|
||||
}
|
||||
export interface IPropertyValidator {
|
||||
isAcceptable(s: any): boolean;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
tagName?: string;
|
||||
}
|
||||
export interface IStringValidator extends IPropertyValidator {
|
||||
isAcceptable(s: string): boolean;
|
||||
}
|
||||
export interface IAsyncPropertyValidator {
|
||||
isAcceptable(s: any): Q.Promise<boolean>;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
isAsync: boolean;
|
||||
tagName?: string;
|
||||
}
|
||||
export interface IAsyncStringPropertyValidator extends IAsyncPropertyValidator {
|
||||
isAcceptable(s: string): Q.Promise<boolean>;
|
||||
}
|
||||
export enum CompareOperator {
|
||||
LessThan = 0,
|
||||
LessThanEqual = 1,
|
||||
Equal = 2,
|
||||
NotEqual = 3,
|
||||
GreaterThanEqual = 4,
|
||||
GreaterThan = 5,
|
||||
}
|
||||
export interface IError {
|
||||
HasError: boolean;
|
||||
ErrorMessage: string;
|
||||
TranslateArgs?: IErrorTranslateArgs;
|
||||
}
|
||||
export interface IErrorTranslateArgs {
|
||||
TranslateId: string;
|
||||
MessageArgs: any;
|
||||
CustomMessage?: IErrorCustomMessage;
|
||||
}
|
||||
export interface IOptional {
|
||||
(): boolean;
|
||||
}
|
||||
export interface IValidationFailure extends IError {
|
||||
IsAsync: boolean;
|
||||
Error: IError;
|
||||
}
|
||||
export interface IValidationResult {
|
||||
Name: string;
|
||||
Add(validationResult: IValidationResult): void;
|
||||
Remove(index: number): void;
|
||||
Children: IValidationResult[];
|
||||
HasErrors: boolean;
|
||||
HasErrorsDirty: boolean;
|
||||
ErrorMessage: string;
|
||||
ErrorCount: number;
|
||||
Optional?: IOptional;
|
||||
TranslateArgs?: IErrorTranslateArgs[];
|
||||
}
|
||||
export interface IValidate {
|
||||
(args: IError): void;
|
||||
}
|
||||
export interface IAsyncValidate {
|
||||
(args: IError): Q.Promise<any>;
|
||||
}
|
||||
export interface IValidatorFce {
|
||||
Name: string;
|
||||
ValidationFce?: IValidate;
|
||||
AsyncValidationFce?: IAsyncValidate;
|
||||
}
|
||||
export interface IValidator {
|
||||
Validate(context: any): IValidationFailure;
|
||||
ValidateAsync(context: any): Q.Promise<IValidationFailure>;
|
||||
Error: IError;
|
||||
}
|
||||
export interface IAbstractValidator<T> {
|
||||
RuleFor(prop: string, validator: IPropertyValidator): any;
|
||||
ValidationFor(prop: string, validatorFce: IValidatorFce): any;
|
||||
Validation(validatorFce: IValidatorFce): any;
|
||||
ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>): any;
|
||||
CreateRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractListRule(name: string): IAbstractValidationRule<any>;
|
||||
ForList: boolean;
|
||||
}
|
||||
export interface IAbstractValidationRule<T> {
|
||||
Validate(context: T): IValidationResult;
|
||||
ValidateAsync(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateAll(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateProperty(context: T, propName: string): void;
|
||||
ValidationResult: IValidationResult;
|
||||
Rules: {
|
||||
[name: string]: IPropertyValidationRule<T>;
|
||||
};
|
||||
Validators: {
|
||||
[name: string]: IValidator;
|
||||
};
|
||||
Children: {
|
||||
[name: string]: IAbstractValidationRule<any>;
|
||||
};
|
||||
}
|
||||
export interface IPropertyValidationRule<T> {
|
||||
Validators: {
|
||||
[name: string]: any;
|
||||
};
|
||||
Validate(context: IValidationContext<T>): IValidationFailure[];
|
||||
ValidateAsync(context: IValidationContext<T>): Q.Promise<IValidationFailure[]>;
|
||||
}
|
||||
export interface IValidationContext<T> {
|
||||
Value: string;
|
||||
Key: string;
|
||||
Data: T;
|
||||
}
|
||||
export class Error implements IError {
|
||||
public HasError: boolean;
|
||||
public ErrorMessage: string;
|
||||
constructor();
|
||||
}
|
||||
export class ValidationFailure implements IError {
|
||||
public Error: IError;
|
||||
public IsAsync: boolean;
|
||||
constructor(Error: IError, IsAsync: boolean);
|
||||
public HasError : boolean;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs;
|
||||
}
|
||||
export class ValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
constructor(Name: string);
|
||||
public IsDirty: boolean;
|
||||
public Children : IValidationResult[];
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public Optional: IOptional;
|
||||
public TranslateArgs: IErrorTranslateArgs[];
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
}
|
||||
export class CompositeValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
public Children: IValidationResult[];
|
||||
constructor(Name: string);
|
||||
public Optional: IOptional;
|
||||
public AddFirst(error: IValidationResult): void;
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs[];
|
||||
public LogErrors(headerMessage?: string): void;
|
||||
public Errors : {
|
||||
[name: string]: IValidationResult;
|
||||
};
|
||||
private FlattenErros;
|
||||
public SetDirty(): void;
|
||||
public SetPristine(): void;
|
||||
private SetDirtyEx(node, dirty);
|
||||
private flattenErrors(node, errorCollection);
|
||||
private traverse(node, indent);
|
||||
}
|
||||
export class AbstractValidator<T> implements IAbstractValidator<T> {
|
||||
public Validators: {
|
||||
[name: string]: IPropertyValidator[];
|
||||
};
|
||||
public AbstractValidators: {
|
||||
[name: string]: IAbstractValidator<any>;
|
||||
};
|
||||
public ValidationFunctions: {
|
||||
[name: string]: IValidatorFce[];
|
||||
};
|
||||
public RuleFor(prop: string, validator: IPropertyValidator): void;
|
||||
public ValidationFor(prop: string, fce: IValidatorFce): void;
|
||||
public Validation(fce: IValidatorFce): void;
|
||||
public ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>, forList?: boolean): void;
|
||||
public CreateAbstractRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateAbstractListRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateRule(name: string): IAbstractValidationRule<T>;
|
||||
public ForList: boolean;
|
||||
}
|
||||
export class MessageLocalization {
|
||||
static customMsg: string;
|
||||
static defaultMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static ValidationMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static GetValidationMessage(validator: any): string;
|
||||
}
|
||||
export = Validation;
|
||||
export as namespace Validation;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import * as CatboxMemory from 'catbox-memory';
|
||||
|
||||
const client = new CatboxMemory<string>({
|
||||
allowMixedContent: true,
|
||||
cloneBuffersOnGet: false,
|
||||
maxByteSize: 1024,
|
||||
minCleanupIntervalMsec: 1000,
|
||||
});
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Type definitions for catbox-memory 4.0
|
||||
// Project: https://github.com/hapijs/catbox-memory#readme
|
||||
// Definitions by: Simon Schick <https://github.com/SimonSchick>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { ClientApi } from 'catbox';
|
||||
|
||||
interface CatboxMemory<T> extends ClientApi<T> {}
|
||||
|
||||
// tslint:disable-next-line:no-unnecessary-class
|
||||
declare class CatboxMemory<T> implements ClientApi<T> {
|
||||
constructor(options?: CatboxMemory.Options);
|
||||
}
|
||||
|
||||
declare namespace CatboxMemory {
|
||||
interface Options {
|
||||
/**
|
||||
* Sets an upper limit on the number of bytes that can be stored in the cache.
|
||||
* Once this limit is reached no additional items will be added to the cache until some expire.
|
||||
* The utilized memory calculation is a rough approximation and must not be relied on.
|
||||
* @default 104857600 (100MB).
|
||||
*/
|
||||
maxByteSize?: number;
|
||||
/**
|
||||
* The minimum number of milliseconds in between each cache cleanup.
|
||||
* @default 1000 (1 second)
|
||||
*/
|
||||
minCleanupIntervalMsec?: number;
|
||||
/**
|
||||
* by default, all data is cached as JSON strings, and converted to an object using JSON.parse() on retrieval.
|
||||
* By setting this option to true, Buffer data can be stored alongside the stringified data.
|
||||
* Buffers are not stringified, and are copied before storage to prevent the value from changing while in the cache.
|
||||
* @default false
|
||||
*/
|
||||
allowMixedContent?: boolean;
|
||||
/**
|
||||
* by default, buffers stored in the cache with allowMixedContent set to true are copied when they are set but not when they are retrieved.
|
||||
* This means a change to the buffer returned by a get() will change the value in the cache. To prevent this,
|
||||
* set cloneBuffersOnGet to true to always return a copy of the cached buffer.
|
||||
* @default false
|
||||
*/
|
||||
cloneBuffersOnGet?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export = CatboxMemory;
|
||||
@@ -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",
|
||||
"catbox-memory-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -1 +1,6 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -3369,7 +3369,7 @@ declare namespace chrome {
|
||||
function chooseEntry(options: ChooseEntryOptionsBase, callback: FileEntryCallback<ChooseEntryOptionsBase>): void;
|
||||
function chooseEntry(options: ChooseFileEntryOptions, callback: FileEntryCallback<ChooseFileEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseSaveFileEntryOptions, callback: FileEntryCallback<ChooseSaveFileEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseMultipleFilesEntryOptions, callback: FileEntryCallback<ChooseFileEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseMultipleFilesEntryOptions, callback: FileEntryCallback<ChooseMultipleFilesEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseDirectoryEntryOptions, callback: FileEntryCallback<ChooseDirectoryEntryOptions>): void;
|
||||
/** Returns the file entry with the given id if it can be restored. This call will fail with a runtime error otherwise. */
|
||||
function restoreEntry(id: string, callback: (entry: FileEntry) => void): void;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -103,6 +103,7 @@ expect("abcd").to.have.length(4);
|
||||
|
||||
expect(5).to.equal(5);
|
||||
expect({ a: 1 }).to.equal({ a: 1 });
|
||||
expect([1, 2, 3]).to.equal([1, 2, 3]);
|
||||
|
||||
expect(Object.create(null)).to.equal({}, { prototype: false });
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -125,9 +125,9 @@ export interface Values<T> {
|
||||
/** Asserts that the reference value has a length property matching the provided size or an object with the specified number of keys. */
|
||||
length(size: number): AssertionChain<T>;
|
||||
/** Asserts that the reference value equals the provided value. */
|
||||
equal(value: T, options?: any): AssertionChain<T>;
|
||||
equal(value: T | T[], options?: any): AssertionChain<T>;
|
||||
/** Asserts that the reference value equals the provided value. */
|
||||
equals(value: T, options?: any): AssertionChain<T>;
|
||||
equals(value: T | T[], options?: any): AssertionChain<T>;
|
||||
/** Asserts that the reference value is greater than (>) the provided value. */
|
||||
above(value: T): AssertionChain<T>;
|
||||
/** Asserts that the reference value is greater than (>) the provided value. */
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ declare module "codemirror" {
|
||||
|
||||
interface Editor {
|
||||
/** Tries to uncomment the current selection, and if that fails, line-comments it. */
|
||||
toggleComment(from: Position, to: Position, options?: CommentOptions): void;
|
||||
toggleComment(options?: CommentOptions): void;
|
||||
/** Set the lines in the given range to be line comments. Will fall back to `blockComment` when no line comment style is defined for the mode. */
|
||||
lineComment(from: Position, to: Position, options?: CommentOptions): void;
|
||||
/** Wrap the code in the given range in a block comment. Will fall back to `lineComment` when no block comment style is defined for the mode. */
|
||||
|
||||
Vendored
+5
@@ -670,6 +670,11 @@ declare namespace CodeMirror {
|
||||
/** Returns an array containing all marked ranges in the document. */
|
||||
getAllMarks(): CodeMirror.TextMarker[];
|
||||
|
||||
/** Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards.
|
||||
line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line.
|
||||
options, when given, should be an object that configures the behavior of the widget.
|
||||
Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. */
|
||||
addLineWidget(line: any, node: HTMLElement, options?: CodeMirror.LineWidgetOptions): CodeMirror.LineWidget;
|
||||
|
||||
/** Gets the mode object for the editor. Note that this is distinct from getOption("mode"), which gives you the mode specification,
|
||||
rather than the resolved, instantiated mode object. */
|
||||
|
||||
@@ -10,7 +10,7 @@ const opt: CodeMirror.CommentOptions = {
|
||||
lineComment: "//",
|
||||
padding: " "
|
||||
};
|
||||
editor.toggleComment(position, position, opt);
|
||||
editor.toggleComment(opt);
|
||||
editor.blockComment(position, position, opt);
|
||||
editor.lineComment(position, position, opt);
|
||||
const b: boolean = editor.uncomment(position, position, opt);
|
||||
|
||||
@@ -91,3 +91,12 @@ CodeMirror.registerHelper("lint", "javascript", {});
|
||||
|
||||
myCodeMirror.isReadOnly();
|
||||
myCodeMirror.execCommand('selectAll');
|
||||
|
||||
let htmlElement1 = document.createElement('div');
|
||||
let htmlElement2 = document.createElement('div');
|
||||
let widget1 = myCodeMirror.addLineWidget(1, htmlElement1, {});
|
||||
let widget2 = doc.addLineWidget(1, htmlElement2, {});
|
||||
widget1.clear();
|
||||
widget2.clear();
|
||||
htmlElement1.remove();
|
||||
htmlElement2.remove();
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import compareFunc = require("compare-func");
|
||||
|
||||
// This is taken from https://github.com/stevemao/compare-func/blob/master/README.md#usage and extended
|
||||
|
||||
// sort by an object property
|
||||
[{ x: "b" }, { x: "a" }, { x: "c" }].sort(compareFunc("x"));
|
||||
// => [{x: "a"}, {x: "b"}, {x: "c"}]
|
||||
|
||||
// sort by a nested object property
|
||||
[{ x: { y: "b" } }, { x: { y: "a" } }].sort(compareFunc("x.y"));
|
||||
// => [{x: {y: "a"}}, {x: {y: "b"}}]
|
||||
|
||||
// sort by the `x` property, then `y`
|
||||
[{ x: "c", y: "c" }, { x: "b", y: "a" }, { x: "b", y: "b" }].sort(compareFunc(["x", "y"]));
|
||||
// => [{x: "b", y: "a"}, {x: "b", y: "b"}, {x: "c", y: "c"}]
|
||||
|
||||
// sort by the returned value
|
||||
[{ x: "b" }, { x: "a" }, { x: "c" }].sort(compareFunc((el) => el.x));
|
||||
// => [{x: "a"}, {x: "b"}, {x: "c"}]
|
||||
|
||||
// sort by an array of functions
|
||||
[{ x: "c", y: "c" }, { x: "b", y: "a" }, { x: "b", y: "b" }].sort(compareFunc([
|
||||
(el) => el.x,
|
||||
(el) => el.y,
|
||||
]));
|
||||
// => [{x: "a"}, {x: "b"}, {x: "c"}]
|
||||
|
||||
// sort by itself
|
||||
[1, 3, 2].sort(compareFunc());
|
||||
// => [1, 2, 3]
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// Type definitions for compare-func 1.3
|
||||
// Project: https://github.com/stevemao/compare-func
|
||||
// Definitions by: Dogan Fennibay <https://github.com/fennibay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
type extractFunc<T> = (e: T) => number | string;
|
||||
|
||||
declare function compare_func<T>(prop?: ReadonlyArray<string | extractFunc<T>> | string | extractFunc<T>):
|
||||
(e1: T, e2: T) => number;
|
||||
|
||||
export = compare_func;
|
||||
@@ -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",
|
||||
"compare-func-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// Type definitions for cookie 0.3
|
||||
// Project: https://github.com/jshttp/cookie
|
||||
// Definitions by: Pine Mizune <https://github.com/pine613>
|
||||
// Definitions by: Pine Mizune <https://github.com/pine>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface CookieSerializeOptions {
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import countries from 'country-list';
|
||||
const Countries = countries();
|
||||
import * as Countries from 'country-list';
|
||||
|
||||
Countries.getCode('Barbados'); // BB
|
||||
|
||||
@@ -14,3 +13,5 @@ Countries.getName('BB'); // Barbados
|
||||
Countries.getNameList();
|
||||
|
||||
Countries.getNames();
|
||||
|
||||
Countries.overwrite([{ code: 'TW', name: 'Taiwan' }]);
|
||||
|
||||
Vendored
+35
-31
@@ -1,41 +1,45 @@
|
||||
// Type definitions for country-list 1.1
|
||||
// Type definitions for country-list 2.1
|
||||
// Project: https://github.com/fannarsh/country-list
|
||||
// Definitions by: Kyle Roach <https://github.com/iRoachie>
|
||||
// Adam Binford <https://github.com/Kimahriman>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export default function Countries(): {
|
||||
/**
|
||||
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
|
||||
*/
|
||||
getName(code: string): string | undefined;
|
||||
/**
|
||||
* Expects an array of code and country name pairs to add to the list. Doesn't return anything.
|
||||
*/
|
||||
export function overwrite(countries: Array<{ code: string, name: string}>): void;
|
||||
|
||||
/**
|
||||
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
|
||||
*/
|
||||
getCode(name: string): string | undefined;
|
||||
/**
|
||||
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
|
||||
*/
|
||||
export function getName(code: string): string | undefined;
|
||||
|
||||
/**
|
||||
* Returns an array of all country names.
|
||||
*/
|
||||
getNames(): string[];
|
||||
/**
|
||||
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
|
||||
*/
|
||||
export function getCode(name: string): string | undefined;
|
||||
|
||||
/**
|
||||
* Returns an array of all country codes.
|
||||
*/
|
||||
getCodes(): string[];
|
||||
/**
|
||||
* Returns an array of all country names.
|
||||
*/
|
||||
export function getNames(): string[];
|
||||
|
||||
/**
|
||||
* Returns a key-value object of all countries using the name as key.
|
||||
*/
|
||||
getNameList(): {[name: string]: string};
|
||||
/**
|
||||
* Returns an array of all country codes.
|
||||
*/
|
||||
export function getCodes(): string[];
|
||||
|
||||
/**
|
||||
* Returns a key-value object of all countries using the code as key.
|
||||
*/
|
||||
getCodeList(): {[code: string]: string};
|
||||
/**
|
||||
* Returns a key-value object of all countries using the name as key.
|
||||
*/
|
||||
export function getNameList(): {[name: string]: string};
|
||||
|
||||
/**
|
||||
* Returns an array of all country information, in the same format as it gets imported.
|
||||
*/
|
||||
getData(): Array<{ code: string, name: string }>;
|
||||
};
|
||||
/**
|
||||
* Returns a key-value object of all countries using the code as key.
|
||||
*/
|
||||
export function getCodeList(): {[code: string]: string};
|
||||
|
||||
/**
|
||||
* Returns an array of all country information, in the same format as it gets imported.
|
||||
*/
|
||||
export function getData(): Array<{ code: string, name: string }>;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import countries from 'country-list';
|
||||
const Countries = countries();
|
||||
|
||||
Countries.getCode('Barbados'); // BB
|
||||
|
||||
Countries.getCodes();
|
||||
|
||||
Countries.getCodeList();
|
||||
|
||||
Countries.getData();
|
||||
|
||||
Countries.getName('BB'); // Barbados
|
||||
|
||||
Countries.getNameList();
|
||||
|
||||
Countries.getNames();
|
||||
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
// Type definitions for country-list 1.1
|
||||
// Project: https://github.com/fannarsh/country-list
|
||||
// Definitions by: Kyle Roach <https://github.com/iRoachie>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export default function Countries(): {
|
||||
/**
|
||||
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
|
||||
*/
|
||||
getName(code: string): string | undefined;
|
||||
|
||||
/**
|
||||
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
|
||||
*/
|
||||
getCode(name: string): string | undefined;
|
||||
|
||||
/**
|
||||
* Returns an array of all country names.
|
||||
*/
|
||||
getNames(): string[];
|
||||
|
||||
/**
|
||||
* Returns an array of all country codes.
|
||||
*/
|
||||
getCodes(): string[];
|
||||
|
||||
/**
|
||||
* Returns a key-value object of all countries using the name as key.
|
||||
*/
|
||||
getNameList(): {[name: string]: string};
|
||||
|
||||
/**
|
||||
* Returns a key-value object of all countries using the code as key.
|
||||
*/
|
||||
getCodeList(): {[code: string]: string};
|
||||
|
||||
/**
|
||||
* Returns an array of all country information, in the same format as it gets imported.
|
||||
*/
|
||||
getData(): Array<{ code: string, name: string }>;
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"country-list": ["country-list/v1"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"country-list-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1 +1,6 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,612 @@
|
||||
import * as csstree from "css-tree";
|
||||
|
||||
const ast = csstree.parse('.a { color: red; }');
|
||||
ast; // $ExpectType CssNode
|
||||
|
||||
csstree.parse('.a { color: red; }', {}); // $ExpectType CssNode
|
||||
csstree.parse('.a { color: red; }', {context: 'selector', positions: true}); // $ExpectType CssNode
|
||||
|
||||
csstree.walk(ast, (node, item, list) => {
|
||||
node; // $ExpectType CssNode
|
||||
item; // $ExpectType ListItem<CssNode>
|
||||
list; // $ExpectType List<CssNode>
|
||||
});
|
||||
|
||||
csstree.walk(ast, {});
|
||||
|
||||
csstree.walk(ast, {
|
||||
enter(node, item, list) {
|
||||
this.stylesheet; // $ExpectType StyleSheet
|
||||
node; // $ExpectType CssNode
|
||||
item; // $ExpectType ListItem<CssNode>
|
||||
list; // $ExpectType List<CssNode>
|
||||
},
|
||||
leave(node, item, list) {
|
||||
this.stylesheet; // $ExpectType StyleSheet
|
||||
node; // $ExpectType CssNode
|
||||
item; // $ExpectType ListItem<CssNode>
|
||||
list; // $ExpectType List<CssNode>
|
||||
},
|
||||
visit: 'ClassSelector',
|
||||
reverse: false,
|
||||
});
|
||||
|
||||
csstree.generate(ast); // $ExpectType string
|
||||
|
||||
csstree.generate(ast, {}); // $ExpectType string
|
||||
|
||||
csstree.generate(ast, {
|
||||
sourceMap: true,
|
||||
decorator: handlers => ({
|
||||
children(node, delimiter) {
|
||||
node; // $ExpectType CssNode
|
||||
delimiter; // $ExpectType ((node: CssNode) => void) | undefined
|
||||
handlers.children.call(handlers, node, delimiter);
|
||||
},
|
||||
node(node) {
|
||||
node; // $ExpectType CssNode
|
||||
handlers.node.call(node);
|
||||
},
|
||||
chunk(chunk) {
|
||||
chunk; // $ExpectType string
|
||||
handlers.chunk.call(chunk);
|
||||
},
|
||||
result() {
|
||||
return handlers.result.call(handlers);
|
||||
}
|
||||
}),
|
||||
});
|
||||
|
||||
const property = csstree.property('*-vendor-property');
|
||||
property.name = 'test'; // $ExpectError
|
||||
|
||||
const keyword = csstree.keyword('-vendor-keyword');
|
||||
keyword.name = 'test'; // $ExpectError
|
||||
|
||||
csstree.clone(ast); // $ExpectType CssNode
|
||||
|
||||
const fromPlain = csstree.fromPlainObject({
|
||||
type: 'SelectorList',
|
||||
children: []
|
||||
});
|
||||
fromPlain; // $ExpectType CssNode
|
||||
|
||||
const toPlain = csstree.toPlainObject({
|
||||
type: 'SelectorList',
|
||||
children: new csstree.List<csstree.CssNode>(),
|
||||
});
|
||||
toPlain; // $ExpectType CssNodePlain
|
||||
|
||||
interface Test {
|
||||
a: string;
|
||||
}
|
||||
|
||||
const list = new csstree.List<Test>();
|
||||
|
||||
const anItem = list.createItem({a: 'c'});
|
||||
anItem; // $ExpectType ListItem<Test>
|
||||
|
||||
list.fromArray([{a: 'b'}]);
|
||||
list.toArray(); // $ExpectType Test[]
|
||||
list.getSize(); // $ExpectType number
|
||||
list.isEmpty(); // $ExpectType boolean
|
||||
list.first(); // $ExpectType Test | null
|
||||
list.last(); // $ExpectType Test | null
|
||||
list.each(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
}, {b: 'c'});
|
||||
list.each(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
});
|
||||
list.forEach(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
}, {b: 'c'});
|
||||
list.forEach(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
});
|
||||
list.eachRight(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
}, {b: 'c'});
|
||||
list.eachRight(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
});
|
||||
list.forEachRight(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
}, {b: 'c'});
|
||||
list.forEachRight(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
});
|
||||
list.nextUntil(anItem, function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
}, {b: 'c'});
|
||||
list.nextUntil(anItem, function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
});
|
||||
list.prevUntil(anItem, function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
}, {b: 'c'});
|
||||
list.prevUntil(anItem, function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
});
|
||||
list.some(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
}, {b: 'c'});
|
||||
list.some(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
});
|
||||
const map1 = list.map(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return { c: 'd' };
|
||||
}, {b: 'c'});
|
||||
map1; // $ExpectType List<{ c: string; }>
|
||||
const map2 = list.map(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return { c: 'd' };
|
||||
});
|
||||
map2; // $ExpectType List<{ c: string; }>
|
||||
|
||||
const list2 = new csstree.List<Test | null>();
|
||||
|
||||
const filter1 = list2.filter(function(item, node, list): item is Test {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test | null
|
||||
node; // $ExpectType ListItem<Test | null>
|
||||
list; // $ExpectType List<Test | null>
|
||||
return !!item;
|
||||
}, {b: 'c'});
|
||||
filter1; // $ExpectType List<Test>
|
||||
const filter2 = list2.filter(function(item, node, list): item is Test {
|
||||
this; // $ExpectType List<Test | null>
|
||||
item; // $ExpectType Test | null
|
||||
node; // $ExpectType ListItem<Test | null>
|
||||
list; // $ExpectType List<Test | null>
|
||||
return !!item;
|
||||
});
|
||||
filter2; // $ExpectType List<Test>
|
||||
const filter3 = list2.filter(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test | null
|
||||
node; // $ExpectType ListItem<Test | null>
|
||||
list; // $ExpectType List<Test | null>
|
||||
return true;
|
||||
}, {b: 'c'});
|
||||
filter3; // $ExpectType List<Test | null>
|
||||
const filter4 = list2.filter(function(item, node, list) {
|
||||
this; // $ExpectType List<Test | null>
|
||||
item; // $ExpectType Test | null
|
||||
node; // $ExpectType ListItem<Test | null>
|
||||
list; // $ExpectType List<Test | null>
|
||||
return true;
|
||||
});
|
||||
filter4; // $ExpectType List<Test | null>
|
||||
|
||||
list.clear();
|
||||
list.copy(); // $ExpectType List<Test>
|
||||
list.prepend(anItem); // $ExpectType List<Test>
|
||||
list.prependData({a: 'b'}); // $ExpectType List<Test>
|
||||
list.append(anItem); // $ExpectType List<Test>
|
||||
list.appendData({a: 'b'}); // $ExpectType List<Test>
|
||||
list.insert(anItem, anItem); // $ExpectType List<Test>
|
||||
list.insertData({a: 'b'}, anItem); // $ExpectType List<Test>
|
||||
list.remove(anItem); // $ExpectType ListItem<Test>
|
||||
list.push({a: 'b'}); // $ExpectType void
|
||||
list.pop(); // $ExpectType ListItem<Test> | undefined
|
||||
list.unshift({a: 'b'}); // $ExpectType void
|
||||
list.shift(); // $ExpectType ListItem<Test> | undefined
|
||||
list.prependList(list); // $ExpectType List<Test>
|
||||
list.appendList(list); // $ExpectType List<Test>
|
||||
list.insertList(list, anItem); // $ExpectType List<Test>
|
||||
list.replace(anItem, list); // $ExpectType List<Test>
|
||||
list.replace(anItem, anItem); // $ExpectType List<Test>
|
||||
|
||||
switch (ast.type) {
|
||||
case 'AnPlusB':
|
||||
ast.a; // $ExpectType string | null
|
||||
ast.b; // $ExpectType string | null
|
||||
break;
|
||||
|
||||
case 'Atrule':
|
||||
ast.name; // $ExpectType string
|
||||
ast.prelude; // $ExpectType AtrulePrelude | Raw | null
|
||||
ast.block; // $ExpectType Block | null
|
||||
break;
|
||||
|
||||
case 'AtrulePrelude':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'AttributeSelector':
|
||||
ast.name; // $ExpectType Identifier
|
||||
ast.matcher; // $ExpectType string | null
|
||||
ast.value; // $ExpectType Identifier | StringNode | null
|
||||
ast.flags; // $ExpectType string | null
|
||||
break;
|
||||
|
||||
case 'Block':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'Brackets':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'CDC':
|
||||
break;
|
||||
|
||||
case 'CDO':
|
||||
break;
|
||||
|
||||
case 'ClassSelector':
|
||||
ast.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Combinator':
|
||||
ast.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Comment':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Declaration':
|
||||
ast.important; // $ExpectType string | boolean
|
||||
ast.property; // $ExpectType string
|
||||
ast.value; // $ExpectType Raw | Value
|
||||
break;
|
||||
|
||||
case 'DeclarationList':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'Dimension':
|
||||
ast.value; // $ExpectType string
|
||||
ast.unit; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Function':
|
||||
ast.name; // $ExpectType string
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'HexColor':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'IdSelector':
|
||||
ast.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Identifier':
|
||||
ast.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'MediaFeature':
|
||||
ast.name; // $ExpectType string
|
||||
ast.value; // $ExpectType Dimension | Identifier | NumberNode | Ratio | null
|
||||
break;
|
||||
|
||||
case 'MediaQuery':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'MediaQueryList':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'Nth':
|
||||
ast.nth; // $ExpectType AnPlusB | Identifier
|
||||
ast.selector; // $ExpectType SelectorList | null
|
||||
break;
|
||||
|
||||
case 'Number':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Operator':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Parentheses':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'Percentage':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'PseudoClassSelector':
|
||||
ast.name; // $ExpectType string
|
||||
ast.children; // $ExpectType List<CssNode> | null
|
||||
break;
|
||||
|
||||
case 'PseudoElementSelector':
|
||||
ast.name; // $ExpectType string
|
||||
ast.children; // $ExpectType List<CssNode> | null
|
||||
break;
|
||||
|
||||
case 'Ratio':
|
||||
ast.left; // $ExpectType string
|
||||
ast.right; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Raw':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Rule':
|
||||
ast.prelude; // $ExpectType Raw | SelectorList
|
||||
ast.block; // $ExpectType Block
|
||||
break;
|
||||
|
||||
case 'Selector':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'SelectorList':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'String':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'StyleSheet':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'TypeSelector':
|
||||
ast.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'UnicodeRange':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Url':
|
||||
ast.value; // $ExpectType Raw | StringNode
|
||||
break;
|
||||
|
||||
case 'Value':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'WhiteSpace':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
default:
|
||||
ast; // $ExpectType never
|
||||
}
|
||||
|
||||
switch (toPlain.type) {
|
||||
case 'AnPlusB':
|
||||
toPlain.a; // $ExpectType string | null
|
||||
toPlain.b; // $ExpectType string | null
|
||||
break;
|
||||
|
||||
case 'Atrule':
|
||||
toPlain.name; // $ExpectType string
|
||||
toPlain.prelude; // $ExpectType Raw | AtrulePreludePlain | null
|
||||
toPlain.block; // $ExpectType BlockPlain | null
|
||||
break;
|
||||
|
||||
case 'AtrulePrelude':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'AttributeSelector':
|
||||
toPlain.name; // $ExpectType Identifier
|
||||
toPlain.matcher; // $ExpectType string | null
|
||||
toPlain.value; // $ExpectType Identifier | StringNode | null
|
||||
toPlain.flags; // $ExpectType string | null
|
||||
break;
|
||||
|
||||
case 'Block':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'Brackets':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'CDC':
|
||||
break;
|
||||
|
||||
case 'CDO':
|
||||
break;
|
||||
|
||||
case 'ClassSelector':
|
||||
toPlain.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Combinator':
|
||||
toPlain.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Comment':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Declaration':
|
||||
toPlain.important; // $ExpectType string | boolean
|
||||
toPlain.property; // $ExpectType string
|
||||
toPlain.value; // $ExpectType Raw | ValuePlain
|
||||
break;
|
||||
|
||||
case 'DeclarationList':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'Dimension':
|
||||
toPlain.value; // $ExpectType string
|
||||
toPlain.unit; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Function':
|
||||
toPlain.name; // $ExpectType string
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'HexColor':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'IdSelector':
|
||||
toPlain.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Identifier':
|
||||
toPlain.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'MediaFeature':
|
||||
toPlain.name; // $ExpectType string
|
||||
toPlain.value; // $ExpectType Dimension | Identifier | NumberNode | Ratio | null
|
||||
break;
|
||||
|
||||
case 'MediaQuery':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'MediaQueryList':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'Nth':
|
||||
toPlain.nth; // $ExpectType AnPlusB | Identifier
|
||||
toPlain.selector; // $ExpectType SelectorListPlain | null
|
||||
break;
|
||||
|
||||
case 'Number':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Operator':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Parentheses':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'Percentage':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'PseudoClassSelector':
|
||||
toPlain.name; // $ExpectType string
|
||||
toPlain.children; // $ExpectType CssNodePlain[] | null
|
||||
break;
|
||||
|
||||
case 'PseudoElementSelector':
|
||||
toPlain.name; // $ExpectType string
|
||||
toPlain.children; // $ExpectType CssNodePlain[] | null
|
||||
break;
|
||||
|
||||
case 'Ratio':
|
||||
toPlain.left; // $ExpectType string
|
||||
toPlain.right; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Raw':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Rule':
|
||||
toPlain.prelude; // $ExpectType Raw | SelectorListPlain
|
||||
toPlain.block; // $ExpectType BlockPlain
|
||||
break;
|
||||
|
||||
case 'Selector':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'SelectorList':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'String':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'StyleSheet':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'TypeSelector':
|
||||
toPlain.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'UnicodeRange':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Url':
|
||||
toPlain.value; // $ExpectType Raw | StringNode
|
||||
break;
|
||||
|
||||
case 'Value':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'WhiteSpace':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
default:
|
||||
toPlain; // $ExpectType never
|
||||
}
|
||||
Vendored
+565
@@ -0,0 +1,565 @@
|
||||
// Type definitions for css-tree 1.0
|
||||
// Project: https://github.com/csstree/csstree
|
||||
// Definitions by: Erik Källén <https://github.com/erik-kallen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
export interface CssLocation {
|
||||
source: string;
|
||||
start: {
|
||||
offset: number;
|
||||
line: number;
|
||||
column: number
|
||||
};
|
||||
end: {
|
||||
offset: number;
|
||||
line: number;
|
||||
column: number
|
||||
};
|
||||
}
|
||||
|
||||
export interface ListItem<TData> {
|
||||
prev: ListItem<TData> | null;
|
||||
next: ListItem<TData> | null;
|
||||
data: TData;
|
||||
}
|
||||
|
||||
export type IteratorFn<TData, TResult, TContext = List<TData>> = (this: TContext, item: TData, node: ListItem<TData>, list: List<TData>) => TResult;
|
||||
export type FilterFn<TData, TResult extends TData, TContext = List<TData>> = (this: TContext, item: TData, node: ListItem<TData>, list: List<TData>) => item is TResult;
|
||||
|
||||
export class List<TData> {
|
||||
constructor();
|
||||
fromArray(array: TData[]): List<TData>;
|
||||
createItem(data: TData): ListItem<TData>;
|
||||
toArray(): TData[];
|
||||
toJSON(): TData[];
|
||||
getSize(): number;
|
||||
isEmpty(): boolean;
|
||||
first(): TData | null;
|
||||
last(): TData | null;
|
||||
each<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
|
||||
each(fn: IteratorFn<TData, void>): void;
|
||||
forEach<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
|
||||
forEach(fn: IteratorFn<TData, void>): void;
|
||||
eachRight<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
|
||||
eachRight(fn: IteratorFn<TData, void>): void;
|
||||
forEachRight<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
|
||||
forEachRight(fn: IteratorFn<TData, void>): void;
|
||||
nextUntil<TContext>(start: ListItem<TData>, fn: IteratorFn<TData, boolean, TContext>, context: TContext): void;
|
||||
nextUntil(start: ListItem<TData>, fn: IteratorFn<TData, boolean>): void;
|
||||
prevUntil<TContext>(start: ListItem<TData>, fn: IteratorFn<TData, boolean, TContext>, context: TContext): void;
|
||||
prevUntil(start: ListItem<TData>, fn: IteratorFn<TData, boolean>): void;
|
||||
some<TContext>(fn: IteratorFn<TData, boolean, TContext>, context: TContext): void;
|
||||
some(fn: IteratorFn<TData, boolean>): void;
|
||||
map<TContext, TResult>(fn: IteratorFn<TData, TResult, TContext>, context: TContext): List<TResult>;
|
||||
map<TResult>(fn: IteratorFn<TData, TResult>): List<TResult>;
|
||||
filter<TContext, TResult extends TData>(fn: FilterFn<TData, TResult, TContext>, context: TContext): List<TResult>;
|
||||
filter<TResult extends TData>(fn: FilterFn<TData, TResult>): List<TResult>;
|
||||
filter<TContext>(fn: IteratorFn<TData, boolean, TContext>, context: TContext): List<TData>;
|
||||
filter(fn: IteratorFn<TData, boolean>): List<TData>;
|
||||
clear(): void;
|
||||
copy(): List<TData>;
|
||||
prepend(item: ListItem<TData>): List<TData>;
|
||||
prependData(data: TData): List<TData>;
|
||||
append(item: ListItem<TData>): List<TData>;
|
||||
appendData(data: TData): List<TData>;
|
||||
insert(item: ListItem<TData>, before: ListItem<TData>): List<TData>;
|
||||
insertData(data: TData, before: ListItem<TData>): List<TData>;
|
||||
remove(item: ListItem<TData>): ListItem<TData>;
|
||||
push(item: TData): void;
|
||||
pop(): ListItem<TData> | undefined;
|
||||
unshift(data: TData): void;
|
||||
shift(): ListItem<TData> | undefined;
|
||||
prependList(list: List<TData>): List<TData>;
|
||||
appendList(list: List<TData>): List<TData>;
|
||||
insertList(list: List<TData>, before: ListItem<TData>): List<TData>;
|
||||
replace(oldItem: ListItem<TData>, newItemOrList: List<TData> | ListItem<TData>): List<TData>;
|
||||
}
|
||||
|
||||
export interface CssNodeCommon {
|
||||
type: string;
|
||||
loc?: CssLocation;
|
||||
}
|
||||
|
||||
export interface AnPlusB extends CssNodeCommon {
|
||||
type: 'AnPlusB';
|
||||
a: string | null;
|
||||
b: string | null;
|
||||
}
|
||||
|
||||
export interface Atrule extends CssNodeCommon {
|
||||
type: 'Atrule';
|
||||
name: string;
|
||||
prelude: AtrulePrelude | Raw | null;
|
||||
block: Block | null;
|
||||
}
|
||||
|
||||
export interface AtrulePlain extends CssNodeCommon {
|
||||
type: 'Atrule';
|
||||
name: string;
|
||||
prelude: AtrulePreludePlain | Raw | null;
|
||||
block: BlockPlain | null;
|
||||
}
|
||||
|
||||
export interface AtrulePrelude extends CssNodeCommon {
|
||||
type: 'AtrulePrelude';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface AtrulePreludePlain extends CssNodeCommon {
|
||||
type: 'AtrulePrelude';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface AttributeSelector extends CssNodeCommon {
|
||||
type: 'AttributeSelector';
|
||||
name: Identifier;
|
||||
matcher: string | null;
|
||||
value: StringNode | Identifier | null;
|
||||
flags: string | null;
|
||||
}
|
||||
|
||||
export interface Block extends CssNodeCommon {
|
||||
type: 'Block';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface BlockPlain extends CssNodeCommon {
|
||||
type: 'Block';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface Brackets extends CssNodeCommon {
|
||||
type: 'Brackets';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface BracketsPlain extends CssNodeCommon {
|
||||
type: 'Brackets';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface CDC extends CssNodeCommon {
|
||||
type: 'CDC';
|
||||
}
|
||||
|
||||
export interface CDO extends CssNodeCommon {
|
||||
type: 'CDO';
|
||||
}
|
||||
|
||||
export interface ClassSelector extends CssNodeCommon {
|
||||
type: 'ClassSelector';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Combinator extends CssNodeCommon {
|
||||
type: 'Combinator';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Comment extends CssNodeCommon {
|
||||
type: 'Comment';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Declaration extends CssNodeCommon {
|
||||
type: 'Declaration';
|
||||
important: boolean | string;
|
||||
property: string;
|
||||
value: Value | Raw;
|
||||
}
|
||||
|
||||
export interface DeclarationPlain extends CssNodeCommon {
|
||||
type: 'Declaration';
|
||||
important: boolean | string;
|
||||
property: string;
|
||||
value: ValuePlain | Raw;
|
||||
}
|
||||
|
||||
export interface DeclarationList extends CssNodeCommon {
|
||||
type: 'DeclarationList';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface DeclarationListPlain extends CssNodeCommon {
|
||||
type: 'DeclarationList';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface Dimension extends CssNodeCommon {
|
||||
type: 'Dimension';
|
||||
value: string;
|
||||
unit: string;
|
||||
}
|
||||
|
||||
export interface FunctionNode extends CssNodeCommon {
|
||||
type: 'Function';
|
||||
name: string;
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface FunctionNodePlain extends CssNodeCommon {
|
||||
type: 'Function';
|
||||
name: string;
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface HexColor extends CssNodeCommon {
|
||||
type: 'HexColor';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface IdSelector extends CssNodeCommon {
|
||||
type: 'IdSelector';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Identifier extends CssNodeCommon {
|
||||
type: 'Identifier';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface MediaFeature extends CssNodeCommon {
|
||||
type: 'MediaFeature';
|
||||
name: string;
|
||||
value: Identifier | NumberNode | Dimension | Ratio | null;
|
||||
}
|
||||
|
||||
export interface MediaQuery extends CssNodeCommon {
|
||||
type: 'MediaQuery';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface MediaQueryPlain extends CssNodeCommon {
|
||||
type: 'MediaQuery';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface MediaQueryList extends CssNodeCommon {
|
||||
type: 'MediaQueryList';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface MediaQueryListPlain extends CssNodeCommon {
|
||||
type: 'MediaQueryList';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface Nth extends CssNodeCommon {
|
||||
type: 'Nth';
|
||||
nth: AnPlusB | Identifier;
|
||||
selector: SelectorList | null;
|
||||
}
|
||||
|
||||
export interface NthPlain extends CssNodeCommon {
|
||||
type: 'Nth';
|
||||
nth: AnPlusB | Identifier;
|
||||
selector: SelectorListPlain | null;
|
||||
}
|
||||
|
||||
export interface NumberNode extends CssNodeCommon {
|
||||
type: 'Number';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Operator extends CssNodeCommon {
|
||||
type: 'Operator';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Parentheses extends CssNodeCommon {
|
||||
type: 'Parentheses';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface ParenthesesPlain extends CssNodeCommon {
|
||||
type: 'Parentheses';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface Percentage extends CssNodeCommon {
|
||||
type: 'Percentage';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface PseudoClassSelector extends CssNodeCommon {
|
||||
type: 'PseudoClassSelector';
|
||||
name: string;
|
||||
children: List<CssNode> | null;
|
||||
}
|
||||
|
||||
export interface PseudoClassSelectorPlain extends CssNodeCommon {
|
||||
type: 'PseudoClassSelector';
|
||||
name: string;
|
||||
children: CssNodePlain[] | null;
|
||||
}
|
||||
|
||||
export interface PseudoElementSelector extends CssNodeCommon {
|
||||
type: 'PseudoElementSelector';
|
||||
name: string;
|
||||
children: List<CssNode> | null;
|
||||
}
|
||||
|
||||
export interface PseudoElementSelectorPlain extends CssNodeCommon {
|
||||
type: 'PseudoElementSelector';
|
||||
name: string;
|
||||
children: CssNodePlain[] | null;
|
||||
}
|
||||
|
||||
export interface Ratio extends CssNodeCommon {
|
||||
type: 'Ratio';
|
||||
left: string;
|
||||
right: string;
|
||||
}
|
||||
|
||||
export interface Raw extends CssNodeCommon {
|
||||
type: 'Raw';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Rule extends CssNodeCommon {
|
||||
type: 'Rule';
|
||||
prelude: SelectorList | Raw;
|
||||
block: Block;
|
||||
}
|
||||
|
||||
export interface RulePlain extends CssNodeCommon {
|
||||
type: 'Rule';
|
||||
prelude: SelectorListPlain | Raw;
|
||||
block: BlockPlain;
|
||||
}
|
||||
|
||||
export interface Selector extends CssNodeCommon {
|
||||
type: 'Selector';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface SelectorPlain extends CssNodeCommon {
|
||||
type: 'Selector';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface SelectorList extends CssNodeCommon {
|
||||
type: 'SelectorList';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface SelectorListPlain extends CssNodeCommon {
|
||||
type: 'SelectorList';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface StringNode extends CssNodeCommon {
|
||||
type: 'String';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface StyleSheet extends CssNodeCommon {
|
||||
type: 'StyleSheet';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface StyleSheetPlain extends CssNodeCommon {
|
||||
type: 'StyleSheet';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface TypeSelector extends CssNodeCommon {
|
||||
type: 'TypeSelector';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface UnicodeRange extends CssNodeCommon {
|
||||
type: 'UnicodeRange';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Url extends CssNodeCommon {
|
||||
type: 'Url';
|
||||
value: StringNode | Raw;
|
||||
}
|
||||
|
||||
export interface Value extends CssNodeCommon {
|
||||
type: 'Value';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface ValuePlain extends CssNodeCommon {
|
||||
type: 'Value';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface WhiteSpace extends CssNodeCommon {
|
||||
type: 'WhiteSpace';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export type CssNode =
|
||||
AnPlusB
|
||||
| Atrule
|
||||
| AtrulePrelude
|
||||
| AttributeSelector
|
||||
| Block
|
||||
| Brackets
|
||||
| CDC
|
||||
| CDO
|
||||
| ClassSelector
|
||||
| Combinator
|
||||
| Comment
|
||||
| Declaration
|
||||
| DeclarationList
|
||||
| Dimension
|
||||
| FunctionNode
|
||||
| HexColor
|
||||
| IdSelector
|
||||
| Identifier
|
||||
| MediaFeature
|
||||
| MediaQuery
|
||||
| MediaQueryList
|
||||
| Nth
|
||||
| NumberNode
|
||||
| Operator
|
||||
| Parentheses
|
||||
| Percentage
|
||||
| PseudoClassSelector
|
||||
| PseudoElementSelector
|
||||
| Ratio
|
||||
| Raw
|
||||
| Rule
|
||||
| Selector
|
||||
| SelectorList
|
||||
| StringNode
|
||||
| StyleSheet
|
||||
| TypeSelector
|
||||
| UnicodeRange
|
||||
| Url
|
||||
| Value
|
||||
| WhiteSpace;
|
||||
|
||||
export type CssNodePlain =
|
||||
AnPlusB
|
||||
| AtrulePlain
|
||||
| AtrulePreludePlain
|
||||
| AttributeSelector
|
||||
| BlockPlain
|
||||
| BracketsPlain
|
||||
| CDC
|
||||
| CDO
|
||||
| ClassSelector
|
||||
| Combinator
|
||||
| Comment
|
||||
| DeclarationPlain
|
||||
| DeclarationListPlain
|
||||
| Dimension
|
||||
| FunctionNodePlain
|
||||
| HexColor
|
||||
| IdSelector
|
||||
| Identifier
|
||||
| MediaFeature
|
||||
| MediaQueryPlain
|
||||
| MediaQueryListPlain
|
||||
| NthPlain
|
||||
| NumberNode
|
||||
| Operator
|
||||
| ParenthesesPlain
|
||||
| Percentage
|
||||
| PseudoClassSelectorPlain
|
||||
| PseudoElementSelectorPlain
|
||||
| Ratio
|
||||
| Raw
|
||||
| RulePlain
|
||||
| SelectorPlain
|
||||
| SelectorListPlain
|
||||
| StringNode
|
||||
| StyleSheetPlain
|
||||
| TypeSelector
|
||||
| UnicodeRange
|
||||
| Url
|
||||
| ValuePlain
|
||||
| WhiteSpace;
|
||||
|
||||
export interface SyntaxParseError extends SyntaxError {
|
||||
input: string;
|
||||
offset: number;
|
||||
rawMessage: string;
|
||||
}
|
||||
|
||||
export interface ParseOptions {
|
||||
context?: string;
|
||||
atrule?: string;
|
||||
positions?: boolean;
|
||||
onParseError?: (error: SyntaxParseError, fallbackNode: CssNode) => void;
|
||||
filename?: string;
|
||||
offset?: number;
|
||||
line?: number;
|
||||
column?: number;
|
||||
parseAtrulePrelude?: boolean;
|
||||
parseRulePrelude?: boolean;
|
||||
parseValue?: boolean;
|
||||
parseCustomProperty?: boolean;
|
||||
}
|
||||
|
||||
export function parse(text: string, options?: ParseOptions): CssNode;
|
||||
|
||||
export interface GenerateHandlers {
|
||||
children: (node: CssNode, delimiter?: (node: CssNode) => void) => void;
|
||||
node: (node: CssNode) => void;
|
||||
chunk: (chunk: string) => void;
|
||||
result: () => string;
|
||||
}
|
||||
|
||||
export interface GenerateOptions {
|
||||
sourceMap?: boolean;
|
||||
decorator?: (handlers: GenerateHandlers) => GenerateHandlers;
|
||||
}
|
||||
|
||||
export function generate(ast: CssNode, options?: GenerateOptions): string;
|
||||
|
||||
export interface WalkContext {
|
||||
root: CssNode;
|
||||
stylesheet: StyleSheet;
|
||||
atrule: Atrule;
|
||||
atrulePrelude: AtrulePrelude;
|
||||
rule: Rule;
|
||||
selector: SelectorList;
|
||||
block: Block;
|
||||
declaration: Declaration;
|
||||
function: FunctionNode | PseudoClassSelector | PseudoElementSelector;
|
||||
}
|
||||
|
||||
export type EnterOrLeaveFn = (this: WalkContext, node: CssNode, item: ListItem<CssNode>, list: List<CssNode>) => void;
|
||||
|
||||
export interface WalkOptions {
|
||||
enter?: EnterOrLeaveFn;
|
||||
leave?: EnterOrLeaveFn;
|
||||
visit?: string;
|
||||
reverse?: boolean;
|
||||
}
|
||||
|
||||
export function walk(ast: CssNode, options: EnterOrLeaveFn | WalkOptions): void;
|
||||
|
||||
export interface Property {
|
||||
readonly basename: string;
|
||||
readonly name: string;
|
||||
readonly hack: string;
|
||||
readonly vendor: string;
|
||||
readonly prefix: string;
|
||||
readonly custom: boolean;
|
||||
}
|
||||
|
||||
export function property(value: string): Property;
|
||||
|
||||
export interface Keyword {
|
||||
readonly basename: string;
|
||||
readonly name: string;
|
||||
readonly vendor: string;
|
||||
readonly prefix: string;
|
||||
readonly custom: boolean;
|
||||
}
|
||||
|
||||
export function keyword(value: string): Keyword;
|
||||
|
||||
export function clone(node: CssNode): CssNode;
|
||||
|
||||
export function fromPlainObject(node: CssNodePlain): CssNode;
|
||||
export function toPlainObject(node: CssNode): CssNodePlain;
|
||||
@@ -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",
|
||||
"css-tree-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -15,7 +15,7 @@ csso.minify('.test { color: #ff0000; }', {
|
||||
logger: () => {}
|
||||
});
|
||||
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').css;
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').css; // $ExpectType string
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').map;
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000', {
|
||||
sourceMap: true,
|
||||
@@ -27,14 +27,30 @@ csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000', {
|
||||
forceMediaMerge: true,
|
||||
clone: false,
|
||||
comments: '',
|
||||
logger: () => {}
|
||||
logger: () => {},
|
||||
usage: {
|
||||
tags: ['ul', 'li'],
|
||||
ids: ['x'],
|
||||
classes: ['a', 'b'],
|
||||
blacklist: {
|
||||
tags: ['body'],
|
||||
ids: ['y'],
|
||||
classes: ['c'],
|
||||
},
|
||||
scopes: [
|
||||
['a', 'b', 'c'],
|
||||
['d', 'e']
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
csso.compress({}).ast;
|
||||
csso.compress({}, {
|
||||
csso.compress({ type: 'CDC' }).ast; // $ExpectType CssNode
|
||||
csso.compress({ type: 'CDC' }, {
|
||||
restructure: false,
|
||||
forceMediaMerge: true,
|
||||
clone: false,
|
||||
comments: '',
|
||||
logger: () => {}
|
||||
}).ast;
|
||||
}).ast; // $ExpectType CssNode
|
||||
|
||||
csso.syntax.parse('.b {font-weight: bold}'); // $ExpectType CssNode
|
||||
|
||||
Vendored
+20
-3
@@ -1,8 +1,11 @@
|
||||
// Type definitions for csso 3.5
|
||||
// Project: https://github.com/css/csso
|
||||
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
|
||||
// Erik Källén <https://github.com/erik-kallen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
import * as csstree from 'css-tree';
|
||||
|
||||
declare namespace csso {
|
||||
interface Result {
|
||||
@@ -16,6 +19,18 @@ declare namespace csso {
|
||||
map: object | null;
|
||||
}
|
||||
|
||||
interface Usage {
|
||||
tags?: string[];
|
||||
ids?: string[];
|
||||
classes?: string[];
|
||||
scopes?: string[][];
|
||||
blacklist?: {
|
||||
tags?: string[];
|
||||
ids?: string[];
|
||||
classes?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
interface CompressOptions {
|
||||
/**
|
||||
* Disable or enable a structure optimisations.
|
||||
@@ -44,7 +59,7 @@ declare namespace csso {
|
||||
/**
|
||||
* Usage data for advanced optimisations.
|
||||
*/
|
||||
usage?: object;
|
||||
usage?: Usage;
|
||||
/**
|
||||
* Function to track every step of transformation.
|
||||
*/
|
||||
@@ -100,7 +115,9 @@ interface Csso {
|
||||
/**
|
||||
* Does the main task – compress an AST.
|
||||
*/
|
||||
compress(ast: object, options?: csso.CompressOptions): { ast: object };
|
||||
compress(ast: csstree.CssNode, options?: csso.CompressOptions): { ast: csstree.CssNode };
|
||||
|
||||
syntax: typeof csstree;
|
||||
}
|
||||
|
||||
declare const csso: Csso;
|
||||
|
||||
@@ -98,7 +98,7 @@ brush.on('end', function(d, i, g) {
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const g = select<SVGSVGElement, any>('svg')
|
||||
.append<SVGGElement>('g')
|
||||
.append('g')
|
||||
.classed('brush', true)
|
||||
.datum<BrushDatum>({
|
||||
extent: [[0, 0], [300, 200]],
|
||||
@@ -108,7 +108,7 @@ const g = select<SVGSVGElement, any>('svg')
|
||||
g.call(brush);
|
||||
|
||||
const gX = select<SVGSVGElement, any>('svg')
|
||||
.append<SVGGElement>('g')
|
||||
.append('g')
|
||||
.classed('brush', true)
|
||||
.datum<BrushDatum>({
|
||||
extent: [[0, 0], [300, 200]],
|
||||
|
||||
@@ -193,5 +193,5 @@ ribbonPaths = select<SVGGElement, any>('g')
|
||||
.datum(chords)
|
||||
.selectAll()
|
||||
.data(chords => chords)
|
||||
.enter().append<SVGPathElement>('path')
|
||||
.enter().append('path')
|
||||
.attr('d', svgRibbon);
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/d3/d3-drag/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.2.1
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* in the sense of typing and call signature consistency. They
|
||||
* are not intended as functional tests.
|
||||
*/
|
||||
/* tslint:disable:no-unnecessary-type-assertion */
|
||||
|
||||
import * as d3Dsv from 'd3-dsv';
|
||||
|
||||
@@ -16,9 +17,9 @@ const csvTestString = '1997,Ford,E350,2.34\n2000,Mercury,Cougar,2.38';
|
||||
const tsvTestString = '1997\tFord\tE350\t2.34\n2000\tMercury\tCougar\t2.38';
|
||||
const pipedTestString = '1997|Ford|E350|2.34\n2000|Mercury|Cougar|2.38';
|
||||
|
||||
const csvTestStringWithHeader = 'Year,Make,Model,Length\n1997,Ford,E350,2.34\n2000,Mercury,Cougar,2.38';
|
||||
const tsvTestStringWithHeader = 'Year\tMake\tModel\tLength\n1997\tFord\tE350\t2.34\n2000\tMercury\tCougar\t2.38';
|
||||
const pipedTestStringWithHeader = 'Year|Make|Model|Length\n1997|Ford|E350|2.34\n2000|Mercury|Cougar|2.38';
|
||||
const csvTestStringWithHeader = `Year,Make,Model,Length\n${csvTestString}`;
|
||||
const tsvTestStringWithHeader = `Year\tMake\tModel\tLength\n${tsvTestString}`;
|
||||
const pipedTestStringWithHeader = `Year|Make|Model|Length\n${pipedTestString}`;
|
||||
|
||||
interface ParsedTestObject {
|
||||
year: Date | null;
|
||||
@@ -33,9 +34,8 @@ let parseMappedArray: d3Dsv.DSVParsedArray<ParsedTestObject>;
|
||||
let parseRowsArray: string[][];
|
||||
let parseRowsMappedArray: ParsedTestObject[];
|
||||
|
||||
let parsedTestObject: ParsedTestObject;
|
||||
let columns: string[];
|
||||
let num: number;
|
||||
let dateNull: Date | null;
|
||||
let str: string;
|
||||
let strMaybe: string | undefined;
|
||||
|
||||
@@ -48,12 +48,8 @@ let strMaybe: string | undefined;
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseArray = d3Dsv.csvParse(csvTestStringWithHeader);
|
||||
|
||||
columns = parseArray.columns;
|
||||
|
||||
strMaybe = parseArray[0]['Year'];
|
||||
// $ExpectError
|
||||
date = parseArray[0]['Year']; // fails, return value is string
|
||||
strMaybe = parseArray[0].Year;
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -61,28 +57,15 @@ parseMappedArray = d3Dsv.csvParse(csvTestStringWithHeader, (rawRow, index, colum
|
||||
const rr: d3Dsv.DSVRowString = rawRow;
|
||||
const i: number = index;
|
||||
const c: string[] = columns;
|
||||
const pr: ParsedTestObject = {
|
||||
year: rr['Year'] ? new Date(+rr['Year']!, 0, 1) : null,
|
||||
make: rr['Make'] ? rr['Make']! : "Missing Value",
|
||||
model: rr['Model'] ? rr['Model']! : "Missing Value",
|
||||
length: rr['Length'] ? +rr['Length']! : NaN
|
||||
};
|
||||
return pr;
|
||||
});
|
||||
|
||||
parseMappedArray = d3Dsv.csvParse(csvTestStringWithHeader, (rawRow, index, columns) => {
|
||||
const rr: d3Dsv.DSVRowString = rawRow;
|
||||
const i: number = index;
|
||||
const c: string[] = columns;
|
||||
const d: number | null = rr['Year'] ? +rr['Year']! : null;
|
||||
const d: number | null = rr.Year ? +rr.Year! : null;
|
||||
const pr: ParsedTestObject | null | undefined = d !== null
|
||||
? (
|
||||
d > 1997
|
||||
? {
|
||||
year: new Date(d, 0, 1),
|
||||
make: rr['Make'] ? rr['Make']! : "Missing Value",
|
||||
model: rr['Model'] ? rr['Model']! : "Missing Value",
|
||||
length: rr['Length'] ? +rr['Length']! : NaN
|
||||
make: rr.Make ? rr.Make! : "Missing Value",
|
||||
model: rr.Model ? rr.Model! : "Missing Value",
|
||||
length: rr.Length ? +rr.Length! : NaN
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
@@ -91,21 +74,14 @@ parseMappedArray = d3Dsv.csvParse(csvTestStringWithHeader, (rawRow, index, colum
|
||||
});
|
||||
|
||||
columns = parseMappedArray.columns;
|
||||
|
||||
dateNull = parseMappedArray[0].year;
|
||||
strMaybe = parseMappedArray[0].make;
|
||||
strMaybe = parseMappedArray[0].model;
|
||||
num = parseMappedArray[0].length;
|
||||
parsedTestObject = parseMappedArray[0];
|
||||
|
||||
// csvParseRows(...) ============================================================================
|
||||
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseRowsArray = d3Dsv.csvParseRows(csvTestString);
|
||||
|
||||
strMaybe = parseRowsArray[0][0]; // 'Year' of first row
|
||||
// $ExpectError
|
||||
date = parseRowsArray[0][0]; // fails, return value is string
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -128,15 +104,12 @@ parseRowsMappedArray = d3Dsv.csvParseRows(csvTestString, (rawRow, index) => {
|
||||
return pr;
|
||||
});
|
||||
|
||||
dateNull = parseRowsMappedArray[0].year;
|
||||
strMaybe = parseRowsMappedArray[0].make;
|
||||
strMaybe = parseRowsMappedArray[0].model;
|
||||
num = parseRowsMappedArray[0].length;
|
||||
|
||||
// csvFormat(...) ============================================================================
|
||||
|
||||
str = d3Dsv.csvFormat(parseRowsMappedArray);
|
||||
str = d3Dsv.csvFormat(parseRowsMappedArray, columns);
|
||||
str = d3Dsv.csvFormat(parseRowsMappedArray, ["year", "length"]);
|
||||
// $ExpectError
|
||||
str = d3Dsv.csvFormat(parseRowsMappedArray, ["year", "unknown"]);
|
||||
|
||||
// csvFormatRows(...) ========================================================================
|
||||
|
||||
@@ -156,12 +129,8 @@ str = d3Dsv.csvFormatRows(parseRowsMappedArray.map((d, i) => [
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseArray = d3Dsv.tsvParse(tsvTestStringWithHeader);
|
||||
|
||||
columns = parseArray.columns;
|
||||
|
||||
strMaybe = parseArray[0]['Year'];
|
||||
// $ExpectError
|
||||
date = parseArray[0]['Year']; // fails, return value is string
|
||||
strMaybe = parseArray[0].Year;
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -169,15 +138,15 @@ parseMappedArray = d3Dsv.tsvParse(tsvTestStringWithHeader, (rawRow, index, colum
|
||||
const rr: d3Dsv.DSVRowString = rawRow;
|
||||
const i: number = index;
|
||||
const c: string[] = columns;
|
||||
const d: number | null = rr['Year'] ? +rr['Year']! : null;
|
||||
const d: number | null = rr.Year ? +rr.Year! : null;
|
||||
const pr: ParsedTestObject | null | undefined = d !== null
|
||||
? (
|
||||
d > 1997
|
||||
? {
|
||||
year: new Date(d, 0, 1),
|
||||
make: rr['Make'] ? rr['Make']! : "Missing Value",
|
||||
model: rr['Model'] ? rr['Model']! : "Missing Value",
|
||||
length: rr['Length'] ? +rr['Length']! : NaN
|
||||
make: rr.Make ? rr.Make! : "Missing Value",
|
||||
model: rr.Model ? rr.Model! : "Missing Value",
|
||||
length: rr.Length ? +rr.Length! : NaN
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
@@ -186,21 +155,14 @@ parseMappedArray = d3Dsv.tsvParse(tsvTestStringWithHeader, (rawRow, index, colum
|
||||
});
|
||||
|
||||
columns = parseMappedArray.columns;
|
||||
|
||||
dateNull = parseMappedArray[0].year;
|
||||
strMaybe = parseMappedArray[0].make;
|
||||
strMaybe = parseMappedArray[0].model;
|
||||
num = parseMappedArray[0].length;
|
||||
parsedTestObject = parseMappedArray[0];
|
||||
|
||||
// tsvParseRows(...) ============================================================================
|
||||
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseRowsArray = d3Dsv.tsvParseRows(tsvTestString);
|
||||
|
||||
strMaybe = parseRowsArray[0][0]; // 'Year' of first row
|
||||
// $ExpectError
|
||||
date = parseRowsArray[0][0]; // fails, return value is string
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -223,15 +185,12 @@ parseRowsMappedArray = d3Dsv.tsvParseRows(tsvTestString, (rawRow, index) => {
|
||||
return pr;
|
||||
});
|
||||
|
||||
dateNull = parseRowsMappedArray[0].year;
|
||||
strMaybe = parseRowsMappedArray[0].make;
|
||||
strMaybe = parseRowsMappedArray[0].model;
|
||||
num = parseRowsMappedArray[0].length;
|
||||
|
||||
// tsvFormat(...) ============================================================================
|
||||
|
||||
str = d3Dsv.tsvFormat(parseRowsMappedArray);
|
||||
str = d3Dsv.tsvFormat(parseRowsMappedArray, columns);
|
||||
str = d3Dsv.tsvFormat(parseRowsMappedArray, ["year", "length"]);
|
||||
// $ExpectError
|
||||
str = d3Dsv.tsvFormat(parseRowsMappedArray, ["year", "unknown"]);
|
||||
|
||||
// tsvFormatRows(...) ========================================================================
|
||||
|
||||
@@ -256,12 +215,8 @@ dsv = d3Dsv.dsvFormat('|');
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseArray = dsv.parse(pipedTestStringWithHeader);
|
||||
|
||||
columns = parseArray.columns;
|
||||
|
||||
strMaybe = parseArray[0]['Year'];
|
||||
// $ExpectError
|
||||
date = parseArray[0]['Year']; // fails, return value is string
|
||||
strMaybe = parseArray[0].Year;
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -269,15 +224,15 @@ parseMappedArray = dsv.parse(pipedTestStringWithHeader, (rawRow, index, columns)
|
||||
const rr: d3Dsv.DSVRowString = rawRow;
|
||||
const i: number = index;
|
||||
const c: string[] = columns;
|
||||
const d: number | null = rr['Year'] ? +rr['Year']! : null;
|
||||
const d: number | null = rr.Year ? +rr.Year! : null;
|
||||
const pr: ParsedTestObject | null | undefined = d !== null
|
||||
? (
|
||||
d > 1997
|
||||
? {
|
||||
year: new Date(d, 0, 1),
|
||||
make: rr['Make'] ? rr['Make']! : "Missing Value",
|
||||
model: rr['Model'] ? rr['Model']! : "Missing Value",
|
||||
length: rr['Length'] ? +rr['Length']! : NaN
|
||||
make: rr.Make ? rr.Make! : "Missing Value",
|
||||
model: rr.Model ? rr.Model! : "Missing Value",
|
||||
length: rr.Length ? +rr.Length! : NaN
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
@@ -286,21 +241,14 @@ parseMappedArray = dsv.parse(pipedTestStringWithHeader, (rawRow, index, columns)
|
||||
});
|
||||
|
||||
columns = parseMappedArray.columns;
|
||||
|
||||
dateNull = parseMappedArray[0].year;
|
||||
strMaybe = parseMappedArray[0].make;
|
||||
strMaybe = parseMappedArray[0].model;
|
||||
num = parseMappedArray[0].length;
|
||||
parsedTestObject = parseMappedArray[0];
|
||||
|
||||
// parseRows(...) ============================================================================
|
||||
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseRowsArray = dsv.parseRows(pipedTestString);
|
||||
|
||||
strMaybe = parseRowsArray[0][0]; // 'Year' of first row
|
||||
// $ExpectError
|
||||
date = parseRowsArray[0][0]; // fails, return value is string
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -323,15 +271,12 @@ parseRowsMappedArray = dsv.parseRows(pipedTestString, (rawRow, index) => {
|
||||
return pr;
|
||||
});
|
||||
|
||||
dateNull = parseRowsMappedArray[0].year;
|
||||
strMaybe = parseRowsMappedArray[0].make;
|
||||
strMaybe = parseRowsMappedArray[0].model;
|
||||
num = parseRowsMappedArray[0].length;
|
||||
|
||||
// format(...) ============================================================================
|
||||
|
||||
str = dsv.format(parseRowsMappedArray);
|
||||
str = dsv.format(parseRowsMappedArray, columns);
|
||||
str = dsv.format(parseRowsMappedArray, ["year", "length"]);
|
||||
// $ExpectError
|
||||
str = dsv.format(parseRowsMappedArray, ["year", "unknown"]);
|
||||
|
||||
// formatRows(...) ========================================================================
|
||||
|
||||
|
||||
Vendored
+17
-11
@@ -1,9 +1,13 @@
|
||||
// Type definitions for D3JS d3-dsv module 1.0
|
||||
// Project: https://github.com/d3/d3-dsv/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>
|
||||
// Alex Ford <https://github.com/gustavderdrache>
|
||||
// Boris Yankov <https://github.com/borisyankov>
|
||||
// denisname <https://github.com/denisname>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.0.8
|
||||
// Last module patch version validated against: 1.0.10
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// Shared Types and Interfaces
|
||||
@@ -19,6 +23,8 @@ export interface DSVRowString {
|
||||
/**
|
||||
* An object representing a DSV parsed row with values represented as an arbitrary datatype, depending
|
||||
* on the performed parsed row mapping.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
export interface DSVRowAny {
|
||||
[key: string]: any;
|
||||
@@ -70,7 +76,7 @@ export function csvParse(csvString: string): DSVParsedArray<DSVRowString>;
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
export function csvParse<ParsedRow extends DSVRowAny>(
|
||||
export function csvParse<ParsedRow extends object>(
|
||||
csvString: string,
|
||||
row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow | undefined | null
|
||||
): DSVParsedArray<ParsedRow>;
|
||||
@@ -105,7 +111,7 @@ export function csvParseRows(csvString: string): string[][];
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
export function csvParseRows<ParsedRow extends DSVRowAny>(
|
||||
export function csvParseRows<ParsedRow extends object>(
|
||||
csvString: string,
|
||||
row: (rawRow: string[], index: number) => ParsedRow | undefined | null
|
||||
): ParsedRow[];
|
||||
@@ -126,7 +132,7 @@ export function csvParseRows<ParsedRow extends DSVRowAny>(
|
||||
* @param rows Array of object rows.
|
||||
* @param columns An array of strings representing the column names.
|
||||
*/
|
||||
export function csvFormat(rows: DSVRowAny[], columns?: string[]): string;
|
||||
export function csvFormat<T extends object>(rows: T[], columns?: Array<keyof T>): string;
|
||||
|
||||
// csvFormatRows(...) ========================================================================
|
||||
|
||||
@@ -180,7 +186,7 @@ export function tsvParse(tsvString: string): DSVParsedArray<DSVRowString>;
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
export function tsvParse<MappedRow extends DSVRowAny>(
|
||||
export function tsvParse<MappedRow extends object>(
|
||||
tsvString: string,
|
||||
row: (rawRow: DSVRowString, index: number, columns: string[]) => MappedRow | undefined | null
|
||||
): DSVParsedArray<MappedRow>;
|
||||
@@ -215,7 +221,7 @@ export function tsvParseRows(tsvString: string): string[][];
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
export function tsvParseRows<MappedRow extends DSVRowAny>(
|
||||
export function tsvParseRows<MappedRow extends object>(
|
||||
tsvString: string,
|
||||
row: (rawRow: string[], index: number) => MappedRow | undefined | null
|
||||
): MappedRow[];
|
||||
@@ -236,7 +242,7 @@ export function tsvParseRows<MappedRow extends DSVRowAny>(
|
||||
* @param rows Array of object rows.
|
||||
* @param columns An array of strings representing the column names.
|
||||
*/
|
||||
export function tsvFormat(rows: DSVRowAny[], columns?: string[]): string;
|
||||
export function tsvFormat<T extends object>(rows: T[], columns?: Array<keyof T>): string;
|
||||
|
||||
// tsvFormatRows(...) ========================================================================
|
||||
|
||||
@@ -288,7 +294,7 @@ export interface DSV {
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
parse<ParsedRow extends DSVRowAny>(
|
||||
parse<ParsedRow extends object>(
|
||||
dsvString: string,
|
||||
row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow | undefined | null
|
||||
): DSVParsedArray<ParsedRow>;
|
||||
@@ -317,7 +323,7 @@ export interface DSV {
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
parseRows<ParsedRow extends DSVRowAny>(
|
||||
parseRows<ParsedRow extends object>(
|
||||
dsvString: string,
|
||||
row: (rawRow: string[], index: number) => ParsedRow | undefined | null
|
||||
): ParsedRow[];
|
||||
@@ -334,7 +340,7 @@ export interface DSV {
|
||||
* @param rows Array of object rows.
|
||||
* @param columns An array of strings representing the column names.
|
||||
*/
|
||||
format(rows: DSVRowAny[], columns?: string[]): string;
|
||||
format<T extends object>(rows: T[], columns?: Array<keyof T>): string;
|
||||
|
||||
/**
|
||||
* Formats the specified array of array of string rows as delimiter-separated values, returning a string.
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://d3js.org/d3-fetch/
|
||||
// Definitions by: Hugues Stefanski <https://github.com/ledragon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.1.0
|
||||
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/d3/d3-sankey/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 0.7.1
|
||||
|
||||
|
||||
@@ -685,7 +685,7 @@ circles2 = d3Selection.select<SVGSVGElement, any>('#svg2')
|
||||
.selectAll() // create empty Selection
|
||||
.data(startCircleData) // assign data for circles to be added (no previous circles)
|
||||
.enter() // obtain enter selection
|
||||
.append<SVGCircleElement>('circle');
|
||||
.append('circle');
|
||||
|
||||
// UPDATE-selection with continuation in data type ---------------------------------
|
||||
|
||||
@@ -705,7 +705,7 @@ let enterElements: d3Selection.Selection<d3Selection.EnterElement, CircleDatumAl
|
||||
enterElements = circles2.enter(); // enter selection
|
||||
|
||||
const enterCircles = enterElements
|
||||
.append<SVGCircleElement>('circle') // enter selection with materialized DOM elements (svg circles)
|
||||
.append('circle') // enter selection with materialized DOM elements (svg circles)
|
||||
.attr('cx', d => d.cx)
|
||||
.attr('cy', d => d.cy)
|
||||
.attr('r', d => d.r)
|
||||
@@ -763,19 +763,19 @@ let nRow: number[];
|
||||
|
||||
let tr: d3Selection.Selection<HTMLTableRowElement, number[], HTMLTableElement, any>;
|
||||
tr = d3Selection.select('body')
|
||||
.append<HTMLTableElement>('table')
|
||||
.append('table')
|
||||
.selectAll()
|
||||
.data(matrix)
|
||||
// $ExpectError
|
||||
.data<number[]>([{test: 1}, {test: 2}]) // fails, using this data statement instead, would fail because of its type parameter not being met by input
|
||||
.enter().append<HTMLTableRowElement>('tr');
|
||||
.enter().append('tr');
|
||||
|
||||
nMatrix = tr.data(); // i.e. matrix
|
||||
|
||||
let td: d3Selection.Selection<HTMLTableDataCellElement, number, HTMLTableRowElement, number[]>;
|
||||
td = tr.selectAll()
|
||||
.data(d => d) // d : Array<number> inferred (Array[4] of number per parent <tr>)
|
||||
.enter().append<HTMLTableDataCellElement>('td')
|
||||
.enter().append('td')
|
||||
.text(function(d, i, g) {
|
||||
const that: HTMLTableDataCellElement = this;
|
||||
const datum: number = d;
|
||||
@@ -810,19 +810,24 @@ nRow = td2.data(); // flattened matrix (Array[16] of number)
|
||||
|
||||
// append(...), creator(...) and create(...) ---------------------------------------------
|
||||
|
||||
// without append<...> typing returned selection has group element of type BaseType
|
||||
let newDiv: d3Selection.Selection<d3Selection.BaseType, BodyDatum, HTMLElement, any>;
|
||||
let newCircle: d3Selection.Selection<SVGCircleElement, BodyDatum, HTMLElement, any>;
|
||||
newCircle = body.append('circle');
|
||||
|
||||
let newDiv: d3Selection.Selection<HTMLDivElement, BodyDatum, HTMLElement, any>;
|
||||
newDiv = body.append('div');
|
||||
|
||||
let newDiv2: d3Selection.Selection<HTMLDivElement, BodyDatum, HTMLElement, any>;
|
||||
newDiv2 = body.append<HTMLDivElement>('div');
|
||||
newDiv = body.append<HTMLDivElement>('div');
|
||||
|
||||
// using creator
|
||||
newDiv2 = body.append(d3Selection.creator<HTMLDivElement>('div'));
|
||||
newCircle = body.append(d3Selection.creator('circle'));
|
||||
newDiv = body.append(d3Selection.creator('div'));
|
||||
newDiv = body.append(d3Selection.creator<HTMLDivElement>('custom_div_elem'));
|
||||
// $ExpectError
|
||||
newDiv2 = body.append(d3Selection.creator('div')); // fails, as creator returns BaseType element, but HTMLDivElement is expected.
|
||||
newDiv = body.append(d3Selection.creator('a'));
|
||||
// $ExpectError
|
||||
newDiv = body.append(d3Selection.creator<HTMLAnchorElement>('a'));
|
||||
|
||||
newDiv2 = body.append(function(d, i, g) {
|
||||
newDiv = body.append(function(d, i, g) {
|
||||
const that: HTMLBodyElement = this;
|
||||
// $ExpectError
|
||||
const that2: SVGElement = this; // fails, type mismatch
|
||||
@@ -834,29 +839,29 @@ newDiv2 = body.append(function(d, i, g) {
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
newDiv2 = body.append<HTMLDivElement>(function(d) {
|
||||
newDiv = body.append<HTMLDivElement>(function(d) {
|
||||
return this.ownerDocument!.createElement('a'); // fails, HTMLDivElement expected by type parameter, HTMLAnchorElement returned
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
newDiv2 = body.append(function(d) {
|
||||
newDiv = body.append(function(d) {
|
||||
return this.ownerDocument!.createElement('a'); // fails, HTMLDivElement expected by inference, HTMLAnchorElement returned
|
||||
});
|
||||
|
||||
// create a detached element
|
||||
|
||||
let detachedCircle: d3Selection.Selection<SVGCircleElement, undefined, null, undefined>;
|
||||
|
||||
detachedCircle = d3Selection.create('circle');
|
||||
|
||||
let detachedDiv: d3Selection.Selection<HTMLDivElement, undefined, null, undefined>;
|
||||
|
||||
detachedDiv = d3Selection.create<HTMLDivElement>('div');
|
||||
detachedDiv = d3Selection.create('div');
|
||||
detachedDiv = d3Selection.create<HTMLDivElement>('custom_div_elem');
|
||||
|
||||
// insert(...) ---------------------------------------------------------------------------
|
||||
|
||||
// without insert<...> typing returned selection has group element of type BaseType
|
||||
let newParagraph: d3Selection.Selection<d3Selection.BaseType, BodyDatum, HTMLElement, any>;
|
||||
newParagraph = body.insert('p', 'p.second-paragraph');
|
||||
newParagraph = body.insert('p');
|
||||
|
||||
// Two arguments; the first can be string, selection , or a
|
||||
// Two arguments; the first can be string, selection, or a
|
||||
|
||||
const typeValueFunction = function(
|
||||
this: HTMLBodyElement,
|
||||
@@ -876,32 +881,37 @@ const beforeValueFunction = function(
|
||||
return this.children[0];
|
||||
};
|
||||
|
||||
let newParagraph2: d3Selection.Selection<HTMLParagraphElement, BodyDatum, HTMLElement, any>;
|
||||
let newParagraph: d3Selection.Selection<HTMLParagraphElement, BodyDatum, HTMLElement, any>;
|
||||
|
||||
// 1 args, with 3 possibilities each, makes 3 possible combinations:
|
||||
newParagraph = body.insert('p', 'p.second-paragraph');
|
||||
newParagraph = body.insert('p', beforeValueFunction);
|
||||
newParagraph = body.insert('p');
|
||||
|
||||
// 2 args, with 3 possibilities each, makes 9 possible combinations:
|
||||
newParagraph2 = body.insert<HTMLParagraphElement>('p', 'p.second-paragraph');
|
||||
newParagraph2 = body.insert<HTMLParagraphElement>('p', beforeValueFunction);
|
||||
newParagraph2 = body.insert<HTMLParagraphElement>('p');
|
||||
newParagraph = body.insert<HTMLParagraphElement>('p', 'p.second-paragraph');
|
||||
newParagraph = body.insert<HTMLParagraphElement>('p', beforeValueFunction);
|
||||
newParagraph = body.insert<HTMLParagraphElement>('p');
|
||||
|
||||
newParagraph2 = body.insert(d3Selection.creator<HTMLParagraphElement>('p'), 'p.second-paragraph');
|
||||
newParagraph2 = body.insert(d3Selection.creator<HTMLParagraphElement>('p'), beforeValueFunction);
|
||||
newParagraph2 = body.insert(d3Selection.creator<HTMLParagraphElement>('p'));
|
||||
newParagraph = body.insert(d3Selection.creator<HTMLParagraphElement>('p'), 'p.second-paragraph');
|
||||
newParagraph = body.insert(d3Selection.creator<HTMLParagraphElement>('p'), beforeValueFunction);
|
||||
newParagraph = body.insert(d3Selection.creator<HTMLParagraphElement>('p'));
|
||||
|
||||
newParagraph2 = body.insert(typeValueFunction, 'p.second-paragraph');
|
||||
newParagraph2 = body.insert(typeValueFunction, beforeValueFunction);
|
||||
newParagraph2 = body.insert(typeValueFunction);
|
||||
newParagraph = body.insert(typeValueFunction, 'p.second-paragraph');
|
||||
newParagraph = body.insert(typeValueFunction, beforeValueFunction);
|
||||
newParagraph = body.insert(typeValueFunction);
|
||||
|
||||
// clone(...) ----------------------------------------------------------------------------
|
||||
|
||||
let clonedParagraph: d3Selection.Selection<HTMLParagraphElement, BodyDatum, HTMLElement, any>;
|
||||
|
||||
// shallow clone
|
||||
clonedParagraph = newParagraph2.clone();
|
||||
clonedParagraph = newParagraph.clone();
|
||||
|
||||
// deep clone
|
||||
|
||||
newParagraph.append('span');
|
||||
clonedParagraph = newParagraph2.clone(true);
|
||||
clonedParagraph = newParagraph.clone(true);
|
||||
|
||||
// sort(...) -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Vendored
+51
-1
@@ -5,6 +5,7 @@
|
||||
// Boris Yankov <https://github.com/borisyankov>
|
||||
// denisname <https://github.com/denisname>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.3.0
|
||||
|
||||
@@ -464,6 +465,19 @@ export interface Selection<GElement extends BaseType, Datum, PElement extends Ba
|
||||
*/
|
||||
html(value: ValueFn<GElement, Datum, string | null>): this;
|
||||
|
||||
/**
|
||||
* Appends a new element of this type (tag name) as the last child of each selected element,
|
||||
* or before the next following sibling in the update selection if this is an enter selection.
|
||||
* The latter behavior for enter selections allows you to insert elements into the DOM in an order consistent with the new bound data;
|
||||
* however, note that selection.order may still be required if updating elements change order
|
||||
* (i.e., if the order of new data is inconsistent with old data).
|
||||
*
|
||||
* This method returns a new selection containing the appended elements.
|
||||
* Each new element inherits the data of the current elements, if any.
|
||||
*
|
||||
* @param type A string representing the tag name.
|
||||
*/
|
||||
append<K extends keyof ElementTagNameMap>(type: K): Selection<ElementTagNameMap[K], Datum, PElement, PDatum>;
|
||||
/**
|
||||
* Appends a new element of this type (tag name) as the last child of each selected element,
|
||||
* or before the next following sibling in the update selection if this is an enter selection.
|
||||
@@ -482,6 +496,7 @@ export interface Selection<GElement extends BaseType, Datum, PElement extends Ba
|
||||
* (for example, svg implies svg:svg)
|
||||
*/
|
||||
append<ChildElement extends BaseType>(type: string): Selection<ChildElement, Datum, PElement, PDatum>;
|
||||
|
||||
/**
|
||||
* Appends a new element of the type provided by the element creator function as the last child of each selected element,
|
||||
* or before the next following sibling in the update selection if this is an enter selection.
|
||||
@@ -500,6 +515,27 @@ export interface Selection<GElement extends BaseType, Datum, PElement extends Ba
|
||||
*/
|
||||
append<ChildElement extends BaseType>(type: ValueFn<GElement, Datum, ChildElement>): Selection<ChildElement, Datum, PElement, PDatum>;
|
||||
|
||||
/**
|
||||
* Inserts a new element of the specified type (tag name) before the first element matching the specified
|
||||
* before selector for each selected element. For example, a before selector :first-child will prepend nodes before the first child.
|
||||
* If before is not specified, it defaults to null. (To append elements in an order consistent with bound data, use selection.append.)
|
||||
*
|
||||
* This method returns a new selection containing the appended elements.
|
||||
* Each new element inherits the data of the current elements, if any.
|
||||
*
|
||||
* The generic refers to the type of the child element to be appended.
|
||||
*
|
||||
* @param type A string representing the tag name for the element type to be inserted.
|
||||
* @param before One of:
|
||||
* * A CSS selector string for the element before which the insertion should occur.
|
||||
* * A child selector function which is evaluated for each selected element, in order, being passed the current datum (d),
|
||||
* the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return the child element
|
||||
* before which the element should be inserted.
|
||||
*/
|
||||
insert<K extends keyof ElementTagNameMap>(
|
||||
type: K,
|
||||
before?: string | ValueFn<GElement, Datum, BaseType>
|
||||
): Selection<ElementTagNameMap[K], Datum, PElement, PDatum>;
|
||||
/**
|
||||
* Inserts a new element of the specified type (tag name) before the first element matching the specified
|
||||
* before selector for each selected element. For example, a before selector :first-child will prepend nodes before the first child.
|
||||
@@ -527,7 +563,7 @@ export interface Selection<GElement extends BaseType, Datum, PElement extends Ba
|
||||
insert<ChildElement extends BaseType>(
|
||||
type: string | ValueFn<GElement, Datum, ChildElement>,
|
||||
before?: string | ValueFn<GElement, Datum, BaseType>
|
||||
): Selection<ChildElement, Datum, PElement, PDatum>;
|
||||
): Selection<ChildElement, Datum, PElement, PDatum>;
|
||||
|
||||
/**
|
||||
* Removes the selected elements from the document.
|
||||
@@ -1115,6 +1151,13 @@ export function window(DOMNode: Window | Document | Element): Window;
|
||||
// for explicit bound-context dependent use
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Given the specified element name, returns a single-element selection containing
|
||||
* a detached element of the given name in the current document.
|
||||
*
|
||||
* @param name tag name of the element to be added.
|
||||
*/
|
||||
export function create<K extends keyof ElementTagNameMap>(name: K): Selection<ElementTagNameMap[K], undefined, null, undefined>;
|
||||
/**
|
||||
* Given the specified element name, returns a single-element selection containing
|
||||
* a detached element of the given name in the current document.
|
||||
@@ -1124,6 +1167,13 @@ export function window(DOMNode: Window | Document | Element): Window;
|
||||
*/
|
||||
export function create<NewGElement extends Element>(name: string): Selection<NewGElement, undefined, null, undefined>;
|
||||
|
||||
/**
|
||||
* Given the specified element name, returns a function which creates an element of the given name,
|
||||
* assuming that "this" is the parent element.
|
||||
*
|
||||
* @param name Tag name of the element to be added.
|
||||
*/
|
||||
export function creator<K extends keyof ElementTagNameMap>(name: K): (this: BaseType) => ElementTagNameMap[K];
|
||||
/**
|
||||
* Given the specified element name, returns a function which creates an element of the given name,
|
||||
* assuming that "this" is the parent element.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// TODO
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-this-assignment": false,
|
||||
"unified-signatures": false,
|
||||
"no-unnecessary-generics": false
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/d3/d3-shape/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.2.0
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ circles = select<SVGSVGElement, any>('svg')
|
||||
.selectAll()
|
||||
.data(startCircleData)
|
||||
.enter()
|
||||
.append<SVGCircleElement>('circle')
|
||||
.append('circle')
|
||||
.attr('cx', d => d.cx)
|
||||
.attr('cy', d => d.cy)
|
||||
.attr('r', d => d.r)
|
||||
@@ -114,7 +114,7 @@ circles = circles
|
||||
|
||||
const enterCircles = circles
|
||||
.enter()
|
||||
.append<SVGCircleElement>('circle')
|
||||
.append('circle')
|
||||
.classed('big', d => d.r > 10)
|
||||
.attr('cx', d => d.cx)
|
||||
.attr('cy', d => d.cy)
|
||||
|
||||
@@ -65,11 +65,11 @@ const svg = select<SVGSVGElement, undefined>('svg')
|
||||
.attr('width', d => d.width)
|
||||
.attr('height', d => d.height);
|
||||
|
||||
const g = svg.append<SVGGElement>('g');
|
||||
const g = svg.append('g');
|
||||
|
||||
g.selectAll()
|
||||
.data<[number, number]>(points)
|
||||
.enter().append<SVGCircleElement>('circle')
|
||||
.enter().append('circle')
|
||||
.attr('cx', d => d[0])
|
||||
.attr('cy', d => d[1])
|
||||
.attr('r', 2.5);
|
||||
@@ -280,7 +280,7 @@ canvas.call(canvasZoom);
|
||||
// SVG Example --------------------------------------------------------------
|
||||
|
||||
// attach the zoom behavior to an overlay svg rectangle
|
||||
const svgOverlay: Selection<SVGRectElement, SVGDatum, HTMLElement, any> = svg.append<SVGRectElement>('rect')
|
||||
const svgOverlay: Selection<SVGRectElement, SVGDatum, HTMLElement, any> = svg.append('rect')
|
||||
.attr('width', d => d.width)
|
||||
.attr('height', d => d.height)
|
||||
.style('fill', 'none')
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// TODO
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-this-assignment": false,
|
||||
"unified-signatures": false,
|
||||
"no-unnecessary-generics": false
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// TODO
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-object-literal-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import depsSort = require("deps-sort");
|
||||
|
||||
function browserifyTest(opts: depsSort.Options) {
|
||||
const depsOpts: depsSort.Options = {
|
||||
index: opts != null && opts.index,
|
||||
dedupe: opts != null && opts.dedupe,
|
||||
expose: opts.expose || { id: "file.txt" }
|
||||
};
|
||||
|
||||
const res = depsSort(); // 'opts' are optional
|
||||
res.pipe(depsSort(depsOpts));
|
||||
|
||||
res.once("error", (err: any) => {
|
||||
console.error("module-deps error: ", err);
|
||||
});
|
||||
|
||||
const inst: NodeJS.ReadWriteStream = depsSort({
|
||||
index: true,
|
||||
expose: { id: "file.txt" }
|
||||
});
|
||||
|
||||
inst.on("file", (file, id) => {
|
||||
console.log("file", file, id);
|
||||
});
|
||||
inst.on("package", (pkg) => {
|
||||
console.log("package", pkg);
|
||||
});
|
||||
inst.on("transform", (tr, file) => {
|
||||
console.log("transform", tr, file);
|
||||
});
|
||||
}
|
||||
Vendored
+85
@@ -0,0 +1,85 @@
|
||||
// Type definitions for deps-sort 2.0
|
||||
// Project: https://github.com/browserify/deps-sort
|
||||
// Definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as stream from "stream";
|
||||
|
||||
/**
|
||||
* Return a new through stream that should get written module-deps objects and will output sorted objects.
|
||||
*/
|
||||
declare function depsSort(opts?: depsSort.Options): stream.Transform;
|
||||
|
||||
/**
|
||||
* Sort module-deps output for deterministic browserify bundles.
|
||||
*/
|
||||
declare namespace depsSort {
|
||||
/**
|
||||
* module-deps constructor options
|
||||
*/
|
||||
interface Options {
|
||||
/**
|
||||
* When true, for each module-deps row, insert 'row.index' with the numeric index and
|
||||
* 'row.indexDeps' like 'row.deps' but mapping require strings to row indices
|
||||
*/
|
||||
index?: boolean;
|
||||
|
||||
/**
|
||||
* array of names or object mapping names to true not to mangle with integer indexes when 'index' is turned on.
|
||||
* If 'expose' maps names to strings, those strings will be used to resolve the indexed references.
|
||||
*/
|
||||
expose?: string[] | { [name: string]: boolean | string };
|
||||
|
||||
/**
|
||||
* Set 'row.dedupe' for files that match existing contents. Sets 'row.dedupeIndex' when 'index' is enabled.
|
||||
* When 'row.dedupe' is set, 'row.sameDeps' will be set to a boolean of whether the dependencies at the dedupe target match (true) or just the source content (false).
|
||||
*/
|
||||
dedupe?: boolean;
|
||||
|
||||
[prop: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Input objects are file objects in the module-deps shape. They must at least have these properties:
|
||||
*/
|
||||
interface InputRow {
|
||||
/**
|
||||
* a unique identifier for the file
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* the file contents
|
||||
*/
|
||||
source: string;
|
||||
/**
|
||||
* dependencies for this file, mapping strings as used in require() to row IDs
|
||||
*/
|
||||
deps: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* All the input properties, and:
|
||||
*/
|
||||
interface OutputRow {
|
||||
/**
|
||||
* when 'opts.index' is true, the sorted numeric index of the row
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* like 'row.deps', but mapping to 'row.index' instead of 'row.id'
|
||||
*/
|
||||
indexDeps: { [id: string]: number };
|
||||
/**
|
||||
* when 'opts.dedupe' is true, contains the row ID of a file with identical contents
|
||||
*/
|
||||
dedupe: string;
|
||||
/**
|
||||
* like 'row.dedupe', but contains the 'row.index' instead of 'row.id'
|
||||
*/
|
||||
dedupeIndex: number;
|
||||
}
|
||||
}
|
||||
|
||||
export = depsSort;
|
||||
@@ -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",
|
||||
"deps-sort-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+10
@@ -370,6 +370,11 @@ declare namespace Detox {
|
||||
type Orientation = "portrait" | "landscape";
|
||||
type Speed = "fast" | "slow";
|
||||
|
||||
interface LanguageAndLocale {
|
||||
language?: string;
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
interface DetoxInitOptions {
|
||||
/**
|
||||
* Detox exports device, expect, element, by and waitFor as globals by default, if you want to control their initialization manually, set init detox with initGlobals set to false.
|
||||
@@ -416,5 +421,10 @@ declare namespace Detox {
|
||||
* The added launchArgs will be passed through the launch command to the device and be accessible via [[NSProcessInfo processInfo] arguments]
|
||||
*/
|
||||
launchArgs?: any;
|
||||
|
||||
/**
|
||||
* Launch config for specifying the native language and locale
|
||||
*/
|
||||
languageAndLocale?: LanguageAndLocale;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user