From f5d60ed96459ab5c886de80b0896f32a425657d7 Mon Sep 17 00:00:00 2001 From: Will Soto Date: Sun, 21 Oct 2018 18:56:51 -0400 Subject: [PATCH 01/68] Update enum arguments to reflect latest signature See https://knexjs.org/#Schema-enum https://github.com/tgriesser/knex/pull/2632 https://github.com/tgriesser/knex/issues/394 Signed-off-by: Will Soto --- types/knex/index.d.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index 4d9b1b25f5..3aefe33dca 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Knex.js 0.14 +// Type definitions for Knex.js 0.15.2 // Project: https://github.com/tgriesser/knex // Definitions by: Qubo // Pablo Rodríguez @@ -444,8 +444,8 @@ declare namespace Knex { timestamp(columnName: string, standard?: boolean): ColumnBuilder; timestamps(useTimestampType?: boolean, makeDefaultNow?: boolean): ColumnBuilder; binary(columnName: string, length?: number): ColumnBuilder; - enum(columnName: string, values: Value[]): ColumnBuilder; - enu(columnName: string, values: Value[]): ColumnBuilder; + enum(columnName: string, values: Value[], options?: EnumOptions): ColumnBuilder; + enu(columnName: string, values: Value[], options?: EnumOptions): ColumnBuilder; json(columnName: string): ColumnBuilder; jsonb(columnName: string): ColumnBuilder; uuid(columnName: string): ColumnBuilder; @@ -517,6 +517,11 @@ declare namespace Knex { after(columnName: string): AlterColumnBuilder; } + interface EnumOptions { + useNative: boolean; + enumName: string; + } + // // Configurations // From 639b07d60dc248e05604857f6ef09238a45a79a4 Mon Sep 17 00:00:00 2001 From: Greg Jednaszewski Date: Tue, 23 Oct 2018 10:58:19 -0400 Subject: [PATCH 02/68] Add glue v4 typings --- types/glue/v4/glue-tests.ts | 34 ++++++++++++++++++++++++++++++++++ types/glue/v4/index.d.ts | 31 +++++++++++++++++++++++++++++++ types/glue/v4/tsconfig.json | 29 +++++++++++++++++++++++++++++ types/glue/v4/tslint.json | 3 +++ 4 files changed, 97 insertions(+) create mode 100644 types/glue/v4/glue-tests.ts create mode 100644 types/glue/v4/index.d.ts create mode 100644 types/glue/v4/tsconfig.json create mode 100644 types/glue/v4/tslint.json diff --git a/types/glue/v4/glue-tests.ts b/types/glue/v4/glue-tests.ts new file mode 100644 index 0000000000..5b0b3ad986 --- /dev/null +++ b/types/glue/v4/glue-tests.ts @@ -0,0 +1,34 @@ +import * as glue from "glue"; +import * as hapi from "hapi"; + +const serverOptions: hapi.ServerOptions = { + debug: false +}; + +const serverConnectionOptions: hapi.ServerConnectionOptions = { + port: 3000 +}; + +const manifest: glue.Manifest = { + server: serverOptions, + connections: [ serverConnectionOptions ], + registrations: [ + { + plugin: "./test.js", + }, + { + plugin: { + register: "test", + options: { + foo: "bar" + } + } + } + ], +}; + +const options: glue.Options = { + relativeTo: `${__dirname}/modules` +}; + +glue.compose(manifest, options); diff --git a/types/glue/v4/index.d.ts b/types/glue/v4/index.d.ts new file mode 100644 index 0000000000..c6f5a14679 --- /dev/null +++ b/types/glue/v4/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for glue 4.0 +// Project: https://github.com/hapijs/glue +// Definitions by: Greg Jednaszewski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Server, ServerConnectionOptions, ServerOptions } from "hapi"; + +export interface Options { + relativeTo: string; + preConnections?: (Server: Server, next: (err: any) => void) => void; + preRegister?: (Server: Server, next: (err: any) => void) => void; +} + +export interface Plugin { + plugin: string | { + register: string; + options?: any; + }; + options?: any; +} + +export interface Manifest { + server: ServerOptions; + connections: ServerConnectionOptions[]; + registrations?: Plugin[]; +} + +export function compose(manifest: Manifest, + options?: Options, + callback?: (err?: any, server?: Server) => void): Promise; diff --git a/types/glue/v4/tsconfig.json b/types/glue/v4/tsconfig.json new file mode 100644 index 0000000000..ead9b81629 --- /dev/null +++ b/types/glue/v4/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "boom": [ "boom/v4" ], + "catbox": [ "catbox/v7" ], + "hapi": [ "hapi/v16" ], + "glue": [ "glue/v4" ] + } + }, + "files": [ + "index.d.ts", + "glue-tests.ts" + ] +} diff --git a/types/glue/v4/tslint.json b/types/glue/v4/tslint.json new file mode 100644 index 0000000000..30a1bdde2e --- /dev/null +++ b/types/glue/v4/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file From 2b602f8da3e7b09206d01703c233c24c288a09be Mon Sep 17 00:00:00 2001 From: Greg Jednaszewski Date: Tue, 23 Oct 2018 10:58:19 -0400 Subject: [PATCH 03/68] Add glue v4 typings --- types/glue/v4/glue-tests.ts | 69 +++++++++++++++++++++++++++++++++++++ types/glue/v4/index.d.ts | 31 +++++++++++++++++ types/glue/v4/tsconfig.json | 29 ++++++++++++++++ types/glue/v4/tslint.json | 3 ++ 4 files changed, 132 insertions(+) create mode 100644 types/glue/v4/glue-tests.ts create mode 100644 types/glue/v4/index.d.ts create mode 100644 types/glue/v4/tsconfig.json create mode 100644 types/glue/v4/tslint.json diff --git a/types/glue/v4/glue-tests.ts b/types/glue/v4/glue-tests.ts new file mode 100644 index 0000000000..1b67554725 --- /dev/null +++ b/types/glue/v4/glue-tests.ts @@ -0,0 +1,69 @@ +import * as glue from "glue"; +import * as hapi from "hapi"; + +const manifest: glue.Manifest = { + server: { + debug: false, + }, + connections: [ + { + port: 8000, + labels: ['web'] + }, + { + port: 8001, + labels: ['admin'] + } + ], + registrations: [ + { + plugin: { + register: './assets', + options: { + uglify: true + } + } + }, + { + plugin: './ui-user', + options: { + select: ['web'] + } + }, + { + plugin: { + register: './ui-admin', + options: { + sessiontime: 500 + } + }, + options: { + select: ['admin'], + routes: { + prefix: '/admin' + } + } + }, + { + plugin: { + register: require('./awesome-plugin.js'), + options: { + whyNot: true + } + } + }, + ] +}; + +const options: glue.Options = { + relativeTo: `${__dirname}/modules` +}; + +glue.compose(manifest, options, (err, server) => { + if (err) { + throw err; + } + server.start(() => { + console.log('hapi days!'); + }); +}); diff --git a/types/glue/v4/index.d.ts b/types/glue/v4/index.d.ts new file mode 100644 index 0000000000..c6f5a14679 --- /dev/null +++ b/types/glue/v4/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for glue 4.0 +// Project: https://github.com/hapijs/glue +// Definitions by: Greg Jednaszewski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Server, ServerConnectionOptions, ServerOptions } from "hapi"; + +export interface Options { + relativeTo: string; + preConnections?: (Server: Server, next: (err: any) => void) => void; + preRegister?: (Server: Server, next: (err: any) => void) => void; +} + +export interface Plugin { + plugin: string | { + register: string; + options?: any; + }; + options?: any; +} + +export interface Manifest { + server: ServerOptions; + connections: ServerConnectionOptions[]; + registrations?: Plugin[]; +} + +export function compose(manifest: Manifest, + options?: Options, + callback?: (err?: any, server?: Server) => void): Promise; diff --git a/types/glue/v4/tsconfig.json b/types/glue/v4/tsconfig.json new file mode 100644 index 0000000000..ead9b81629 --- /dev/null +++ b/types/glue/v4/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "boom": [ "boom/v4" ], + "catbox": [ "catbox/v7" ], + "hapi": [ "hapi/v16" ], + "glue": [ "glue/v4" ] + } + }, + "files": [ + "index.d.ts", + "glue-tests.ts" + ] +} diff --git a/types/glue/v4/tslint.json b/types/glue/v4/tslint.json new file mode 100644 index 0000000000..30a1bdde2e --- /dev/null +++ b/types/glue/v4/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file From 76c49f0c9dac7a2baab6db234571cc2748aae8d1 Mon Sep 17 00:00:00 2001 From: Greg Jednaszewski Date: Tue, 23 Oct 2018 11:31:30 -0400 Subject: [PATCH 04/68] Match hapi v16 typescript version --- types/glue/v4/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/glue/v4/index.d.ts b/types/glue/v4/index.d.ts index c6f5a14679..69c7d56d01 100644 --- a/types/glue/v4/index.d.ts +++ b/types/glue/v4/index.d.ts @@ -1,8 +1,8 @@ -// Type definitions for glue 4.0 +// Type definitions for glue 4.2 // Project: https://github.com/hapijs/glue // Definitions by: Greg Jednaszewski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 2.4 import { Server, ServerConnectionOptions, ServerOptions } from "hapi"; From ebadcef9b0aedc8229c83cafe5076a63f1515834 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 10:11:19 +0200 Subject: [PATCH 05/68] Add terser types Adds types for the terser module. Based on the uglify-js types. Extended and corrected some things. --- types/terser/index.d.ts | 493 +++++++++++++++++++++++++++++++++++ types/terser/package.json | 25 ++ types/terser/terser-tests.ts | 33 +++ types/terser/tsconfig.json | 23 ++ types/terser/tslint.json | 3 + 5 files changed, 577 insertions(+) create mode 100644 types/terser/index.d.ts create mode 100644 types/terser/package.json create mode 100644 types/terser/terser-tests.ts create mode 100644 types/terser/tsconfig.json create mode 100644 types/terser/tslint.json diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts new file mode 100644 index 0000000000..905ba01d6d --- /dev/null +++ b/types/terser/index.d.ts @@ -0,0 +1,493 @@ +// Type definitions for Terser 3.8.1 +// Project: https://github.com/terser-js/terser +// Definitions by: JordiAnderl +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import * as MOZ_SourceMap from "source-map"; + +declare module "terser" { + interface Tokenizer { + /** + * The type of this token. + * Can be "num", "string", "regexp", "operator", "punc", "atom", "name", "keyword", "comment1" or "comment2". + * "comment1" and "comment2" are for single-line, respectively multi-line comments. + */ + type: string; + + /** + * The name of the file where this token originated from. Useful when compressing multiple files at once to generate the proper source map. + */ + file: string; + + /** + * The "value" of the token. + * That's additional information and depends on the token type: "num", "string" and "regexp" tokens you get their literal value. + * - For "operator" you get the operator. + * - For "punc" it's the punctuation sign (parens, comma, semicolon etc). + * - For "atom", "name" and "keyword" it's the name of the identifier + * - For comments it's the body of the comment (excluding the initial "//" and "/*". + */ + value: string; + + /** + * The line number of this token in the original code. + * 1-based index. + */ + line: number; + + /** + * The column number of this token in the original code. + * 0-based index. + */ + col: number; + + /** + * Short for "newline before", it's a boolean that tells us whether there was a newline before this node in the original source. It helps for automatic semicolon insertion. + * For multi-line comments in particular this will be set to true if there either was a newline before this comment, or * * if this comment contains a newline. + */ + nlb: boolean; + + /** + * This doesn't apply for comment tokens, but for all other token types it will be an array of comment tokens that were found before. + */ + comments_before: string[]; + } + + class AST_Node { + // The first token of this node + start: AST_Node; + + // The last token of this node + end: AST_Node; + + value?: string | number; + file?: string; + property?: string; + key?: string; + + transform(tt: TreeTransformer): AST_Toplevel; + + walk(walker: TreeWalker): void; + } + + class AST_Toplevel extends AST_Node { + // Terser contains a scope analyzer which figures out variable/function definitions, references etc. + // You need to call it manually before compression or mangling. + // The figure_out_scope method is defined only on the AST_Toplevel node. + figure_out_scope(): void; + + // Get names that are optimized for GZip compression (names will be generated using the most frequent characters first) + compute_char_frequency(): void; + + mangle_names(): void; + + print(stream: OutputStream): void; + + print_to_string(options?: BeautifierOptions): string; + + } + + interface MinifyOptions { + spidermonkey?: boolean; + outSourceMap?: string; + sourceRoot?: string; + inSourceMap?: string; + fromString?: boolean; + warnings?: boolean; + mangle?: Object; + output?: MinifyOutput; + compress?: Object; + nameCache?: {}; + } + + interface MinifyOutput { + code: string; + map: string; + warnings?: string[]; + error?: string; + ast?: boolean | AST_Toplevel; + } + + function minify(files: {}, options?: MinifyOptions): MinifyOutput; + + + interface ParseOptions { + // Default is false + strict?: boolean; + + // Input file name, default is null + filename?: string; + + // Default is null + toplevel?: AST_Toplevel; + } + + /** + * The parser creates a custom abstract syntax tree given a piece of JavaScript code. + * Perhaps you should read about the AST first. + */ + function parse(code: string, options?: ParseOptions): AST_Toplevel; + + + interface BeautifierOptions { + /** + * Start indentation on every line (only when `beautify`) + */ + indent_start?: number; + + /** + * Indentation level (only when `beautify`) + */ + indent_level?: number; + + /** + * Quote all keys in object literals? + */ + quote_keys?: boolean; + + /** + * Add a space after colon signs? + */ + space_colon?: boolean; + + /** + * Output ASCII-safe? (encodes Unicode characters as ASCII) + */ + ascii_only?: boolean; + + /** + * Escape " AST_Scope; + stack: AST_Scope[]; + } + + type visitor = (node: AST_Node, descend: Function) => boolean | void; + + // TODO: + + /** + * The tree transformer is a special case of a tree walker. + * In fact it even inherits from TreeWalker and you can use the same methods, but initialization and visitor protocol are a bit different. + */ + class TreeTransformer extends TreeWalker { + constructor(visitor: visitor, after: visitor); + } + + // TODO: http://lisperator.net/Terser/ast + + class AST_PropAccess extends AST_Node { + } + + class AST_ObjectKeyVal extends AST_Node { + } + + class AST_Scope extends AST_Node { + find_variable(name: string): AST_SymbolDeclaration; + } + + class AST_Symbol extends AST_Node { + scope?: AST_Scope; + name: string; + thedef: unknown; + } + + class AST_SymbolDeclaration extends AST_Symbol { + orig: AST_SymbolDeclaration[]; + references: AST_SymbolRef[]; + global: boolean; + undeclared: boolean; + constant: boolean; + mangledName?: string; + mangled_name?: string; + } + + class AST_SymbolRef extends AST_Symbol { + + } + + class AST_Call extends AST_Node { + expression: { name?: string, property?: string }; + args: AST_Node[]; + } + class AST_String extends AST_Node { + value: string; + } + class AST_Lambda extends AST_Node { + name?: string; + } + class AST_SymbolMethod extends AST_Node { + name?: string; + } + class AST_ConciseMethod extends AST_Node { + + } + class AST_SymbolVar extends AST_Node { + name?: string; + } +} + +export * from 'uglify-js'; + diff --git a/types/terser/package.json b/types/terser/package.json new file mode 100644 index 0000000000..11573ccf73 --- /dev/null +++ b/types/terser/package.json @@ -0,0 +1,25 @@ +{ + "name": "@types/terser", + "version": "3.8.1", + "private": true, + "description": "TypeScript definitions for terser", + "license": "MIT", + "contributors": [ + { + "name": "Jordi Anderl", + "url": "https://github.com/JordiAnderl", + "githubUsername": "JordiAnderl" + } + ], + "main": "", + "repository": { + "type": "git", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git" + }, + "scripts": {}, + "dependencies": { + "@types/uglify-js": "*", + "source-map": "*" + }, + "typeScriptVersion": "2.2" +} diff --git a/types/terser/terser-tests.ts b/types/terser/terser-tests.ts new file mode 100644 index 0000000000..49b9190070 --- /dev/null +++ b/types/terser/terser-tests.ts @@ -0,0 +1,33 @@ +/// + +import { OutputQuoteStyle, minify } from 'terser'; + +let code: any; + +code = { + "file1.js": "function add(first, second) { return first + second; }", + "file2.js": "console.log(add(1 + 2, 3 + 4));" +}; + +minify(code); + +code = "function add(first, second) { return first + second; }"; +minify(code); + +minify(code); + +const output = minify(code, { + warnings: true, + mangle: { + properties: { + regex: /reg/ + } + }, + compress: { + arguments: true + } +}); + +if (output.warnings) { + output.warnings.filter(x => x === 'Dropping unused variable'); +} diff --git a/types/terser/tsconfig.json b/types/terser/tsconfig.json new file mode 100644 index 0000000000..937a5d1350 --- /dev/null +++ b/types/terser/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "terser-tests.ts" + ] +} diff --git a/types/terser/tslint.json b/types/terser/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/terser/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From e7d57ca2eca9034a471c1c2f879883b7b1ecf60a Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 10:32:16 +0200 Subject: [PATCH 06/68] Changes in package.json Fix tests --- types/terser/package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/terser/package.json b/types/terser/package.json index 11573ccf73..9c41e7c621 100644 --- a/types/terser/package.json +++ b/types/terser/package.json @@ -1,9 +1,7 @@ { "name": "@types/terser", "version": "3.8.1", - "private": true, "description": "TypeScript definitions for terser", - "license": "MIT", "contributors": [ { "name": "Jordi Anderl", From 8d4988084b9dc977e6d862d26191c6f29b72d99a Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 10:34:52 +0200 Subject: [PATCH 07/68] Fix dependencies --- types/terser/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/types/terser/package.json b/types/terser/package.json index 9c41e7c621..6ecaa25c92 100644 --- a/types/terser/package.json +++ b/types/terser/package.json @@ -16,7 +16,6 @@ }, "scripts": {}, "dependencies": { - "@types/uglify-js": "*", "source-map": "*" }, "typeScriptVersion": "2.2" From 2d88cac8f277e15b38f44f481481d1cdf1cb78ec Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 10:42:26 +0200 Subject: [PATCH 08/68] Private => true in package.json --- types/terser/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/terser/package.json b/types/terser/package.json index 6ecaa25c92..0e6e244d83 100644 --- a/types/terser/package.json +++ b/types/terser/package.json @@ -1,6 +1,7 @@ { "name": "@types/terser", "version": "3.8.1", + "private": true, "description": "TypeScript definitions for terser", "contributors": [ { From ea1a8d27fc2922b8b0a2bf72a3d1af15525b1275 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 10:48:08 +0200 Subject: [PATCH 09/68] Fix package.json should not include field name --- types/terser/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/types/terser/package.json b/types/terser/package.json index 0e6e244d83..00f3008570 100644 --- a/types/terser/package.json +++ b/types/terser/package.json @@ -1,5 +1,4 @@ { - "name": "@types/terser", "version": "3.8.1", "private": true, "description": "TypeScript definitions for terser", From caa5d977682db8e92d160f6cb66cd8ca3bea9b95 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 10:55:55 +0200 Subject: [PATCH 10/68] Remove version --- types/terser/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/types/terser/package.json b/types/terser/package.json index 00f3008570..118657f66f 100644 --- a/types/terser/package.json +++ b/types/terser/package.json @@ -1,5 +1,4 @@ { - "version": "3.8.1", "private": true, "description": "TypeScript definitions for terser", "contributors": [ From fe5a7299c3969f6bcffe209c47ffd7eefbb1d9c5 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 10:58:00 +0200 Subject: [PATCH 11/68] Description --- types/terser/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/types/terser/package.json b/types/terser/package.json index 118657f66f..cb7e199622 100644 --- a/types/terser/package.json +++ b/types/terser/package.json @@ -1,6 +1,5 @@ { "private": true, - "description": "TypeScript definitions for terser", "contributors": [ { "name": "Jordi Anderl", From f100cd5b1012cd2a3d4660030124e4ea7fd54f4c Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 10:59:14 +0200 Subject: [PATCH 12/68] Remove more fields --- types/terser/package.json | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/types/terser/package.json b/types/terser/package.json index cb7e199622..69ad27c300 100644 --- a/types/terser/package.json +++ b/types/terser/package.json @@ -1,18 +1,5 @@ { "private": true, - "contributors": [ - { - "name": "Jordi Anderl", - "url": "https://github.com/JordiAnderl", - "githubUsername": "JordiAnderl" - } - ], - "main": "", - "repository": { - "type": "git", - "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git" - }, - "scripts": {}, "dependencies": { "source-map": "*" }, From f9af6e5e914b1fb1496ff4aab2300c6424d446f6 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 11:01:02 +0200 Subject: [PATCH 13/68] Remove version --- types/terser/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/terser/package.json b/types/terser/package.json index 69ad27c300..25c65e7595 100644 --- a/types/terser/package.json +++ b/types/terser/package.json @@ -2,6 +2,5 @@ "private": true, "dependencies": { "source-map": "*" - }, - "typeScriptVersion": "2.2" + } } From 0b4f82865f437a3930db015adc645918df40cce5 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 11:08:51 +0200 Subject: [PATCH 14/68] Remove module declaration --- types/terser/index.d.ts | 904 ++++++++++++++++++++-------------------- 1 file changed, 450 insertions(+), 454 deletions(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 905ba01d6d..5a1d0e5aea 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Terser 3.8.1 +// Type definitions for terser 3.8.1 // Project: https://github.com/terser-js/terser // Definitions by: JordiAnderl // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,487 +6,483 @@ import * as MOZ_SourceMap from "source-map"; -declare module "terser" { - interface Tokenizer { - /** - * The type of this token. - * Can be "num", "string", "regexp", "operator", "punc", "atom", "name", "keyword", "comment1" or "comment2". - * "comment1" and "comment2" are for single-line, respectively multi-line comments. - */ - type: string; - - /** - * The name of the file where this token originated from. Useful when compressing multiple files at once to generate the proper source map. - */ - file: string; - - /** - * The "value" of the token. - * That's additional information and depends on the token type: "num", "string" and "regexp" tokens you get their literal value. - * - For "operator" you get the operator. - * - For "punc" it's the punctuation sign (parens, comma, semicolon etc). - * - For "atom", "name" and "keyword" it's the name of the identifier - * - For comments it's the body of the comment (excluding the initial "//" and "/*". - */ - value: string; - - /** - * The line number of this token in the original code. - * 1-based index. - */ - line: number; - - /** - * The column number of this token in the original code. - * 0-based index. - */ - col: number; - - /** - * Short for "newline before", it's a boolean that tells us whether there was a newline before this node in the original source. It helps for automatic semicolon insertion. - * For multi-line comments in particular this will be set to true if there either was a newline before this comment, or * * if this comment contains a newline. - */ - nlb: boolean; - - /** - * This doesn't apply for comment tokens, but for all other token types it will be an array of comment tokens that were found before. - */ - comments_before: string[]; - } - - class AST_Node { - // The first token of this node - start: AST_Node; - - // The last token of this node - end: AST_Node; - - value?: string | number; - file?: string; - property?: string; - key?: string; - - transform(tt: TreeTransformer): AST_Toplevel; - - walk(walker: TreeWalker): void; - } - - class AST_Toplevel extends AST_Node { - // Terser contains a scope analyzer which figures out variable/function definitions, references etc. - // You need to call it manually before compression or mangling. - // The figure_out_scope method is defined only on the AST_Toplevel node. - figure_out_scope(): void; - - // Get names that are optimized for GZip compression (names will be generated using the most frequent characters first) - compute_char_frequency(): void; - - mangle_names(): void; - - print(stream: OutputStream): void; - - print_to_string(options?: BeautifierOptions): string; - - } - - interface MinifyOptions { - spidermonkey?: boolean; - outSourceMap?: string; - sourceRoot?: string; - inSourceMap?: string; - fromString?: boolean; - warnings?: boolean; - mangle?: Object; - output?: MinifyOutput; - compress?: Object; - nameCache?: {}; - } - - interface MinifyOutput { - code: string; - map: string; - warnings?: string[]; - error?: string; - ast?: boolean | AST_Toplevel; - } - - function minify(files: {}, options?: MinifyOptions): MinifyOutput; - - - interface ParseOptions { - // Default is false - strict?: boolean; - - // Input file name, default is null - filename?: string; - - // Default is null - toplevel?: AST_Toplevel; - } +export interface Tokenizer { + /** + * The type of this token. + * Can be "num", "string", "regexp", "operator", "punc", "atom", "name", "keyword", "comment1" or "comment2". + * "comment1" and "comment2" are for single-line, respectively multi-line comments. + */ + type: string; /** - * The parser creates a custom abstract syntax tree given a piece of JavaScript code. - * Perhaps you should read about the AST first. + * The name of the file where this token originated from. Useful when compressing multiple files at once to generate the proper source map. */ - function parse(code: string, options?: ParseOptions): AST_Toplevel; - - - interface BeautifierOptions { - /** - * Start indentation on every line (only when `beautify`) - */ - indent_start?: number; - - /** - * Indentation level (only when `beautify`) - */ - indent_level?: number; - - /** - * Quote all keys in object literals? - */ - quote_keys?: boolean; - - /** - * Add a space after colon signs? - */ - space_colon?: boolean; - - /** - * Output ASCII-safe? (encodes Unicode characters as ASCII) - */ - ascii_only?: boolean; - - /** - * Escape " AST_Scope; - stack: AST_Scope[]; - } - - type visitor = (node: AST_Node, descend: Function) => boolean | void; - - // TODO: + nlb: boolean; /** - * The tree transformer is a special case of a tree walker. - * In fact it even inherits from TreeWalker and you can use the same methods, but initialization and visitor protocol are a bit different. + * This doesn't apply for comment tokens, but for all other token types it will be an array of comment tokens that were found before. */ - class TreeTransformer extends TreeWalker { - constructor(visitor: visitor, after: visitor); - } + comments_before: string[]; +} - // TODO: http://lisperator.net/Terser/ast +declare class AST_Node { + // The first token of this node + start: AST_Node; - class AST_PropAccess extends AST_Node { - } + // The last token of this node + end: AST_Node; - class AST_ObjectKeyVal extends AST_Node { - } + value?: string | number; + file?: string; + property?: string; + key?: string; - class AST_Scope extends AST_Node { - find_variable(name: string): AST_SymbolDeclaration; - } + transform(tt: TreeTransformer): AST_Toplevel; - class AST_Symbol extends AST_Node { - scope?: AST_Scope; - name: string; - thedef: unknown; - } + walk(walker: TreeWalker): void; +} - class AST_SymbolDeclaration extends AST_Symbol { - orig: AST_SymbolDeclaration[]; - references: AST_SymbolRef[]; - global: boolean; - undeclared: boolean; - constant: boolean; - mangledName?: string; - mangled_name?: string; - } +declare class AST_Toplevel extends AST_Node { + // Terser contains a scope analyzer which figures out variable/function definitions, references etc. + // You need to call it manually before compression or mangling. + // The figure_out_scope method is defined only on the AST_Toplevel node. + figure_out_scope(): void; - class AST_SymbolRef extends AST_Symbol { + // Get names that are optimized for GZip compression (names will be generated using the most frequent characters first) + compute_char_frequency(): void; - } + mangle_names(): void; - class AST_Call extends AST_Node { - expression: { name?: string, property?: string }; - args: AST_Node[]; - } - class AST_String extends AST_Node { - value: string; - } - class AST_Lambda extends AST_Node { - name?: string; - } - class AST_SymbolMethod extends AST_Node { - name?: string; - } - class AST_ConciseMethod extends AST_Node { + print(stream: OutputStream): void; - } - class AST_SymbolVar extends AST_Node { - name?: string; - } + print_to_string(options?: BeautifierOptions): string; + +} + +export interface MinifyOptions { + spidermonkey?: boolean; + outSourceMap?: string; + sourceRoot?: string; + inSourceMap?: string; + fromString?: boolean; + warnings?: boolean; + mangle?: {}; + output?: MinifyOutput; + compress?: {}; + nameCache?: {}; +} + +export interface MinifyOutput { + code: string; + map: string; + warnings?: string[]; + error?: string; + ast?: boolean | AST_Toplevel; +} + +declare function minify(files: {}, options?: MinifyOptions): MinifyOutput; + +export interface ParseOptions { + // Default is false + strict?: boolean; + + // Input file name, default is null + filename?: string; + + // Default is null + toplevel?: AST_Toplevel; +} + +/** + * The parser creates a custom abstract syntax tree given a piece of JavaScript code. + * Perhaps you should read about the AST first. + */ +declare function parse(code: string, options?: ParseOptions): AST_Toplevel; + +export interface BeautifierOptions { + /** + * Start indentation on every line (only when `beautify`) + */ + indent_start?: number; + + /** + * Indentation level (only when `beautify`) + */ + indent_level?: number; + + /** + * Quote all keys in {} literals? + */ + quote_keys?: boolean; + + /** + * Add a space after colon signs? + */ + space_colon?: boolean; + + /** + * Output ASCII-safe? (encodes Unicode characters as ASCII) + */ + ascii_only?: boolean; + + /** + * Escape " AST_Scope; + stack: AST_Scope[]; +} + +export type visitor = (node: AST_Node, descend: Function) => boolean | void; + +// TODO: + +/** + * The tree transformer is a special case of a tree walker. + * In fact it even inherits from TreeWalker and you can use the same methods, but initialization and visitor protocol are a bit different. + */ +declare class TreeTransformer extends TreeWalker { + constructor(visitor: visitor, after: visitor); +} + +// TODO: http://lisperator.net/Terser/ast + +declare class AST_PropAccess extends AST_Node { +} + +declare class AST_{}KeyVal extends AST_Node { +} + +declare class AST_Scope extends AST_Node { + find_variable(name: string): AST_SymbolDeclaration; +} + +declare class AST_Symbol extends AST_Node { + scope?: AST_Scope; + name: string; + thedef: unknown; +} + +declare class AST_SymbolDeclaration extends AST_Symbol { + orig: AST_SymbolDeclaration[]; + references: AST_SymbolRef[]; + global: boolean; + undeclared: boolean; + constant: boolean; + mangledName?: string; + mangled_name?: string; +} + +declare class AST_SymbolRef extends AST_Symbol { + +} + +declare class AST_Call extends AST_Node { + expression: { name?: string, property?: string }; + args: AST_Node[]; +} +declare class AST_String extends AST_Node { + value: string; +} +declare class AST_Lambda extends AST_Node { + name?: string; +} +declare class AST_SymbolMethod extends AST_Node { + name?: string; +} +declare class AST_ConciseMethod extends AST_Node { + +} +declare class AST_SymbolVar extends AST_Node { + name?: string; } export * from 'uglify-js'; From cc0efe53659125a0fc0f449dddd16d5e7771d0ec Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 11:19:08 +0200 Subject: [PATCH 15/68] Remove declare --- types/terser/index.d.ts | 60 +++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 5a1d0e5aea..8e291379f1 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for terser 3.8.1 +// Type definitions for terser 3.8 // Project: https://github.com/terser-js/terser // Definitions by: JordiAnderl // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -53,7 +53,7 @@ export interface Tokenizer { comments_before: string[]; } -declare class AST_Node { +class AST_Node { // The first token of this node start: AST_Node; @@ -70,7 +70,7 @@ declare class AST_Node { walk(walker: TreeWalker): void; } -declare class AST_Toplevel extends AST_Node { +class AST_Toplevel extends AST_Node { // Terser contains a scope analyzer which figures out variable/function definitions, references etc. // You need to call it manually before compression or mangling. // The figure_out_scope method is defined only on the AST_Toplevel node. @@ -84,7 +84,6 @@ declare class AST_Toplevel extends AST_Node { print(stream: OutputStream): void; print_to_string(options?: BeautifierOptions): string; - } export interface MinifyOptions { @@ -108,7 +107,7 @@ export interface MinifyOutput { ast?: boolean | AST_Toplevel; } -declare function minify(files: {}, options?: MinifyOptions): MinifyOutput; +function minify(files: {}, options?: MinifyOptions): MinifyOutput; export interface ParseOptions { // Default is false @@ -125,7 +124,7 @@ export interface ParseOptions { * The parser creates a custom abstract syntax tree given a piece of JavaScript code. * Perhaps you should read about the AST first. */ -declare function parse(code: string, options?: ParseOptions): AST_Toplevel; +function parse(code: string, options?: ParseOptions): AST_Toplevel; export interface BeautifierOptions { /** @@ -213,7 +212,7 @@ export interface OutputStream { indentation(): number; // return the width of the current line text minus indentation. - current_width(): number + current_width(): number; // Return true if current_width() is bigger than options.width (assuming options.width is non-null, non-zero). should_break(): boolean; @@ -262,18 +261,18 @@ export interface OutputStream { // Sets the current indentation to col (column), calls the function and thereafter restores the previous indentation level. // If beautification is off it simply calls func. - with_indent(col: number, func: Function): void; + with_indent(col: number, func: () => void): void; // This is used to output blocks in curly brackets. // It'll print an open bracket at current point, then call newline() and with the next indentation level it calls your func. // Lastly, it'll print an indented closing bracket. As usual, if beautification is off you'll just get {x} where x is whatever func outputs. - with_block(func: Function): void; + with_block(func: () => void): void; // Adds parens around the output that your function prints. - with_parens(func: Function): void; + with_parens(func: () => void): void; // Adds square brackets around the output that your function prints. - with_square(func: Function): void; + with_square(func: () => void): void; // If options.source_map is set, this will generate a source mapping between the given token (which should be an AST_Token-like {}) and the current line/col. // The name is optional; in most cases it will be inferred from the token. @@ -307,8 +306,7 @@ export interface OutputStream { * The stream {} supports a lot of options that control the output. * You can specify whether you'd like to get human-readable (indented) output, the indentation level, whether you'd like to quote all properties in {} literals etc. */ -declare function OutputStream(options?: BeautifierOptions): OutputStream; - +function OutputStream(options?: BeautifierOptions): OutputStream; export interface SourceMapOptions { /** @@ -341,8 +339,7 @@ export interface SourceMap { * To use this functionality, you must load this library (it's automatically require-d by Terser in the NodeJS version, but in a browser you must load it yourself) * and make it available via the global MOZ_SourceMap variable. */ -declare function SourceMap(options?: SourceMapOptions): SourceMap; - +function SourceMap(options?: SourceMapOptions): SourceMap; export interface CompressorOptions { // Join consecutive statemets with the “comma operator” @@ -406,8 +403,7 @@ export interface CompressorOptions { /** * The compressor is a tree transformer which reduces the code size by applying various optimizations on the AST */ -declare function Compressor(options?: CompressorOptions): AST_Toplevel; - +function Compressor(options?: CompressorOptions): AST_Toplevel; // TODO: @@ -415,13 +411,13 @@ declare function Compressor(options?: CompressorOptions): AST_Toplevel; * Terser provides a TreeWalker {} and every node has a walk method that given a walker will apply your visitor to each node in the tree. * Your visitor can return a non-falsy value in order to prevent descending the current node. */ -declare class TreeWalker { +class TreeWalker { constructor(visitor: visitor); parent: () => AST_Scope; stack: AST_Scope[]; } -export type visitor = (node: AST_Node, descend: Function) => boolean | void; +export type visitor = (node: AST_Node, descend: () => void) => boolean | void; // TODO: @@ -429,29 +425,29 @@ export type visitor = (node: AST_Node, descend: Function) => boolean | void; * The tree transformer is a special case of a tree walker. * In fact it even inherits from TreeWalker and you can use the same methods, but initialization and visitor protocol are a bit different. */ -declare class TreeTransformer extends TreeWalker { +class TreeTransformer extends TreeWalker { constructor(visitor: visitor, after: visitor); } // TODO: http://lisperator.net/Terser/ast -declare class AST_PropAccess extends AST_Node { +class AST_PropAccess extends AST_Node { } -declare class AST_{}KeyVal extends AST_Node { +class AST_ObjectKeyVal extends AST_Node { } -declare class AST_Scope extends AST_Node { +class AST_Scope extends AST_Node { find_variable(name: string): AST_SymbolDeclaration; } -declare class AST_Symbol extends AST_Node { +class AST_Symbol extends AST_Node { scope?: AST_Scope; name: string; thedef: unknown; } -declare class AST_SymbolDeclaration extends AST_Symbol { +class AST_SymbolDeclaration extends AST_Symbol { orig: AST_SymbolDeclaration[]; references: AST_SymbolRef[]; global: boolean; @@ -461,27 +457,27 @@ declare class AST_SymbolDeclaration extends AST_Symbol { mangled_name?: string; } -declare class AST_SymbolRef extends AST_Symbol { +class AST_SymbolRef extends AST_Symbol { } -declare class AST_Call extends AST_Node { +class AST_Call extends AST_Node { expression: { name?: string, property?: string }; args: AST_Node[]; } -declare class AST_String extends AST_Node { +class AST_String extends AST_Node { value: string; } -declare class AST_Lambda extends AST_Node { +class AST_Lambda extends AST_Node { name?: string; } -declare class AST_SymbolMethod extends AST_Node { +class AST_SymbolMethod extends AST_Node { name?: string; } -declare class AST_ConciseMethod extends AST_Node { +class AST_ConciseMethod extends AST_Node { } -declare class AST_SymbolVar extends AST_Node { +class AST_SymbolVar extends AST_Node { name?: string; } From 5f29885e56d1df8f85f2ea0e0ded0144735b11e8 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 11:21:27 +0200 Subject: [PATCH 16/68] Add some declare --- types/terser/index.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 8e291379f1..9b859a0cf4 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -53,7 +53,7 @@ export interface Tokenizer { comments_before: string[]; } -class AST_Node { +declare class AST_Node { // The first token of this node start: AST_Node; @@ -429,7 +429,7 @@ class TreeTransformer extends TreeWalker { constructor(visitor: visitor, after: visitor); } -// TODO: http://lisperator.net/Terser/ast +// TODO: http://lisperator.net/Terser/ast class AST_PropAccess extends AST_Node { } @@ -458,7 +458,6 @@ class AST_SymbolDeclaration extends AST_Symbol { } class AST_SymbolRef extends AST_Symbol { - } class AST_Call extends AST_Node { @@ -475,7 +474,6 @@ class AST_SymbolMethod extends AST_Node { name?: string; } class AST_ConciseMethod extends AST_Node { - } class AST_SymbolVar extends AST_Node { name?: string; From 3444c92c1d3e7597ae88d72bb6f6775e3b3ca0c6 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 11:38:19 +0200 Subject: [PATCH 17/68] Replace delcares with export --- types/terser/index.d.ts | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 9b859a0cf4..e7f02d4942 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -53,7 +53,7 @@ export interface Tokenizer { comments_before: string[]; } -declare class AST_Node { +export class AST_Node { // The first token of this node start: AST_Node; @@ -70,7 +70,7 @@ declare class AST_Node { walk(walker: TreeWalker): void; } -class AST_Toplevel extends AST_Node { +export class AST_Toplevel extends AST_Node { // Terser contains a scope analyzer which figures out variable/function definitions, references etc. // You need to call it manually before compression or mangling. // The figure_out_scope method is defined only on the AST_Toplevel node. @@ -411,7 +411,7 @@ function Compressor(options?: CompressorOptions): AST_Toplevel; * Terser provides a TreeWalker {} and every node has a walk method that given a walker will apply your visitor to each node in the tree. * Your visitor can return a non-falsy value in order to prevent descending the current node. */ -class TreeWalker { +export class TreeWalker { constructor(visitor: visitor); parent: () => AST_Scope; stack: AST_Scope[]; @@ -425,29 +425,29 @@ export type visitor = (node: AST_Node, descend: () => void) => boolean | void; * The tree transformer is a special case of a tree walker. * In fact it even inherits from TreeWalker and you can use the same methods, but initialization and visitor protocol are a bit different. */ -class TreeTransformer extends TreeWalker { +export class TreeTransformer extends TreeWalker { constructor(visitor: visitor, after: visitor); } // TODO: http://lisperator.net/Terser/ast -class AST_PropAccess extends AST_Node { +export class AST_PropAccess extends AST_Node { } -class AST_ObjectKeyVal extends AST_Node { +export class AST_ObjectKeyVal extends AST_Node { } -class AST_Scope extends AST_Node { +export class AST_Scope extends AST_Node { find_variable(name: string): AST_SymbolDeclaration; } -class AST_Symbol extends AST_Node { +export class AST_Symbol extends AST_Node { scope?: AST_Scope; name: string; thedef: unknown; } -class AST_SymbolDeclaration extends AST_Symbol { +export class AST_SymbolDeclaration extends AST_Symbol { orig: AST_SymbolDeclaration[]; references: AST_SymbolRef[]; global: boolean; @@ -457,27 +457,26 @@ class AST_SymbolDeclaration extends AST_Symbol { mangled_name?: string; } -class AST_SymbolRef extends AST_Symbol { +export class AST_SymbolRef extends AST_Symbol { } -class AST_Call extends AST_Node { +export class AST_Call extends AST_Node { expression: { name?: string, property?: string }; args: AST_Node[]; } -class AST_String extends AST_Node { +export class AST_String extends AST_Node { value: string; } -class AST_Lambda extends AST_Node { +export class AST_Lambda extends AST_Node { name?: string; } -class AST_SymbolMethod extends AST_Node { +export class AST_SymbolMethod extends AST_Node { name?: string; } -class AST_ConciseMethod extends AST_Node { +export class AST_ConciseMethod extends AST_Node { } -class AST_SymbolVar extends AST_Node { +export class AST_SymbolVar extends AST_Node { name?: string; } export * from 'uglify-js'; - From f8665dbf39f8df48828b2f6bdd6905dadb7bfbcb Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 11:43:59 +0200 Subject: [PATCH 18/68] Export functions --- types/terser/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index e7f02d4942..44290580e7 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -107,7 +107,7 @@ export interface MinifyOutput { ast?: boolean | AST_Toplevel; } -function minify(files: {}, options?: MinifyOptions): MinifyOutput; +export function minify(files: {}, options?: MinifyOptions): MinifyOutput; export interface ParseOptions { // Default is false @@ -124,7 +124,7 @@ export interface ParseOptions { * The parser creates a custom abstract syntax tree given a piece of JavaScript code. * Perhaps you should read about the AST first. */ -function parse(code: string, options?: ParseOptions): AST_Toplevel; +export function parse(code: string, options?: ParseOptions): AST_Toplevel; export interface BeautifierOptions { /** @@ -306,7 +306,7 @@ export interface OutputStream { * The stream {} supports a lot of options that control the output. * You can specify whether you'd like to get human-readable (indented) output, the indentation level, whether you'd like to quote all properties in {} literals etc. */ -function OutputStream(options?: BeautifierOptions): OutputStream; +export function OutputStream(options?: BeautifierOptions): OutputStream; export interface SourceMapOptions { /** @@ -339,7 +339,7 @@ export interface SourceMap { * To use this functionality, you must load this library (it's automatically require-d by Terser in the NodeJS version, but in a browser you must load it yourself) * and make it available via the global MOZ_SourceMap variable. */ -function SourceMap(options?: SourceMapOptions): SourceMap; +export function SourceMap(options?: SourceMapOptions): SourceMap; export interface CompressorOptions { // Join consecutive statemets with the “comma operator” @@ -403,7 +403,7 @@ export interface CompressorOptions { /** * The compressor is a tree transformer which reduces the code size by applying various optimizations on the AST */ -function Compressor(options?: CompressorOptions): AST_Toplevel; +export function Compressor(options?: CompressorOptions): AST_Toplevel; // TODO: From 84cff26fd07473c6286c8266777625e084a39ed8 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 11:45:45 +0200 Subject: [PATCH 19/68] Fix typescript version --- types/terser/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 44290580e7..1ec8a298e9 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/terser-js/terser // Definitions by: JordiAnderl // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 3.0 import * as MOZ_SourceMap from "source-map"; From a405a07298cdcd6a7d5f4608b9bca66d548e519b Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 11:59:21 +0200 Subject: [PATCH 20/68] Update types and stop using uglify.js --- types/terser/index.d.ts | 177 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 172 insertions(+), 5 deletions(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 1ec8a298e9..887be7b2b5 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -93,9 +93,9 @@ export interface MinifyOptions { inSourceMap?: string; fromString?: boolean; warnings?: boolean; - mangle?: {}; - output?: MinifyOutput; - compress?: {}; + mangle?: boolean | MangleOptions; + output?: OutputOptions; + compress?: boolean | CompressOptions; nameCache?: {}; } @@ -119,6 +119,175 @@ export interface ParseOptions { // Default is null toplevel?: AST_Toplevel; } +export interface CompressOptions { + /** Replace `arguments[index]` with function parameter name whenever possible. */ + arguments?: boolean; + /** Various optimizations for boolean context, for example `!!a ? b : c → a ? b : c` */ + booleans?: boolean; + /** Collapse single-use non-constant variables, side effects permitting. */ + collapse_vars?: boolean; + /** Apply certain optimizations to binary nodes, e.g. `!(a <= b) → a > b,` attempts to negate binary nodes, e.g. `a = !b && !c && !d && !e → a=!(b||c||d||e)` etc */ + comparisons?: boolean; + /** Apply optimizations for `if-s` and conditional expressions. */ + conditionals?: boolean; + /** Remove unreachable code */ + dead_code?: boolean; + /** + * Pass `true` to discard calls to console.* functions. + * If you wish to drop a specific function call such as `console.info` and/or retain side effects from function + * arguments after dropping the function call then use `pure_funcs` instead. + */ + drop_console?: boolean; + /** Remove `debugger;` statements */ + drop_debugger?: boolean; + /** Attempt to evaluate constant expressions */ + evaluate?: boolean; + /** Pass `true` to preserve completion values from terminal statements without `return`, e.g. in bookmarklets. */ + expression?: boolean; + global_defs?: object; + /** hoist function declarations */ + hoist_funs?: boolean; + /** + * Hoist properties from constant object and array literals into regular variables subject to a set of constraints. + * For example: `var o={p:1, q:2}; f(o.p, o.q);` is converted to `f(1, 2);`. Note: `hoist_props` works best with mangle enabled, + * the compress option passes set to 2 or higher, and the compress option toplevel enabled. + */ + hoist_props?: boolean; + /** Hoist var declarations (this is `false` by default because it seems to increase the size of the output in general) */ + hoist_vars?: boolean; + /** Optimizations for if/return and if/continue */ + if_return?: boolean; + /** + * Inline calls to function with simple/return statement + * - false -- same as `Disabled` + * - `Disabled` -- disabled inlining + * - `SimpleFunctions` -- inline simple functions + * - `WithArguments` -- inline functions with arguments + * - `WithArgumentsAndVariables` -- inline functions with arguments and variables + * - true -- same as `WithArgumentsAndVariables` + */ + inline?: boolean | InlineFunctions; + /** join consecutive `var` statements */ + join_vars?: boolean; + /** Prevents the compressor from discarding unused function arguments. You need this for code which relies on `Function.length` */ + keep_fargs?: boolean; + /** Pass true to prevent the compressor from discarding function names. Useful for code relying on `Function.prototype.name`. */ + keep_fnames?: boolean; + /** Pass true to prevent Infinity from being compressed into `1/0`, which may cause performance issues on `Chrome` */ + keep_infinity?: boolean; + /** Optimizations for `do`, `while` and `for` loops when we can statically determine the condition. */ + loops?: boolean; + /** negate `Immediately-Called Function Expressions` where the return value is discarded, to avoid the parens that the code generator would insert. */ + negate_iife?: boolean; + /** The maximum number of times to run compress. In some cases more than one pass leads to further compressed code. Keep in mind more passes will take more time. */ + passes?: number; + /** Rewrite property access using the dot notation, for example `foo["bar"]` to `foo.bar` */ + properties?: boolean; + /** + * An array of names and UglifyJS will assume that those functions do not produce side effects. + * DANGER: will not check if the name is redefined in scope. + * An example case here, for instance `var q = Math.floor(a/b)`. + * If variable q is not used elsewhere, UglifyJS will drop it, but will still keep the `Math.floor(a/b)`, + * not knowing what it does. You can pass `pure_funcs: [ 'Math.floor' ]` to let it know that this function + * won't produce any side effect, in which case the whole statement would get discarded. The current + * implementation adds some overhead (compression will be slower). + */ + pure_funcs?: string[]; + pure_getters?: boolean | 'strict'; + /** + * Allows single-use functions to be inlined as function expressions when permissible allowing further optimization. + * Enabled by default. Option depends on reduce_vars being enabled. Some code runs faster in the Chrome V8 engine if + * this option is disabled. Does not negatively impact other major browsers. + */ + reduce_funcs?: boolean; + /** Improve optimization on variables assigned with and used as constant values. */ + reduce_vars?: boolean; + sequences?: boolean; + /** Pass false to disable potentially dropping functions marked as "pure". */ + side_effects?: boolean; + /** De-duplicate and remove unreachable `switch` branches. */ + switches?: boolean; + /** Drop unreferenced functions ("funcs") and/or variables ("vars") in the top level scope (false by default, true to drop both unreferenced functions and variables) */ + toplevel?: boolean; + /** Prevent specific toplevel functions and variables from unused removal (can be array, comma-separated, RegExp or function. Implies toplevel) */ + top_retain?: boolean; + typeofs?: boolean; + unsafe?: boolean; + /** Compress expressions like a `<= b` assuming none of the operands can be (coerced to) `NaN`. */ + unsafe_comps?: boolean; + /** Compress and mangle `Function(args, code)` when both args and code are string literals. */ + unsafe_Function?: boolean; + /** Optimize numerical expressions like `2 * x * 3` into `6 * x`, which may give imprecise floating point results. */ + unsafe_math?: boolean; + /** Optimize expressions like `Array.prototype.slice.call(a)` into `[].slice.call(a)` */ + unsafe_proto?: boolean; + /** Enable substitutions of variables with `RegExp` values the same way as if they are constants. */ + unsafe_regexp?: boolean; + unsafe_undefined?: boolean; + unused?: boolean; + /** display warnings when dropping unreachable code or unused declarations etc. */ + warnings?: boolean; +} + +export enum InlineFunctions { + Disabled = 0, + SimpleFunctions = 1, + WithArguments = 2, + WithArgumentsAndVariables = 3 +} + +export interface MangleOptions { + /** Pass true to mangle names visible in scopes where `eval` or with are used. */ + eval?: boolean; + /** Pass true to not mangle function names. Useful for code relying on `Function.prototype.name`. */ + keep_fnames?: boolean; + /** Pass an array of identifiers that should be excluded from mangling. Example: `["foo", "bar"]`. */ + reserved?: string[]; + /** Pass true to mangle names declared in the top level scope. */ + toplevel?: boolean; + properties?: boolean | ManglePropertiesOptions; +} + +export interface ManglePropertiesOptions { + /** Use true to allow the mangling of builtin DOM properties. Not recommended to override this setting. */ + builtins?: boolean; + /** Mangle names with the original name still present. Pass an empty string "" to enable, or a non-empty string to set the debug suffix. */ + debug?: boolean; + /** Only mangle unquoted property names */ + keep_quoted?: boolean; + /** Pass a RegExp literal to only mangle property names matching the regular expression. */ + regex?: RegExp; + /** Do not mangle property names listed in the reserved array */ + reserved?: string[]; +} + +export interface OutputOptions { + ascii_only?: boolean; + beautify?: boolean; + braces?: boolean; + comments?: boolean | 'all' | 'some' | RegExp; + indent_level?: number; + indent_start?: boolean; + inline_script?: boolean; + keep_quoted_props?: boolean; + max_line_len?: boolean | number; + preamble?: string; + preserve_line?: boolean; + quote_keys?: boolean; + quote_style?: OutputQuoteStyle; + semicolons?: boolean; + shebang?: boolean; + webkit?: boolean; + width?: number; + wrap_iife?: boolean; +} + +export enum OutputQuoteStyle { + PreferDouble = 0, + AlwaysSingle = 1, + AlwaysDouble = 2, + AlwaysOriginal = 3 +} /** * The parser creates a custom abstract syntax tree given a piece of JavaScript code. @@ -478,5 +647,3 @@ export class AST_ConciseMethod extends AST_Node { export class AST_SymbolVar extends AST_Node { name?: string; } - -export * from 'uglify-js'; From 0e511cf719a1733ed6752256c1594b7781a59fb6 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 12:14:01 +0200 Subject: [PATCH 21/68] Chage version --- types/terser/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 887be7b2b5..c9a07c6d89 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/terser-js/terser // Definitions by: JordiAnderl // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.0 +// TypeScript Version: 3.0.0 import * as MOZ_SourceMap from "source-map"; From dabd0b47f8fa1304537db23fb7c285279a207b3f Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 12:32:26 +0200 Subject: [PATCH 22/68] Change typescript version Could not parse version: line is '// TypeScript Version: 3.0.0' --- types/terser/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index c9a07c6d89..3e61a95655 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/terser-js/terser // Definitions by: JordiAnderl // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.0.0 +// TypeScript Version: 3 import * as MOZ_SourceMap from "source-map"; From 4c5892c46ac97b49502b41ffacac49e5121afa43 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 12:36:18 +0200 Subject: [PATCH 23/68] Fix typescript version As seen in https://github.com/Microsoft/definitelytyped-header-parser/blob/master/index.ts --- types/terser/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 3e61a95655..887be7b2b5 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/terser-js/terser // Definitions by: JordiAnderl // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3 +// TypeScript Version: 3.0 import * as MOZ_SourceMap from "source-map"; From 2b206bceb503d2a5e2c59561bd0cae96de62eb33 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Wed, 24 Oct 2018 12:55:55 +0200 Subject: [PATCH 24/68] Fix url --- types/terser/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 887be7b2b5..f9367436c8 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -598,7 +598,7 @@ export class TreeTransformer extends TreeWalker { constructor(visitor: visitor, after: visitor); } -// TODO: http://lisperator.net/Terser/ast +// TODO: http://lisperator.net/uglifyjs/ast export class AST_PropAccess extends AST_Node { } From 001a9ae75806b88ef76e43fcb415a341d0e4101e Mon Sep 17 00:00:00 2001 From: Philipp A Date: Wed, 24 Oct 2018 16:36:41 +0200 Subject: [PATCH 25/68] Reworked markdown-it --- types/markdown-it-anchor/index.d.ts | 4 +- types/markdown-it-container/index.d.ts | 4 +- .../markdown-it-container-tests.ts | 4 +- types/markdown-it-lazy-headers/index.d.ts | 2 +- types/markdown-it/index.d.ts | 232 +----------------- types/markdown-it/lib/index.d.ts | 113 +++++++++ types/markdown-it/lib/parser_block.d.ts | 11 + types/markdown-it/lib/parser_core.d.ts | 12 + types/markdown-it/lib/parser_inline.d.ts | 15 ++ types/markdown-it/lib/renderer.d.ts | 14 ++ types/markdown-it/lib/ruler.d.ts | 17 ++ .../lib/rules_block/state_block.d.ts | 25 ++ .../lib/rules_core/state_core.d.ts | 22 ++ .../lib/rules_inline/state_inline.d.ts | 48 ++++ types/markdown-it/lib/token.d.ts | 25 ++ types/markdown-it/markdown-it-tests.ts | 8 +- types/prosemirror-markdown/index.d.ts | 2 +- 17 files changed, 319 insertions(+), 239 deletions(-) create mode 100644 types/markdown-it/lib/index.d.ts create mode 100644 types/markdown-it/lib/parser_block.d.ts create mode 100644 types/markdown-it/lib/parser_core.d.ts create mode 100644 types/markdown-it/lib/parser_inline.d.ts create mode 100644 types/markdown-it/lib/renderer.d.ts create mode 100644 types/markdown-it/lib/ruler.d.ts create mode 100644 types/markdown-it/lib/rules_block/state_block.d.ts create mode 100644 types/markdown-it/lib/rules_core/state_core.d.ts create mode 100644 types/markdown-it/lib/rules_inline/state_inline.d.ts create mode 100644 types/markdown-it/lib/token.d.ts diff --git a/types/markdown-it-anchor/index.d.ts b/types/markdown-it-anchor/index.d.ts index fc4cead6d4..e0ef0dd9f9 100644 --- a/types/markdown-it-anchor/index.d.ts +++ b/types/markdown-it-anchor/index.d.ts @@ -4,7 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import { MarkdownIt, Core, Token } from 'markdown-it'; +import * as MarkdownIt from 'markdown-it'; +import * as Core from 'markdown-it/lib/parser_core'; +import * as Token from 'markdown-it/lib/token'; declare namespace anchor { interface AnchorInfo { diff --git a/types/markdown-it-container/index.d.ts b/types/markdown-it-container/index.d.ts index b0913972fa..99c33958c5 100644 --- a/types/markdown-it-container/index.d.ts +++ b/types/markdown-it-container/index.d.ts @@ -4,7 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import { MarkdownIt, Token, Renderer } from 'markdown-it'; +import * as MarkdownIt from 'markdown-it'; +import * as Renderer from 'markdown-it/lib/renderer'; +import * as Token from 'markdown-it/lib/token'; declare namespace markdownItContainer { interface ContainerOpts { diff --git a/types/markdown-it-container/markdown-it-container-tests.ts b/types/markdown-it-container/markdown-it-container-tests.ts index 3c8f3bf980..fcd46b80d9 100644 --- a/types/markdown-it-container/markdown-it-container-tests.ts +++ b/types/markdown-it-container/markdown-it-container-tests.ts @@ -1,11 +1,13 @@ import * as MarkdownIt from "markdown-it"; +import * as Token from "markdown-it/lib/token"; + import MarkdownItContainer = require("markdown-it-container"); const md = new MarkdownIt(); md.use(MarkdownItContainer, 'spoiler', { validate: (params: any) => params.trim().match(/^spoiler\s+(.*)$/), - render: (tokens: MarkdownIt.Token[], index: number) => { + render: (tokens: Token[], index: number) => { const match = tokens[index].info.trim().match(/^spoiler\s+(.*)$/); const onClick = "this.parentNode.classList.toggle('_expanded');" + diff --git a/types/markdown-it-lazy-headers/index.d.ts b/types/markdown-it-lazy-headers/index.d.ts index 0579118f80..f16c30e651 100644 --- a/types/markdown-it-lazy-headers/index.d.ts +++ b/types/markdown-it-lazy-headers/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import { MarkdownIt } from 'markdown-it'; +import * as MarkdownIt from 'markdown-it'; declare function lazyheaders(md: MarkdownIt): void; diff --git a/types/markdown-it/index.d.ts b/types/markdown-it/index.d.ts index 0948a6d353..296d55f41c 100644 --- a/types/markdown-it/index.d.ts +++ b/types/markdown-it/index.d.ts @@ -4,235 +4,5 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -interface MarkdownItStatic { - new (): MarkdownIt.MarkdownIt; - new (presetName: "commonmark" | "zero" | "default", options?: MarkdownIt.Options): MarkdownIt.MarkdownIt; - new (options: MarkdownIt.Options): MarkdownIt.MarkdownIt; - (): MarkdownIt.MarkdownIt; - (presetName: "commonmark" | "zero" | "default", options ?: MarkdownIt.Options): MarkdownIt.MarkdownIt; - (options: MarkdownIt.Options): MarkdownIt.MarkdownIt; -} - -declare var MarkdownIt: MarkdownItStatic; +import * as MarkdownIt from "./lib"; export = MarkdownIt; -export as namespace markdownit; - -declare module MarkdownIt { - interface MarkdownIt { - render(md: string, env?: any): string; - renderInline(md: string, env?: any): string; - parse(src: string, env: any): Token[]; - parseInline(src: string, env: any): Token[]; - - /* - // The following only works in 3.0 - // Since it's still not allowed to target 3.0, i'll leave the code commented out - - use = any[]>( - plugin: (md: MarkdownIt, ...params: T) => void, - ...params: T - ): MarkdownIt; - */ - - use(plugin: (md: MarkdownIt, ...params: any[]) => void, ...params: any[]): MarkdownIt; - - utils: { - assign(obj: any): any; - isString(obj: any): boolean; - has(object: any, key: string): boolean; - unescapeMd(str: string): string; - unescapeAll(str: string): string; - isValidEntityCode(str: any): boolean; - fromCodePoint(str: string): string; - escapeHtml(str: string): string; - arrayReplaceAt(src: any[], pos: number, newElements: any[]): any[] - isSpace(str: any): boolean; - isWhiteSpace(str: any): boolean - isMdAsciiPunct(str: any): boolean; - isPunctChar(str: any): boolean; - escapeRE(str: string): string; - normalizeReference(str: string): string; - } - - disable(rules: string[] | string, ignoreInvalid?: boolean): MarkdownIt; - enable(rules: string[] | string, ignoreInvalid?: boolean): MarkdownIt; - set(options: Options): MarkdownIt; - normalizeLink(url: string): string; - normalizeLinkText(url: string): string; - validateLink(url: string): boolean; - block: ParserBlock; - core: Core; - helpers: any; - inline: ParserInline; - linkify: LinkifyIt; - renderer: Renderer; - } - interface Options { - html?: boolean; - xhtmlOut?: boolean; - breaks?: boolean; - langPrefix?: string; - linkify?: boolean; - typographer?: boolean; - quotes?: string; - highlight?: (str: string, lang: string) => void; - } - interface LinkifyIt { - tlds(lang: string, linkified: boolean): void; - } - interface Renderer { - rules: { [name: string]: TokenRender }; - render(tokens: Token[], options: any, env: any): string; - renderAttrs(token: Token): string; - renderInline(tokens: Token[], options: any, env: any): string; - renderToken(tokens: Token[], idx: number, options: any): string; - } - interface Token { - new (type: string, tag: string, nesting: number): Token; - attrGet: (name: string) => string | null; - attrIndex: (name: string) => number; - attrJoin: (name: string, value: string) => void; - attrPush: (attrData: string[]) => void; - attrSet: (name: string, value: string) => void; - attrs: string[][]; - block: boolean; - children: Token[]; - content: string; - hidden: boolean; - info: string; - level: number; - map: number[]; - markup: string; - meta: any; - nesting: number; - tag: string; - type: string; - } - - type TokenRender = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => void; - - interface Rule { - (state: S, silent?: boolean): boolean | void; - } - - interface RuleInline extends Rule {} - interface RuleBlock extends Rule {} - - interface Ruler { - after(afterName: string, ruleName: string, rule: Rule, options?: any): void; - at(name: string, rule: Rule, options?: any): void; - before(beforeName: string, ruleName: string, rule: Rule, options?: any): void; - disable(rules: string | string[], ignoreInvalid?: boolean): string[]; - enable(rules: string | string[], ignoreInvalid?: boolean): string[]; - enableOnly(rule: string, ignoreInvalid?: boolean): void; - getRules(chain: string): Rule[]; - push(ruleName: string, rule: Rule, options?: any): void; - } - - interface RulerInline extends Ruler {} - interface RulerBlock extends Ruler {} - - interface ParserBlock { - parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void; - ruler: RulerBlock; - } - - interface Core { - process(state: any): void; - ruler: Ruler; - } - - interface ParserInline { - parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void; - tokenize(state: State): void; - skipToken(state: State): void; - ruler: RulerInline; - ruler2: RulerInline; - } - - interface Delimiter { - close: boolean; - end: number; - jump: number; - length: number; - level: number; - marker: number; - open: boolean; - token: number; - } - - interface State { - env: any; - level: number; - - /** Link to parser instance */ - md: MarkdownIt; - - /** The markdown source code that is being parsed. */ - src: string; - - tokens: Token[]; - - /** Return any for a yet untyped property */ - [undocumented: string]: any; - } - - interface StateInline extends State { - /** - * Stores `{ start: end }` pairs. Useful for backtrack - * optimization of pairs parse (emphasis, strikes). - */ - cache: { [start: number]: number }; - - /** Emphasis-like delimiters */ - delimiters: Delimiter[]; - - pending: string; - pendingLevel: number; - - /** Index of the first character of this token. */ - pos: number; - - /** Index of the last character that can be used (for example the one before the end of this line). */ - posMax: number; - - /** - * Push new token to "stream". - * If pending text exists, flush it as text token. - */ - push(type: string, tag: string, nesting: number): Token; - - /** Flush pending text */ - pushPending(): Token; - - /** - * Scan a sequence of emphasis-like markers and determine whether - * it can start an emphasis sequence or end an emphasis sequence. - * @param start - position to scan from (it should point to a valid marker) - * @param canSplitWord - determine if these markers can be found inside a word - */ - scanDelims(start: number, canSplitWord: boolean): { - can_open: boolean, - can_close: boolean, - length: number - }; - } - - interface StateBlock extends State { - /** Used in lists to determine if they interrupt a paragraph */ - parentType: 'blockquote' | 'list' | 'root' | 'paragraph' | 'reference'; - - eMarks: number[]; - bMarks: number[]; - bsCount: number[]; - sCount: number[]; - tShift: number[]; - - blkIndent: number; - ddIndent: number; - - line: number; - lineMax: number; - tight: boolean; - } -} diff --git a/types/markdown-it/lib/index.d.ts b/types/markdown-it/lib/index.d.ts new file mode 100644 index 0000000000..5360d80b1a --- /dev/null +++ b/types/markdown-it/lib/index.d.ts @@ -0,0 +1,113 @@ +import { LinkifyIt } from 'linkify-it' + +import * as State from './rules_core/state_core'; +import * as StateBlock from './rules_block/state_block'; +import * as StateInline from './rules_inline/state_inline'; + +import * as Core from './parser_core'; +import * as ParserBlock from './parser_block'; +import * as ParserInline from './parser_inline'; + +import * as Renderer from './renderer'; +import * as Ruler from './ruler'; +import * as Token from './token'; + +export = MarkdownIt; +export as namespace markdownit; + +declare const MarkdownIt: MarkdownItConstructor; + +interface MarkdownItConstructor { + new (): MarkdownIt; + new (presetName: "commonmark" | "zero" | "default", options?: MarkdownIt.Options): MarkdownIt; + new (options: MarkdownIt.Options): MarkdownIt; + (): MarkdownIt; + (presetName: "commonmark" | "zero" | "default", options ?: MarkdownIt.Options): MarkdownIt; + (options: MarkdownIt.Options): MarkdownIt; +} + +interface MarkdownIt { + render(md: string, env?: any): string; + renderInline(md: string, env?: any): string; + parse(src: string, env: any): Token[]; + parseInline(src: string, env: any): Token[]; + + /* + // The following only works in 3.0 + // Since it's still not allowed to target 3.0, i'll leave the code commented out + + use = any[]>( + plugin: (md: MarkdownIt, ...params: T) => void, + ...params: T + ): MarkdownIt; + */ + + use(plugin: (md: MarkdownIt, ...params: any[]) => void, ...params: any[]): MarkdownIt; + + utils: { + assign(obj: any): any; + isString(obj: any): boolean; + has(object: any, key: string): boolean; + unescapeMd(str: string): string; + unescapeAll(str: string): string; + isValidEntityCode(str: any): boolean; + fromCodePoint(str: string): string; + escapeHtml(str: string): string; + arrayReplaceAt(src: any[], pos: number, newElements: any[]): any[] + isSpace(str: any): boolean; + isWhiteSpace(str: any): boolean + isMdAsciiPunct(str: any): boolean; + isPunctChar(str: any): boolean; + escapeRE(str: string): string; + normalizeReference(str: string): string; + } + + disable(rules: string[] | string, ignoreInvalid?: boolean): MarkdownIt; + enable(rules: string[] | string, ignoreInvalid?: boolean): MarkdownIt; + set(options: MarkdownIt.Options): MarkdownIt; + normalizeLink(url: string): string; + normalizeLinkText(url: string): string; + validateLink(url: string): boolean; + block: ParserBlock; + core: Core; + helpers: any; + inline: ParserInline; + linkify: LinkifyIt; + renderer: Renderer; +} + +declare module MarkdownIt { + interface Options { + html?: boolean; + xhtmlOut?: boolean; + breaks?: boolean; + langPrefix?: string; + linkify?: boolean; + typographer?: boolean; + quotes?: string; + highlight?: (str: string, lang: string) => void; + } + + interface Rule { + (state: S, silent?: boolean): boolean | void; + } + + interface RuleInline extends Rule {} + interface RuleBlock extends Rule {} + + interface RulerInline extends Ruler {} + interface RulerBlock extends Ruler {} + + type TokenRender = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => void; + + interface Delimiter { + close: boolean; + end: number; + jump: number; + length: number; + level: number; + marker: number; + open: boolean; + token: number; + } +} diff --git a/types/markdown-it/lib/parser_block.d.ts b/types/markdown-it/lib/parser_block.d.ts new file mode 100644 index 0000000000..288a791089 --- /dev/null +++ b/types/markdown-it/lib/parser_block.d.ts @@ -0,0 +1,11 @@ +import * as MarkdownIt from "."; +import * as Token from "./token"; + +export = ParserBlock; + +declare class ParserBlock { + parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void; + ruler: MarkdownIt.RulerBlock; +} + +declare module ParserBlock {} diff --git a/types/markdown-it/lib/parser_core.d.ts b/types/markdown-it/lib/parser_core.d.ts new file mode 100644 index 0000000000..42d2759ab0 --- /dev/null +++ b/types/markdown-it/lib/parser_core.d.ts @@ -0,0 +1,12 @@ +import * as MarkdownIt from "."; +import * as Ruler from "./ruler"; +import * as Token from "./token"; + +export = ParserCore; + +declare class ParserCore { + process(state: any): void; + ruler: Ruler; +} + +declare module ParserCore {} diff --git a/types/markdown-it/lib/parser_inline.d.ts b/types/markdown-it/lib/parser_inline.d.ts new file mode 100644 index 0000000000..1be89e09f1 --- /dev/null +++ b/types/markdown-it/lib/parser_inline.d.ts @@ -0,0 +1,15 @@ +import * as MarkdownIt from "."; +import * as State from "./rules_core/state_core"; +import * as Token from "./token"; + +export = ParserInline; + +declare class ParserInline { + parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void; + tokenize(state: State): void; + skipToken(state: State): void; + ruler: MarkdownIt.RulerInline; + ruler2: MarkdownIt.RulerInline; +} + +declare module ParserInline {} diff --git a/types/markdown-it/lib/renderer.d.ts b/types/markdown-it/lib/renderer.d.ts new file mode 100644 index 0000000000..51125309e6 --- /dev/null +++ b/types/markdown-it/lib/renderer.d.ts @@ -0,0 +1,14 @@ +import * as MarkdownIt from "."; +import * as Token from "./token"; + +export = Renderer; + +declare class Renderer { + rules: { [name: string]: MarkdownIt.TokenRender }; + render(tokens: Token[], options: any, env: any): string; + renderAttrs(token: Token): string; + renderInline(tokens: Token[], options: any, env: any): string; + renderToken(tokens: Token[], idx: number, options: any): string; +} + +declare module Renderer {} diff --git a/types/markdown-it/lib/ruler.d.ts b/types/markdown-it/lib/ruler.d.ts new file mode 100644 index 0000000000..106a3d1d72 --- /dev/null +++ b/types/markdown-it/lib/ruler.d.ts @@ -0,0 +1,17 @@ +import * as MarkdownIt from "."; +import * as State from "./rules_core/state_core"; + +export = Ruler; + +declare class Ruler { + after(afterName: string, ruleName: string, rule: MarkdownIt.Rule, options?: any): void; + at(name: string, rule: MarkdownIt.Rule, options?: any): void; + before(beforeName: string, ruleName: string, rule: MarkdownIt.Rule, options?: any): void; + disable(rules: string | string[], ignoreInvalid?: boolean): string[]; + enable(rules: string | string[], ignoreInvalid?: boolean): string[]; + enableOnly(rule: string, ignoreInvalid?: boolean): void; + getRules(chain: string): MarkdownIt.Rule[]; + push(ruleName: string, rule: MarkdownIt.Rule, options?: any): void; +} + +declare module Ruler {} diff --git a/types/markdown-it/lib/rules_block/state_block.d.ts b/types/markdown-it/lib/rules_block/state_block.d.ts new file mode 100644 index 0000000000..e1dc5a2fbd --- /dev/null +++ b/types/markdown-it/lib/rules_block/state_block.d.ts @@ -0,0 +1,25 @@ +import * as MarkdownIt from ".."; +import * as State from "../rules_core/state_core"; +import * as Token from "../token"; + +export = StateBlock; + +declare class StateBlock extends State { + /** Used in lists to determine if they interrupt a paragraph */ + parentType: 'blockquote' | 'list' | 'root' | 'paragraph' | 'reference'; + + eMarks: number[]; + bMarks: number[]; + bsCount: number[]; + sCount: number[]; + tShift: number[]; + + blkIndent: number; + ddIndent: number; + + line: number; + lineMax: number; + tight: boolean; +} + +declare module StateBlock {} diff --git a/types/markdown-it/lib/rules_core/state_core.d.ts b/types/markdown-it/lib/rules_core/state_core.d.ts new file mode 100644 index 0000000000..dc0eb54921 --- /dev/null +++ b/types/markdown-it/lib/rules_core/state_core.d.ts @@ -0,0 +1,22 @@ +import * as MarkdownIt from ".."; +import * as Token from "../token"; + +export = StateCore; + +declare class StateCore { + env: any; + level: number; + + /** Link to parser instance */ + md: MarkdownIt; + + /** The markdown source code that is being parsed. */ + src: string; + + tokens: Token[]; + + /** Return any for a yet untyped property */ + [undocumented: string]: any; +} + +declare module StateCore {} diff --git a/types/markdown-it/lib/rules_inline/state_inline.d.ts b/types/markdown-it/lib/rules_inline/state_inline.d.ts new file mode 100644 index 0000000000..eaa1feaa00 --- /dev/null +++ b/types/markdown-it/lib/rules_inline/state_inline.d.ts @@ -0,0 +1,48 @@ +import * as MarkdownIt from ".."; +import * as State from "../rules_core/state_core"; +import * as Token from "../token"; + +export = StateInline; + +declare class StateInline extends State { + /** + * Stores `{ start: end }` pairs. Useful for backtrack + * optimization of pairs parse (emphasis, strikes). + */ + cache: { [start: number]: number }; + + /** Emphasis-like delimiters */ + delimiters: MarkdownIt.Delimiter[]; + + pending: string; + pendingLevel: number; + + /** Index of the first character of this token. */ + pos: number; + + /** Index of the last character that can be used (for example the one before the end of this line). */ + posMax: number; + + /** + * Push new token to "stream". + * If pending text exists, flush it as text token. + */ + push(type: string, tag: string, nesting: number): Token; + + /** Flush pending text */ + pushPending(): Token; + + /** + * Scan a sequence of emphasis-like markers and determine whether + * it can start an emphasis sequence or end an emphasis sequence. + * @param start - position to scan from (it should point to a valid marker) + * @param canSplitWord - determine if these markers can be found inside a word + */ + scanDelims(start: number, canSplitWord: boolean): { + can_open: boolean, + can_close: boolean, + length: number + }; +} + +declare module StateInline {} diff --git a/types/markdown-it/lib/token.d.ts b/types/markdown-it/lib/token.d.ts new file mode 100644 index 0000000000..142b59289b --- /dev/null +++ b/types/markdown-it/lib/token.d.ts @@ -0,0 +1,25 @@ +export = Token; + +declare class Token { + constructor(type: string, tag: string, nesting: number); + attrGet: (name: string) => string | null; + attrIndex: (name: string) => number; + attrJoin: (name: string, value: string) => void; + attrPush: (attrData: string[]) => void; + attrSet: (name: string, value: string) => void; + attrs: string[][]; + block: boolean; + children: Token[]; + content: string; + hidden: boolean; + info: string; + level: number; + map: number[]; + markup: string; + meta: any; + nesting: number; + tag: string; + type: string; +} + +declare module Token {} diff --git a/types/markdown-it/markdown-it-tests.ts b/types/markdown-it/markdown-it-tests.ts index f22fc5cb2d..3cb1a9ea3b 100644 --- a/types/markdown-it/markdown-it-tests.ts +++ b/types/markdown-it/markdown-it-tests.ts @@ -1,4 +1,6 @@ import * as MarkdownIt from "markdown-it"; +import * as Renderer from "markdown-it/lib/renderer"; +import * as Token from "markdown-it/lib/token"; { const md = new MarkdownIt(); @@ -141,7 +143,7 @@ function myToken(tokens: any, idx: number, options: any, env: any, self: any) { return ""; }, }); - md.renderer.rules["image"] = (tokens: MarkdownIt.Token[], index: number, options: any, env: any, self: MarkdownIt.Renderer) => { + md.renderer.rules["image"] = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => { const token = tokens[index]; const aIndex = token.attrIndex("src"); token.attrs[aIndex][1]; @@ -154,11 +156,11 @@ function myToken(tokens: any, idx: number, options: any, env: any, self: any) { if (md.renderer.rules["link_open"]) { defaultLinkRender = md.renderer.rules["link_open"]; } else { - defaultLinkRender = (tokens: MarkdownIt.Token[], index: number, options: any, env: any, self: MarkdownIt.Renderer) => { + defaultLinkRender = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => { return self.renderToken(tokens, index, options); }; } - md.renderer.rules["link_open"] = (tokens: MarkdownIt.Token[], index: number, options: any, env: any, self: MarkdownIt.Renderer) => { + md.renderer.rules["link_open"] = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => { tokens[index].attrPush(["target", "_blank"]); tokens[index].attrPush(["rel", "nofollow"]); return defaultLinkRender(tokens, index, options, env, self); diff --git a/types/prosemirror-markdown/index.d.ts b/types/prosemirror-markdown/index.d.ts index 7af366c04e..7d18611513 100644 --- a/types/prosemirror-markdown/index.d.ts +++ b/types/prosemirror-markdown/index.d.ts @@ -7,7 +7,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import { MarkdownIt } from 'markdown-it'; +import * as MarkdownIt from 'markdown-it'; import { Node as ProsemirrorNode, Schema } from 'prosemirror-model'; /** From 3024a9dd0e27b00ec820f2e4f10f6582dbcc4d8b Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Tue, 30 Oct 2018 12:35:20 +0100 Subject: [PATCH 26/68] Wait until support for typescript 3 arrives. https://github.com/Microsoft/dtslint/issues/137 https://github.com/Microsoft/definitelytyped-header-parser/pull/15 --- types/terser/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index f9367436c8..ea57a27c53 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -3,6 +3,7 @@ // Definitions by: JordiAnderl // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 +// No support for typescript version 3. See https://github.com/Microsoft/dtslint/issues/137 import * as MOZ_SourceMap from "source-map"; From bf99256c235788233a79ad5ce07d956c9699a290 Mon Sep 17 00:00:00 2001 From: Frithjof Winkelmann Date: Thu, 1 Nov 2018 01:23:29 +0100 Subject: [PATCH 27/68] Add types for rc-time-picker --- types/rc-time-picker/index.d.ts | 54 +++++++++++++++++++ types/rc-time-picker/rc-time-picker-tests.tsx | 10 ++++ types/rc-time-picker/tsconfig.json | 24 +++++++++ types/rc-time-picker/tslint.json | 1 + 4 files changed, 89 insertions(+) create mode 100644 types/rc-time-picker/index.d.ts create mode 100644 types/rc-time-picker/rc-time-picker-tests.tsx create mode 100644 types/rc-time-picker/tsconfig.json create mode 100644 types/rc-time-picker/tslint.json diff --git a/types/rc-time-picker/index.d.ts b/types/rc-time-picker/index.d.ts new file mode 100644 index 0000000000..354189cc3b --- /dev/null +++ b/types/rc-time-picker/index.d.ts @@ -0,0 +1,54 @@ +// Type definitions for rc-time-picker 3.4 +// Project: http://github.com/react-component/time-picker +// Definitions by: Frithjof Winkelmann +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as moment from "moment"; +import * as React from 'react'; + +export {}; + +interface TimePickerProps { + prefixCls: string; + clearText: string; + disabled: boolean; + allowEmpty: boolean; + open: boolean; + defaultValue: moment.Moment; + defaultOpenValue: moment.Moment; + value: moment.Moment; + placeholder: string; + className: string; + id: string; + popupClassName: string; + showHour: boolean; + showMinute: boolean; + showSecond: boolean; + format: string; + disabledHours: () => number[]; + disabledMinutes: (hour: number) => number[]; + disabledSeconds: (hour: number, minute: number) => number[]; + use12Hours: boolean; + hideDisabledOptions: boolean; + onChange: (value: moment.Moment) => void; + addon: (timepicker: TimePicker) => void; + placement: string; + transitionName: string; + onOpen: (state: { open: boolean }) => void; + onClose: (state: { open: boolean }) => void; + hourStep: number; + minuteStep: number; + secondStep: number; + focusOnOpen: boolean; + inputReadOnly: boolean; + inputIcon: React.ReactNode; + clearIcon: React.ReactNode; +} + +export default class TimePicker extends React.Component> { + constructor(props: Readonly>) + + close(): void; + isAM(): boolean; +} diff --git a/types/rc-time-picker/rc-time-picker-tests.tsx b/types/rc-time-picker/rc-time-picker-tests.tsx new file mode 100644 index 0000000000..9717e21038 --- /dev/null +++ b/types/rc-time-picker/rc-time-picker-tests.tsx @@ -0,0 +1,10 @@ +import TimePicker from 'rc-time-picker'; +import * as React from 'react'; +import * as moment from 'moment'; + + {}} + placeholder={'Input time'} + showSecond={false} + onOpen={({open}: { open: boolean }) => {}}/>; diff --git a/types/rc-time-picker/tsconfig.json b/types/rc-time-picker/tsconfig.json new file mode 100644 index 0000000000..013c1bfcb5 --- /dev/null +++ b/types/rc-time-picker/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "rc-time-picker-tests.tsx" + ] +} diff --git a/types/rc-time-picker/tslint.json b/types/rc-time-picker/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/rc-time-picker/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From ae1d344fdf249a4a18ddfd170d62480460f42040 Mon Sep 17 00:00:00 2001 From: Frithjof Winkelmann Date: Thu, 1 Nov 2018 14:12:34 +0100 Subject: [PATCH 28/68] Update type of addon in rc-time-picker --- types/rc-time-picker/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/rc-time-picker/index.d.ts b/types/rc-time-picker/index.d.ts index 354189cc3b..79d3f2b89a 100644 --- a/types/rc-time-picker/index.d.ts +++ b/types/rc-time-picker/index.d.ts @@ -32,7 +32,7 @@ interface TimePickerProps { use12Hours: boolean; hideDisabledOptions: boolean; onChange: (value: moment.Moment) => void; - addon: (timepicker: TimePicker) => void; + addon: (timepicker: TimePicker) => JSX.Element; placement: string; transitionName: string; onOpen: (state: { open: boolean }) => void; From 833ffc438b7d37a3b97e2cb4498fc74978c62d30 Mon Sep 17 00:00:00 2001 From: Micah Riggan Date: Sat, 27 Oct 2018 15:18:48 -0400 Subject: [PATCH 29/68] Adding typings for json-rpc-random-id Matching dslint Using declare function Header is required Adding a comment Moving export line Missing space Tslint... --- types/json-rpc-random-id/index.d.ts | 14 +++++++++++ .../json-rpc-random-id-tests.ts | 2 ++ types/json-rpc-random-id/tsconfig.json | 23 +++++++++++++++++++ types/json-rpc-random-id/tslint.json | 1 + 4 files changed, 40 insertions(+) create mode 100644 types/json-rpc-random-id/index.d.ts create mode 100644 types/json-rpc-random-id/json-rpc-random-id-tests.ts create mode 100644 types/json-rpc-random-id/tsconfig.json create mode 100644 types/json-rpc-random-id/tslint.json diff --git a/types/json-rpc-random-id/index.d.ts b/types/json-rpc-random-id/index.d.ts new file mode 100644 index 0000000000..14b5ba0ff0 --- /dev/null +++ b/types/json-rpc-random-id/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for json-rpc-random-id 1.0 +// Project: https://github.com/kumavis/json-rpc-random-id#readme +// Definitions by: Micah Riggan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/** + * Returns a function that generates a random number + * This number is to be used with web3 rpc + */ +declare function IdIterator(options?: { + max?: number; + start?: number; +}): () => number; + +export = IdIterator; diff --git a/types/json-rpc-random-id/json-rpc-random-id-tests.ts b/types/json-rpc-random-id/json-rpc-random-id-tests.ts new file mode 100644 index 0000000000..c71a7581e8 --- /dev/null +++ b/types/json-rpc-random-id/json-rpc-random-id-tests.ts @@ -0,0 +1,2 @@ +import jsonRPCRandomID = require("json-rpc-random-id"); +const generateId = jsonRPCRandomID(); diff --git a/types/json-rpc-random-id/tsconfig.json b/types/json-rpc-random-id/tsconfig.json new file mode 100644 index 0000000000..c39a0a4e2b --- /dev/null +++ b/types/json-rpc-random-id/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes":true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "json-rpc-random-id-tests.ts" + ] +} diff --git a/types/json-rpc-random-id/tslint.json b/types/json-rpc-random-id/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/json-rpc-random-id/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 862d10038fb50556d33b8e8d3a141242b4276c38 Mon Sep 17 00:00:00 2001 From: Will Soto Date: Thu, 1 Nov 2018 19:52:41 -0400 Subject: [PATCH 30/68] Remove patch version from knex typings. Only MAJOR.MINOR Signed-off-by: Will Soto --- types/knex/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index 3aefe33dca..f1d0083756 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Knex.js 0.15.2 +// Type definitions for Knex.js 0.15 // Project: https://github.com/tgriesser/knex // Definitions by: Qubo // Pablo Rodríguez From ce45dc72c04ce322901dc22f81e12f8cb8c51eb1 Mon Sep 17 00:00:00 2001 From: g1eny0ung Date: Fri, 2 Nov 2018 09:32:59 +0800 Subject: [PATCH 31/68] Upgrade react-alert to 4.0 --- types/react-alert/index.d.ts | 122 ++++----------------- types/react-alert/react-alert-tests.tsx | 113 +++++++++++++------ types/react-alert/v2/index.d.ts | 110 +++++++++++++++++++ types/react-alert/v2/react-alert-tests.tsx | 48 ++++++++ types/react-alert/v2/tsconfig.json | 27 +++++ types/react-alert/v2/tslint.json | 1 + 6 files changed, 286 insertions(+), 135 deletions(-) create mode 100644 types/react-alert/v2/index.d.ts create mode 100644 types/react-alert/v2/react-alert-tests.tsx create mode 100644 types/react-alert/v2/tsconfig.json create mode 100644 types/react-alert/v2/tslint.json diff --git a/types/react-alert/index.d.ts b/types/react-alert/index.d.ts index 3814b7f29f..cbc48d247f 100644 --- a/types/react-alert/index.d.ts +++ b/types/react-alert/index.d.ts @@ -1,110 +1,34 @@ -// Type definitions for react-alert 2.4 +// Type definitions for react-alert 4.0 // Project: https://github.com/schiehll/react-alert -// Definitions by: Steve Syrell +// Definitions by: Yue Yang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import * as React from "react"; +import * as React from 'react'; -export interface AlertContainerProps { - /** - * The offset of the alert from the page border, can be any number. - * - * Default: 14. - */ - offset: number; +export type AlertPosition = + | 'top left' + | 'top right' + | 'top center' + | 'bottom left' + | 'bottom right' + | 'bottom center'; - /** - * The position of the alert. Can be [bottom left, bottom right, top left, top right]. - * - * Default: 'bottom left' - */ - position: string; +export type AlertType = 'info' | 'success' | 'error'; +export type AlertTransition = 'fade' | 'scale'; - /** - * The color theme of the alert. Can be [dark, light]. - * - * Default: 'dark' - */ - theme: string; - - /** - * The time in milliseconds the alert is displayed. After this - * time ellapses, the alert will close itself. Use 0 to prevent self-closure - * (applies to all alerts). - * - * Default: 5000 - */ - time: number; - - /** - * The transition animation. Can be [scale, fade]. - * - * Default: 'scale' - */ - transition: string; +export interface ProviderProps { + offset?: string; + position?: AlertPosition; + timeout?: number; + type?: AlertType; + transition?: AlertTransition; + zIndex?: number; + template: React.ComponentType; } -export interface AlertShowOptions { - /** - * The time in milliseconds the alert is displayed. After this - * time ellapses, the alert will close itself. Use 0 to prevent self-closure. - */ - time?: number; +export class Provider extends React.Component {} - /** - * The icon to show in the alert. - * - * Default: the icon which matches the type of alert to be shown. - */ - icon?: React.ReactNode; +export const Alert: React.Consumer; - /** - * A callback function that will be called when the alert is closed. - */ - onClose?: () => void; - - /** - * The type of alert to show. This will only be used when calling show(). - * Can be [info, success, error]. - * - * Default: 'info' - */ - type?: string; -} - -export default class AlertContainer extends React.Component { - /** - * Show a success alert. - * @returns The id of the created alert. - */ - success(message: string, options?: AlertShowOptions): string; - - /** - * Show an error alert. - * @returns The id of the created alert. - */ - error(message: string, options?: AlertShowOptions): string; - - /** - * Show an info alert. - * @returns The id of the created alert. - */ - info(message: string, options?: AlertShowOptions): string; - - /** - * Show an alert. - * @returns The id of the created alert. - */ - show(message: string, options?: AlertShowOptions): string; - - /** - * Remove all alerts from the page. - */ - removeAll(): void; - - /** - * Removes the alert with the specified id from the page. - */ - remove(id: string): void; -} +export function withAlert

(c: React.ComponentType

): React.ComponentType

; diff --git a/types/react-alert/react-alert-tests.tsx b/types/react-alert/react-alert-tests.tsx index 84686ea73d..d421d8cc88 100644 --- a/types/react-alert/react-alert-tests.tsx +++ b/types/react-alert/react-alert-tests.tsx @@ -1,48 +1,89 @@ -import * as React from "react"; -import AlertContainer, { AlertContainerProps, AlertShowOptions } from "react-alert"; +import * as React from 'react'; +import { + Provider as AlertProvider, + Alert, + withAlert, + AlertPosition, + AlertTransition +} from 'react-alert'; -export class ReactAlertTest extends React.Component { - private _alert: AlertContainer; +class AppWithoutAlert extends React.Component { render() { - const props: AlertContainerProps = { - offset: 14, - position: "bottom left", - theme: "dark", - time: 5000, - transition: "scale" - }; + return ( + + ); + } +} + +class AppAlert extends React.Component { + render() { + return ( + + {alert => ( + + )} + + ); + } +} + +const App = withAlert(AppWithoutAlert); + +class AlertTemplate extends React.Component { + render() { + // the style contains only the margin given as offset + // options contains all alert given options + // message is the alert message... + // close is a function that closes the alert + const { style, options, message, close } = this.props; return ( -

- this._alert = a as AlertContainer} {...props} /> +
+ {options.type === 'info' && '!'} + {options.type === 'success' && ':)'} + {options.type === 'error' && ':('} + {message} +
); } +} - private _testMethods(): void { - const options: AlertShowOptions = { - time: 5000, - type: "info", - onClose: this._onAlertClosed, - icon: - }; +const options = { + position: 'bottom center' as AlertPosition, + timeout: 5000, + offset: '30px', + transition: 'scale' as AlertTransition +}; - let alertId: string; - alertId = this._alert.show("show without options"); - alertId = this._alert.show("show with options", options); - - alertId = this._alert.error("error without options"); - alertId = this._alert.error("error with options", options); - - alertId = this._alert.info("info without options"); - alertId = this._alert.info("info with options", options); +class Root extends React.Component { + render() { + return ( + + + + ); + } +} - alertId = this._alert.success("success without options"); - alertId = this._alert.success("success with options", options); - - this._alert.remove(alertId); - this._alert.removeAll(); +class RootAlert extends React.Component { + render() { + return ( + + + + ); } - - private _onAlertClosed(): void { } } diff --git a/types/react-alert/v2/index.d.ts b/types/react-alert/v2/index.d.ts new file mode 100644 index 0000000000..3814b7f29f --- /dev/null +++ b/types/react-alert/v2/index.d.ts @@ -0,0 +1,110 @@ +// Type definitions for react-alert 2.4 +// Project: https://github.com/schiehll/react-alert +// Definitions by: Steve Syrell +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from "react"; + +export interface AlertContainerProps { + /** + * The offset of the alert from the page border, can be any number. + * + * Default: 14. + */ + offset: number; + + /** + * The position of the alert. Can be [bottom left, bottom right, top left, top right]. + * + * Default: 'bottom left' + */ + position: string; + + /** + * The color theme of the alert. Can be [dark, light]. + * + * Default: 'dark' + */ + theme: string; + + /** + * The time in milliseconds the alert is displayed. After this + * time ellapses, the alert will close itself. Use 0 to prevent self-closure + * (applies to all alerts). + * + * Default: 5000 + */ + time: number; + + /** + * The transition animation. Can be [scale, fade]. + * + * Default: 'scale' + */ + transition: string; +} + +export interface AlertShowOptions { + /** + * The time in milliseconds the alert is displayed. After this + * time ellapses, the alert will close itself. Use 0 to prevent self-closure. + */ + time?: number; + + /** + * The icon to show in the alert. + * + * Default: the icon which matches the type of alert to be shown. + */ + icon?: React.ReactNode; + + /** + * A callback function that will be called when the alert is closed. + */ + onClose?: () => void; + + /** + * The type of alert to show. This will only be used when calling show(). + * Can be [info, success, error]. + * + * Default: 'info' + */ + type?: string; +} + +export default class AlertContainer extends React.Component { + /** + * Show a success alert. + * @returns The id of the created alert. + */ + success(message: string, options?: AlertShowOptions): string; + + /** + * Show an error alert. + * @returns The id of the created alert. + */ + error(message: string, options?: AlertShowOptions): string; + + /** + * Show an info alert. + * @returns The id of the created alert. + */ + info(message: string, options?: AlertShowOptions): string; + + /** + * Show an alert. + * @returns The id of the created alert. + */ + show(message: string, options?: AlertShowOptions): string; + + /** + * Remove all alerts from the page. + */ + removeAll(): void; + + /** + * Removes the alert with the specified id from the page. + */ + remove(id: string): void; +} diff --git a/types/react-alert/v2/react-alert-tests.tsx b/types/react-alert/v2/react-alert-tests.tsx new file mode 100644 index 0000000000..84686ea73d --- /dev/null +++ b/types/react-alert/v2/react-alert-tests.tsx @@ -0,0 +1,48 @@ +import * as React from "react"; +import AlertContainer, { AlertContainerProps, AlertShowOptions } from "react-alert"; + +export class ReactAlertTest extends React.Component { + private _alert: AlertContainer; + render() { + const props: AlertContainerProps = { + offset: 14, + position: "bottom left", + theme: "dark", + time: 5000, + transition: "scale" + }; + + return ( +
+ this._alert = a as AlertContainer} {...props} /> +
+ ); + } + + private _testMethods(): void { + const options: AlertShowOptions = { + time: 5000, + type: "info", + onClose: this._onAlertClosed, + icon: + }; + + let alertId: string; + alertId = this._alert.show("show without options"); + alertId = this._alert.show("show with options", options); + + alertId = this._alert.error("error without options"); + alertId = this._alert.error("error with options", options); + + alertId = this._alert.info("info without options"); + alertId = this._alert.info("info with options", options); + + alertId = this._alert.success("success without options"); + alertId = this._alert.success("success with options", options); + + this._alert.remove(alertId); + this._alert.removeAll(); + } + + private _onAlertClosed(): void { } +} diff --git a/types/react-alert/v2/tsconfig.json b/types/react-alert/v2/tsconfig.json new file mode 100644 index 0000000000..47de249c7e --- /dev/null +++ b/types/react-alert/v2/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "react-alert": ["react-alert/v2"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-alert-tests.tsx" + ] +} diff --git a/types/react-alert/v2/tslint.json b/types/react-alert/v2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-alert/v2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From f74d5783e763c6f3235c48f51e3acfd63c3fa518 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Fri, 2 Nov 2018 03:56:04 -0400 Subject: [PATCH 32/68] Add types for scheduler package --- types/scheduler/index.d.ts | 28 ++++++++++++++++++++++++++++ types/scheduler/scheduler-tests.ts | 8 ++++++++ types/scheduler/tsconfig.json | 23 +++++++++++++++++++++++ types/scheduler/tslint.json | 1 + 4 files changed, 60 insertions(+) create mode 100644 types/scheduler/index.d.ts create mode 100644 types/scheduler/scheduler-tests.ts create mode 100644 types/scheduler/tsconfig.json create mode 100644 types/scheduler/tslint.json diff --git a/types/scheduler/index.d.ts b/types/scheduler/index.d.ts new file mode 100644 index 0000000000..8ed478b8ef --- /dev/null +++ b/types/scheduler/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for scheduler 0.10 +// Project: https://reactjs.org/ +// Definitions by: Nathan Bierema +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface Deadline { + timeRemaining(): number; + didTimeout: boolean; +} +export type FrameCallbackType = (deadline: Deadline) => FameCallbackType | undefined; +export interface CallbackNode { + callback: FrameCallbackType; + priorityLevel: number; + expirationTime: number; + next: CallbackNode | null; + prev: CallbackNode | null; +} + +export const unstable_ImmediatePriority = 1; +export const unstable_UserBlockingPriority = 2; +export const unstable_NormalPriority = 3; +export const unstable_IdlePriority = 4; +export function unstable_runWithPriority(priorityLevel: number, eventHandler: () => T): T | undefined; +export function unstable_scheduleCallback(callback: FameCallbackType, deprecated_options?: { timeout: number}): CallbackNode; +export function unstable_cancelCallback(callbackNode: CallbackNode): void; +export function unstable_wrapCallback(callback: FrameCallbackType): () => FrameCallbackType | undefined; +export function unstable_getCurrentPriorityLevel(): number; +export function unstable_now(): number; diff --git a/types/scheduler/scheduler-tests.ts b/types/scheduler/scheduler-tests.ts new file mode 100644 index 0000000000..49baa28e3a --- /dev/null +++ b/types/scheduler/scheduler-tests.ts @@ -0,0 +1,8 @@ +import { unstable_scheduleCallback, unstable_cancelCallback, unstable_now } from 'scheduler'; + +// $ExpectType CallbackNode +const callbackNode = unstable_scheduleCallback(() => 0, { timeout: 100 }); +unstable_cancelCallback(callbackNode); + +// $ExpectType number +unstable_now(); diff --git a/types/scheduler/tsconfig.json b/types/scheduler/tsconfig.json new file mode 100644 index 0000000000..b6c5c6021a --- /dev/null +++ b/types/scheduler/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "scheduler-tests.ts" + ] +} diff --git a/types/scheduler/tslint.json b/types/scheduler/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/scheduler/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 93cc9ad5d66c32e58183121b327ec2d043a50fb6 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Fri, 2 Nov 2018 04:02:07 -0400 Subject: [PATCH 33/68] Fix --- types/scheduler/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/scheduler/index.d.ts b/types/scheduler/index.d.ts index 8ed478b8ef..4b85703328 100644 --- a/types/scheduler/index.d.ts +++ b/types/scheduler/index.d.ts @@ -7,7 +7,7 @@ export interface Deadline { timeRemaining(): number; didTimeout: boolean; } -export type FrameCallbackType = (deadline: Deadline) => FameCallbackType | undefined; +export type FrameCallbackType = (deadline: Deadline) => FrameCallbackType | undefined; export interface CallbackNode { callback: FrameCallbackType; priorityLevel: number; @@ -21,7 +21,7 @@ export const unstable_UserBlockingPriority = 2; export const unstable_NormalPriority = 3; export const unstable_IdlePriority = 4; export function unstable_runWithPriority(priorityLevel: number, eventHandler: () => T): T | undefined; -export function unstable_scheduleCallback(callback: FameCallbackType, deprecated_options?: { timeout: number}): CallbackNode; +export function unstable_scheduleCallback(callback: F4ameCallbackType, deprecated_options?: { timeout: number}): CallbackNode; export function unstable_cancelCallback(callbackNode: CallbackNode): void; export function unstable_wrapCallback(callback: FrameCallbackType): () => FrameCallbackType | undefined; export function unstable_getCurrentPriorityLevel(): number; From eba14636591e60f101c6fa209d9f74fb56c966d4 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Fri, 2 Nov 2018 04:10:16 -0400 Subject: [PATCH 34/68] Fix --- types/scheduler/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/scheduler/index.d.ts b/types/scheduler/index.d.ts index 4b85703328..9ec0f55e0f 100644 --- a/types/scheduler/index.d.ts +++ b/types/scheduler/index.d.ts @@ -21,7 +21,7 @@ export const unstable_UserBlockingPriority = 2; export const unstable_NormalPriority = 3; export const unstable_IdlePriority = 4; export function unstable_runWithPriority(priorityLevel: number, eventHandler: () => T): T | undefined; -export function unstable_scheduleCallback(callback: F4ameCallbackType, deprecated_options?: { timeout: number}): CallbackNode; +export function unstable_scheduleCallback(callback: FrameCallbackType, deprecated_options?: { timeout: number}): CallbackNode; export function unstable_cancelCallback(callbackNode: CallbackNode): void; export function unstable_wrapCallback(callback: FrameCallbackType): () => FrameCallbackType | undefined; export function unstable_getCurrentPriorityLevel(): number; From 9ea2436ebf4b06d462e6650e6a35086b17c15639 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Fri, 2 Nov 2018 09:19:32 +0100 Subject: [PATCH 35/68] Fix 'expected onespace after colon in property-declaration' --- types/terser/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index ea57a27c53..97a3244698 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -96,7 +96,7 @@ export interface MinifyOptions { warnings?: boolean; mangle?: boolean | MangleOptions; output?: OutputOptions; - compress?: boolean | CompressOptions; + compress?: boolean | CompressOptions; nameCache?: {}; } From 951bf36687025b461ed69aef24c16e841853a894 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Fri, 2 Nov 2018 04:21:10 -0400 Subject: [PATCH 36/68] Fix --- types/scheduler/index.d.ts | 1 + types/scheduler/scheduler-tests.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/scheduler/index.d.ts b/types/scheduler/index.d.ts index 9ec0f55e0f..66da96e759 100644 --- a/types/scheduler/index.d.ts +++ b/types/scheduler/index.d.ts @@ -2,6 +2,7 @@ // Project: https://reactjs.org/ // Definitions by: Nathan Bierema // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 export interface Deadline { timeRemaining(): number; diff --git a/types/scheduler/scheduler-tests.ts b/types/scheduler/scheduler-tests.ts index 49baa28e3a..84c35fb5b7 100644 --- a/types/scheduler/scheduler-tests.ts +++ b/types/scheduler/scheduler-tests.ts @@ -1,7 +1,7 @@ import { unstable_scheduleCallback, unstable_cancelCallback, unstable_now } from 'scheduler'; // $ExpectType CallbackNode -const callbackNode = unstable_scheduleCallback(() => 0, { timeout: 100 }); +const callbackNode = unstable_scheduleCallback(() => {}, { timeout: 100 }); unstable_cancelCallback(callbackNode); // $ExpectType number From 4ebc65dc5c6f8fda52fabee60c4e057bb35c3746 Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Fri, 2 Nov 2018 09:22:23 +0100 Subject: [PATCH 37/68] Remove dtslint compatibility warning --- types/terser/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 97a3244698..7c64a67e34 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: JordiAnderl // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.0 -// No support for typescript version 3. See https://github.com/Microsoft/dtslint/issues/137 import * as MOZ_SourceMap from "source-map"; From a1cdeac2042d131eb0eb0881e4c72590531a00ec Mon Sep 17 00:00:00 2001 From: JordiAnderl Date: Fri, 2 Nov 2018 09:30:52 +0100 Subject: [PATCH 38/68] Use literals for Tokenizer types --- types/terser/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/terser/index.d.ts b/types/terser/index.d.ts index 7c64a67e34..44a3e1cdb7 100644 --- a/types/terser/index.d.ts +++ b/types/terser/index.d.ts @@ -9,10 +9,9 @@ import * as MOZ_SourceMap from "source-map"; export interface Tokenizer { /** * The type of this token. - * Can be "num", "string", "regexp", "operator", "punc", "atom", "name", "keyword", "comment1" or "comment2". * "comment1" and "comment2" are for single-line, respectively multi-line comments. */ - type: string; + type: "num" | "string" | "regexp" | "operator" | "punc" | "atom" | "name" | "keyword" | "comment1" | "comment2"; /** * The name of the file where this token originated from. Useful when compressing multiple files at once to generate the proper source map. From d595662faa64f611335fc5cf6e487fc87c2a2b2f Mon Sep 17 00:00:00 2001 From: Timur Manyanov Date: Fri, 2 Nov 2018 10:18:08 +0100 Subject: [PATCH 39/68] Add makeup-screenreader-trap definitions --- types/makeup-screenreader-trap/index.d.ts | 9 +++++++ .../makeup-screenreader-trap-tests.ts | 9 +++++++ types/makeup-screenreader-trap/tsconfig.json | 24 +++++++++++++++++++ types/makeup-screenreader-trap/tslint.json | 1 + 4 files changed, 43 insertions(+) create mode 100644 types/makeup-screenreader-trap/index.d.ts create mode 100644 types/makeup-screenreader-trap/makeup-screenreader-trap-tests.ts create mode 100644 types/makeup-screenreader-trap/tsconfig.json create mode 100644 types/makeup-screenreader-trap/tslint.json diff --git a/types/makeup-screenreader-trap/index.d.ts b/types/makeup-screenreader-trap/index.d.ts new file mode 100644 index 0000000000..0995b62a3c --- /dev/null +++ b/types/makeup-screenreader-trap/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for makeup-screenreader-trap 0.0 +// Project: https://github.com/makeup-js/makeup-screenreader-trap#readme +// Definitions by: Timur Manyanov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +export function trap(el: HTMLElement): void; + +export function untrap(): void; diff --git a/types/makeup-screenreader-trap/makeup-screenreader-trap-tests.ts b/types/makeup-screenreader-trap/makeup-screenreader-trap-tests.ts new file mode 100644 index 0000000000..48b198ab2d --- /dev/null +++ b/types/makeup-screenreader-trap/makeup-screenreader-trap-tests.ts @@ -0,0 +1,9 @@ +import { trap, untrap } from 'makeup-screenreader-trap'; + +const widgetEl: HTMLElement | null = document.querySelector('.expander'); + +if (widgetEl) { + trap(widgetEl); +} + +untrap(); diff --git a/types/makeup-screenreader-trap/tsconfig.json b/types/makeup-screenreader-trap/tsconfig.json new file mode 100644 index 0000000000..08df420e11 --- /dev/null +++ b/types/makeup-screenreader-trap/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "makeup-screenreader-trap-tests.ts" + ] +} diff --git a/types/makeup-screenreader-trap/tslint.json b/types/makeup-screenreader-trap/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/makeup-screenreader-trap/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From acae25e4856e102dcc17548de8165a92bb0aaf98 Mon Sep 17 00:00:00 2001 From: Philipp A Date: Fri, 2 Nov 2018 10:17:35 +0100 Subject: [PATCH 40/68] =?UTF-8?q?Switched=20to=20=E2=80=9Crequire=20=3D?= =?UTF-8?q?=E2=80=9D=20style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/markdown-it-anchor/index.d.ts | 6 ++--- .../markdown-it-anchor-tests.ts | 2 +- types/markdown-it-container/index.d.ts | 6 ++--- .../markdown-it-container-tests.ts | 4 ++-- types/markdown-it-lazy-headers/index.d.ts | 2 +- types/markdown-it/index.d.ts | 2 +- types/markdown-it/lib/index.d.ts | 22 +++++++++---------- types/markdown-it/lib/parser_block.d.ts | 6 ++--- types/markdown-it/lib/parser_core.d.ts | 8 +++---- types/markdown-it/lib/parser_inline.d.ts | 8 +++---- types/markdown-it/lib/renderer.d.ts | 6 ++--- types/markdown-it/lib/ruler.d.ts | 6 ++--- .../lib/rules_block/state_block.d.ts | 8 +++---- .../lib/rules_core/state_core.d.ts | 6 ++--- .../lib/rules_inline/state_inline.d.ts | 8 +++---- types/markdown-it/lib/token.d.ts | 2 -- types/markdown-it/markdown-it-tests.ts | 6 ++--- types/prosemirror-markdown/index.d.ts | 2 +- 18 files changed, 46 insertions(+), 64 deletions(-) diff --git a/types/markdown-it-anchor/index.d.ts b/types/markdown-it-anchor/index.d.ts index e0ef0dd9f9..39cb91be45 100644 --- a/types/markdown-it-anchor/index.d.ts +++ b/types/markdown-it-anchor/index.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as MarkdownIt from 'markdown-it'; -import * as Core from 'markdown-it/lib/parser_core'; -import * as Token from 'markdown-it/lib/token'; +import MarkdownIt = require('markdown-it'); +import Core = require('markdown-it/lib/parser_core'); +import Token = require('markdown-it/lib/token'); declare namespace anchor { interface AnchorInfo { diff --git a/types/markdown-it-anchor/markdown-it-anchor-tests.ts b/types/markdown-it-anchor/markdown-it-anchor-tests.ts index 3570ba764b..a9a865a469 100644 --- a/types/markdown-it-anchor/markdown-it-anchor-tests.ts +++ b/types/markdown-it-anchor/markdown-it-anchor-tests.ts @@ -1,4 +1,4 @@ -import * as MarkdownIt from "markdown-it"; +import MarkdownIt = require("markdown-it"); import anchor = require("markdown-it-anchor"); const md = new MarkdownIt(); diff --git a/types/markdown-it-container/index.d.ts b/types/markdown-it-container/index.d.ts index 99c33958c5..2920f38f91 100644 --- a/types/markdown-it-container/index.d.ts +++ b/types/markdown-it-container/index.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as MarkdownIt from 'markdown-it'; -import * as Renderer from 'markdown-it/lib/renderer'; -import * as Token from 'markdown-it/lib/token'; +import MarkdownIt = require('markdown-it'); +import Renderer = require('markdown-it/lib/renderer'); +import Token = require('markdown-it/lib/token'); declare namespace markdownItContainer { interface ContainerOpts { diff --git a/types/markdown-it-container/markdown-it-container-tests.ts b/types/markdown-it-container/markdown-it-container-tests.ts index fcd46b80d9..e6754f82f3 100644 --- a/types/markdown-it-container/markdown-it-container-tests.ts +++ b/types/markdown-it-container/markdown-it-container-tests.ts @@ -1,5 +1,5 @@ -import * as MarkdownIt from "markdown-it"; -import * as Token from "markdown-it/lib/token"; +import MarkdownIt = require("markdown-it"); +import Token = require("markdown-it/lib/token"); import MarkdownItContainer = require("markdown-it-container"); diff --git a/types/markdown-it-lazy-headers/index.d.ts b/types/markdown-it-lazy-headers/index.d.ts index f16c30e651..43ac828764 100644 --- a/types/markdown-it-lazy-headers/index.d.ts +++ b/types/markdown-it-lazy-headers/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as MarkdownIt from 'markdown-it'; +import MarkdownIt = require('markdown-it'); declare function lazyheaders(md: MarkdownIt): void; diff --git a/types/markdown-it/index.d.ts b/types/markdown-it/index.d.ts index 296d55f41c..e7d0ffa6e7 100644 --- a/types/markdown-it/index.d.ts +++ b/types/markdown-it/index.d.ts @@ -4,5 +4,5 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as MarkdownIt from "./lib"; +import MarkdownIt = require("./lib"); export = MarkdownIt; diff --git a/types/markdown-it/lib/index.d.ts b/types/markdown-it/lib/index.d.ts index 5360d80b1a..9a9caf37b6 100644 --- a/types/markdown-it/lib/index.d.ts +++ b/types/markdown-it/lib/index.d.ts @@ -1,16 +1,16 @@ import { LinkifyIt } from 'linkify-it' -import * as State from './rules_core/state_core'; -import * as StateBlock from './rules_block/state_block'; -import * as StateInline from './rules_inline/state_inline'; +import State = require('./rules_core/state_core'); +import StateBlock = require('./rules_block/state_block'); +import StateInline = require('./rules_inline/state_inline'); -import * as Core from './parser_core'; -import * as ParserBlock from './parser_block'; -import * as ParserInline from './parser_inline'; +import Core = require('./parser_core'); +import ParserBlock = require('./parser_block'); +import ParserInline = require('./parser_inline'); -import * as Renderer from './renderer'; -import * as Ruler from './ruler'; -import * as Token from './token'; +import Renderer = require('./renderer'); +import Ruler = require('./ruler'); +import Token = require('./token'); export = MarkdownIt; export as namespace markdownit; @@ -61,7 +61,7 @@ interface MarkdownIt { escapeRE(str: string): string; normalizeReference(str: string): string; } - + disable(rules: string[] | string, ignoreInvalid?: boolean): MarkdownIt; enable(rules: string[] | string, ignoreInvalid?: boolean): MarkdownIt; set(options: MarkdownIt.Options): MarkdownIt; @@ -97,7 +97,7 @@ declare module MarkdownIt { interface RulerInline extends Ruler {} interface RulerBlock extends Ruler {} - + type TokenRender = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => void; interface Delimiter { diff --git a/types/markdown-it/lib/parser_block.d.ts b/types/markdown-it/lib/parser_block.d.ts index 288a791089..2efc76b858 100644 --- a/types/markdown-it/lib/parser_block.d.ts +++ b/types/markdown-it/lib/parser_block.d.ts @@ -1,5 +1,5 @@ -import * as MarkdownIt from "."; -import * as Token from "./token"; +import MarkdownIt = require("."); +import Token = require("./token"); export = ParserBlock; @@ -7,5 +7,3 @@ declare class ParserBlock { parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void; ruler: MarkdownIt.RulerBlock; } - -declare module ParserBlock {} diff --git a/types/markdown-it/lib/parser_core.d.ts b/types/markdown-it/lib/parser_core.d.ts index 42d2759ab0..a6559bdfef 100644 --- a/types/markdown-it/lib/parser_core.d.ts +++ b/types/markdown-it/lib/parser_core.d.ts @@ -1,6 +1,6 @@ -import * as MarkdownIt from "."; -import * as Ruler from "./ruler"; -import * as Token from "./token"; +import MarkdownIt = require("."); +import Ruler = require("./ruler"); +import Token = require("./token"); export = ParserCore; @@ -8,5 +8,3 @@ declare class ParserCore { process(state: any): void; ruler: Ruler; } - -declare module ParserCore {} diff --git a/types/markdown-it/lib/parser_inline.d.ts b/types/markdown-it/lib/parser_inline.d.ts index 1be89e09f1..ad7aa26d93 100644 --- a/types/markdown-it/lib/parser_inline.d.ts +++ b/types/markdown-it/lib/parser_inline.d.ts @@ -1,6 +1,6 @@ -import * as MarkdownIt from "."; -import * as State from "./rules_core/state_core"; -import * as Token from "./token"; +import MarkdownIt = require("."); +import State = require("./rules_core/state_core"); +import Token = require("./token"); export = ParserInline; @@ -11,5 +11,3 @@ declare class ParserInline { ruler: MarkdownIt.RulerInline; ruler2: MarkdownIt.RulerInline; } - -declare module ParserInline {} diff --git a/types/markdown-it/lib/renderer.d.ts b/types/markdown-it/lib/renderer.d.ts index 51125309e6..0231dad0f9 100644 --- a/types/markdown-it/lib/renderer.d.ts +++ b/types/markdown-it/lib/renderer.d.ts @@ -1,5 +1,5 @@ -import * as MarkdownIt from "."; -import * as Token from "./token"; +import MarkdownIt = require("."); +import Token = require("./token"); export = Renderer; @@ -10,5 +10,3 @@ declare class Renderer { renderInline(tokens: Token[], options: any, env: any): string; renderToken(tokens: Token[], idx: number, options: any): string; } - -declare module Renderer {} diff --git a/types/markdown-it/lib/ruler.d.ts b/types/markdown-it/lib/ruler.d.ts index 106a3d1d72..62ab55e3de 100644 --- a/types/markdown-it/lib/ruler.d.ts +++ b/types/markdown-it/lib/ruler.d.ts @@ -1,5 +1,5 @@ -import * as MarkdownIt from "."; -import * as State from "./rules_core/state_core"; +import MarkdownIt = require("."); +import State = require("./rules_core/state_core"); export = Ruler; @@ -13,5 +13,3 @@ declare class Ruler { getRules(chain: string): MarkdownIt.Rule[]; push(ruleName: string, rule: MarkdownIt.Rule, options?: any): void; } - -declare module Ruler {} diff --git a/types/markdown-it/lib/rules_block/state_block.d.ts b/types/markdown-it/lib/rules_block/state_block.d.ts index e1dc5a2fbd..6eebab4202 100644 --- a/types/markdown-it/lib/rules_block/state_block.d.ts +++ b/types/markdown-it/lib/rules_block/state_block.d.ts @@ -1,6 +1,6 @@ -import * as MarkdownIt from ".."; -import * as State from "../rules_core/state_core"; -import * as Token from "../token"; +import MarkdownIt = require(".."); +import State = require("../rules_core/state_core"); +import Token = require("../token"); export = StateBlock; @@ -21,5 +21,3 @@ declare class StateBlock extends State { lineMax: number; tight: boolean; } - -declare module StateBlock {} diff --git a/types/markdown-it/lib/rules_core/state_core.d.ts b/types/markdown-it/lib/rules_core/state_core.d.ts index dc0eb54921..7cf73134aa 100644 --- a/types/markdown-it/lib/rules_core/state_core.d.ts +++ b/types/markdown-it/lib/rules_core/state_core.d.ts @@ -1,5 +1,5 @@ -import * as MarkdownIt from ".."; -import * as Token from "../token"; +import MarkdownIt = require(".."); +import Token = require("../token"); export = StateCore; @@ -18,5 +18,3 @@ declare class StateCore { /** Return any for a yet untyped property */ [undocumented: string]: any; } - -declare module StateCore {} diff --git a/types/markdown-it/lib/rules_inline/state_inline.d.ts b/types/markdown-it/lib/rules_inline/state_inline.d.ts index eaa1feaa00..27938d99da 100644 --- a/types/markdown-it/lib/rules_inline/state_inline.d.ts +++ b/types/markdown-it/lib/rules_inline/state_inline.d.ts @@ -1,6 +1,6 @@ -import * as MarkdownIt from ".."; -import * as State from "../rules_core/state_core"; -import * as Token from "../token"; +import MarkdownIt = require(".."); +import State = require("../rules_core/state_core"); +import Token = require("../token"); export = StateInline; @@ -44,5 +44,3 @@ declare class StateInline extends State { length: number }; } - -declare module StateInline {} diff --git a/types/markdown-it/lib/token.d.ts b/types/markdown-it/lib/token.d.ts index 142b59289b..1f71d54bfd 100644 --- a/types/markdown-it/lib/token.d.ts +++ b/types/markdown-it/lib/token.d.ts @@ -21,5 +21,3 @@ declare class Token { tag: string; type: string; } - -declare module Token {} diff --git a/types/markdown-it/markdown-it-tests.ts b/types/markdown-it/markdown-it-tests.ts index 3cb1a9ea3b..343661ad87 100644 --- a/types/markdown-it/markdown-it-tests.ts +++ b/types/markdown-it/markdown-it-tests.ts @@ -1,6 +1,6 @@ -import * as MarkdownIt from "markdown-it"; -import * as Renderer from "markdown-it/lib/renderer"; -import * as Token from "markdown-it/lib/token"; +import MarkdownIt = require("markdown-it"); +import Renderer = require("markdown-it/lib/renderer"); +import Token = require("markdown-it/lib/token"); { const md = new MarkdownIt(); diff --git a/types/prosemirror-markdown/index.d.ts b/types/prosemirror-markdown/index.d.ts index 7d18611513..91b37ea51e 100644 --- a/types/prosemirror-markdown/index.d.ts +++ b/types/prosemirror-markdown/index.d.ts @@ -7,7 +7,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as MarkdownIt from 'markdown-it'; +import MarkdownIt = require('markdown-it'); import { Node as ProsemirrorNode, Schema } from 'prosemirror-model'; /** From 7a8020b83a4b60ca3a8d8b2abbaba5c74052838a Mon Sep 17 00:00:00 2001 From: Will Soto Date: Fri, 2 Nov 2018 07:42:21 -0400 Subject: [PATCH 41/68] Enable tslint for knex Signed-off-by: Will Soto --- types/knex/tslint.json | 75 +----------------------------------------- 1 file changed, 1 insertion(+), 74 deletions(-) diff --git a/types/knex/tslint.json b/types/knex/tslint.json index d84fe24e60..f93cf8562a 100644 --- a/types/knex/tslint.json +++ b/types/knex/tslint.json @@ -1,76 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "unified-signatures": false - } + "extends": "dtslint/dt.json" } From 6f37c19a96b65fdb5c614d9236fd89536a63d197 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Fri, 2 Nov 2018 16:01:31 +0100 Subject: [PATCH 42/68] [@commercetools/enzyme-extensions] Add types --- ...commercetools__enzyme-extensions-tests.tsx | 30 +++++++++++++++++++ .../index.d.ts | 22 ++++++++++++++ .../tsconfig.json | 27 +++++++++++++++++ .../tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 types/commercetools__enzyme-extensions/commercetools__enzyme-extensions-tests.tsx create mode 100644 types/commercetools__enzyme-extensions/index.d.ts create mode 100644 types/commercetools__enzyme-extensions/tsconfig.json create mode 100644 types/commercetools__enzyme-extensions/tslint.json diff --git a/types/commercetools__enzyme-extensions/commercetools__enzyme-extensions-tests.tsx b/types/commercetools__enzyme-extensions/commercetools__enzyme-extensions-tests.tsx new file mode 100644 index 0000000000..bceab689e7 --- /dev/null +++ b/types/commercetools__enzyme-extensions/commercetools__enzyme-extensions-tests.tsx @@ -0,0 +1,30 @@ +import React = require('react'); +import enzyme = require('enzyme'); +import configureExtensions = require('@commercetools/enzyme-extensions'); + +configureExtensions(enzyme.ShallowWrapper); + +function App() { + return 'Hello world'} />; +} + +interface ChildProps { + cb: () => string; +} + +function Child(props: ChildProps) { + return
{props.cb()}
; +} + +enzyme.shallow() + .find(App) + .renderProp('render'); +enzyme.shallow() + .find(Child) + .renderProp('render', 1, 2); + +enzyme.shallow() + .find(Child) + .drill(props => props.cb()); + +enzyme.shallow().until(Child); diff --git a/types/commercetools__enzyme-extensions/index.d.ts b/types/commercetools__enzyme-extensions/index.d.ts new file mode 100644 index 0000000000..7c009f8e95 --- /dev/null +++ b/types/commercetools__enzyme-extensions/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for @commercetools/enzyme-extensions 3.0 +// Project: https://github.com/commercetools/enzyme-extensions +// Definitions by: Christian Rackerseder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as enzyme from 'enzyme'; + +declare module 'enzyme' { + interface UntilOptions { + maxDepth: number; + } + interface ShallowWrapper

{ + renderProp(propName: string, ...args: any[]): ShallowWrapper

; + drill(expander: (props: any) => ShallowWrapper): ShallowWrapper

; + until(selector: EnzymeSelector, options?: UntilOptions): ShallowWrapper

; + } +} + +declare function monkeyPatchShallowWrapper(s: typeof enzyme.ShallowWrapper): void; + +export = monkeyPatchShallowWrapper; diff --git a/types/commercetools__enzyme-extensions/tsconfig.json b/types/commercetools__enzyme-extensions/tsconfig.json new file mode 100644 index 0000000000..9e6d70239e --- /dev/null +++ b/types/commercetools__enzyme-extensions/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "paths": { + "@commercetools/enzyme-extensions": ["commercetools__enzyme-extensions"] + } + }, + "files": [ + "index.d.ts", + "commercetools__enzyme-extensions-tests.tsx" + ] +} diff --git a/types/commercetools__enzyme-extensions/tslint.json b/types/commercetools__enzyme-extensions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/commercetools__enzyme-extensions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From dfa10e28bb1f983dd0ef84baf0de9f2d9f6e9dc4 Mon Sep 17 00:00:00 2001 From: Frithjof Winkelmann Date: Fri, 2 Nov 2018 18:53:37 +0100 Subject: [PATCH 43/68] Enable esModuleInterop in rc-time-picker --- types/rc-time-picker/index.d.ts | 6 +++--- types/rc-time-picker/rc-time-picker-tests.tsx | 2 +- types/rc-time-picker/tsconfig.json | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/types/rc-time-picker/index.d.ts b/types/rc-time-picker/index.d.ts index 79d3f2b89a..62f6a7711a 100644 --- a/types/rc-time-picker/index.d.ts +++ b/types/rc-time-picker/index.d.ts @@ -7,8 +7,6 @@ import * as moment from "moment"; import * as React from 'react'; -export {}; - interface TimePickerProps { prefixCls: string; clearText: string; @@ -46,9 +44,11 @@ interface TimePickerProps { clearIcon: React.ReactNode; } -export default class TimePicker extends React.Component> { +declare class TimePicker extends React.Component> { constructor(props: Readonly>) close(): void; isAM(): boolean; } + +export = TimePicker; diff --git a/types/rc-time-picker/rc-time-picker-tests.tsx b/types/rc-time-picker/rc-time-picker-tests.tsx index 9717e21038..7f0ea63e9c 100644 --- a/types/rc-time-picker/rc-time-picker-tests.tsx +++ b/types/rc-time-picker/rc-time-picker-tests.tsx @@ -1,6 +1,6 @@ import TimePicker from 'rc-time-picker'; import * as React from 'react'; -import * as moment from 'moment'; +import moment from 'moment'; Date: Fri, 2 Nov 2018 11:52:21 -0700 Subject: [PATCH 44/68] Add error code 12009 for Office.UI.dislayDialogAsync method. --- types/office-js/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index 105062a56e..26631c8c1d 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -1035,6 +1035,10 @@ declare namespace Office { * 12007 * A dialog box is already opened from the task pane. A task pane add-in can only have one dialog box open at a time. * + * + * 12009 + * The user chose to ignore the dialog box. This error can occur in online versions of Office, where users may choose not to allow an add-in to present a dialog. + * * * * In the callback function passed to the displayDialogAsync method, you can use the properties of the AsyncResult object to return the From 0933324489d2b4368bb955ec1696d16b9eecdf21 Mon Sep 17 00:00:00 2001 From: Evan Cameron Date: Fri, 2 Nov 2018 16:21:36 -0400 Subject: [PATCH 45/68] Add lzma-native types --- types/lzma-native/index.d.ts | 130 +++++++++++++++++++++++++ types/lzma-native/lzma-native-tests.ts | 55 +++++++++++ types/lzma-native/tsconfig.json | 13 +++ types/lzma-native/tslint.json | 1 + 4 files changed, 199 insertions(+) create mode 100644 types/lzma-native/index.d.ts create mode 100644 types/lzma-native/lzma-native-tests.ts create mode 100644 types/lzma-native/tsconfig.json create mode 100644 types/lzma-native/tslint.json diff --git a/types/lzma-native/index.d.ts b/types/lzma-native/index.d.ts new file mode 100644 index 0000000000..2581f4dc65 --- /dev/null +++ b/types/lzma-native/index.d.ts @@ -0,0 +1,130 @@ +// Type definitions for lzma-native 4.0 +// Project: https://github.com/addaleax/lzma-native +// Definitions by: Evan Cameron +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +declare module "lzma-native" { + import { Stream } from "stream"; + export type LzmaOptions = { + synchronous?: boolean; + bufsize?: number; + memlimit?: number; + check?: Check; + preset?: Preset; + flags?: + | "TELL_NO_CHECK" + | "TELL_UNSUPPORTED_CHECK" + | "TELL_ANY_CHECK" + | "CONCATENATED"; + threads?: number; + blockSize?: number; + timeout?: number; + }; + + export type Check = + | "CHECK_CRC32" + | "CHECK_CRC64" + | "CHECK_NONE" + | "CHECK_SHA256"; + + export type Coders = + | "easyEncoder" + | "aloneDecoder" + | "rawEncoder" + | "autoDecoder" + | "aloneEncoder" + | "streamEncoder" + | "streamDecoder"; + + export type Preset = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; + + export type FileOptions = { + fileSize: number; + memlimit?: number; + read: ( + count: number, + offset: number, + cb: (err: any, buffer: Buffer) => void + ) => void; + }; + + export type StreamInfo = { + streamPadding: number; + memlimit: number; + streams: number; + blocks: number; + fileSize: number; + uncompressedSize: number; + checks: number; + }; + + export function createStream( + coder: Coders, + options?: LzmaOptions + ): JSLzmaStream; + + export function createCompressor(options?: LzmaOptions): JSLzmaStream; + export function createDecompressor(options?: LzmaOptions): JSLzmaStream; + export function crc32( + input: string, + encoding?: string, + previous?: number + ): string; + export function isXZ(buf: Buffer | string): boolean; + export function versionString(): string; + export function versionNumber(): number; + export function checkSize(check: Check): number; + export function easyDecoderMemusage(preset: Preset): number; + export function easyEncoderMemusage(preset: Preset): number; + export function rawDecoderMemusage(preset: Preset): number; + export function rawEncoderMemusage(preset: Preset): number; + + export function Compressor( + preset?: Preset, + options?: LzmaOptions + ): JSLzmaStream; + export function Decompressor(options?: LzmaOptions): JSLzmaStream; + + export function parseFileIndex( + options: FileOptions, + callback?: (err: any, info?: StreamInfo) => void + ): void; + export function parseFileIndexFD( + fileDescriptor: number, + callback?: (err: any, info?: StreamInfo) => void + ): void; + + export function compress( + buf: Buffer | string, + options?: LzmaOptions | Preset, + on_finish?: (result: Buffer) => void + ): void; + export function decompress( + buf: Buffer | string, + options?: LzmaOptions | Preset, + on_finish?: (result: Buffer) => void + ): void; + export function LZMA(): { + compress( + buf: Buffer | string, + mode: Preset, + on_finish: (result: Buffer) => void, + on_progress?: (progress: number) => void + ): void; + decompress( + buf: Buffer | string, + on_finish: (result: Buffer) => void, + on_progress?: (progress: number) => void + ): void; + }; + + export class JSLzmaStream extends Stream.Transform { + constructor(nativeStream: Stream, options: LzmaOptions); + bufsize(): number; + bufsize(size: number): void; + totalInt(): number; + totalOut(): number; + cleanUp(): void; + } +} diff --git a/types/lzma-native/lzma-native-tests.ts b/types/lzma-native/lzma-native-tests.ts new file mode 100644 index 0000000000..2b94092c00 --- /dev/null +++ b/types/lzma-native/lzma-native-tests.ts @@ -0,0 +1,55 @@ +import * as lzma from "lzma-native"; +import { CHECK_CRC32 } from "lzma-native"; +var fs = require("fs"); + +var compressor = lzma.createCompressor(); +var input = fs.createReadStream("tsconfig.json"); +var output = fs.createWriteStream("tsconfig.json.xz"); + +input.pipe(compressor).pipe(output); + +lzma.compress("Banana", undefined, function(result) { + console.log(result); // +}); + +lzma.compress("Bananas", 6, function(result) { + lzma.decompress(result, undefined, function(decompressedResult) { + console.log(decompressedResult.toString() == "Bananas"); + }); +}); + +lzma.LZMA().compress("Bananas", 4, function(result) { + lzma.LZMA().decompress(result, function(decompressedResult) { + console.log("Bananas" == decompressedResult.toString()); + }); +}); + +var compressor = lzma.Compressor(); + +process.stdin.pipe(compressor).pipe(process.stdout); +lzma.crc32("Banana"); // => 69690105 +lzma.checkSize("CHECK_SHA256"); // => 16 +lzma.checkSize("CHECK_CRC32"); // => 4 +lzma.easyDecoderMemusage(6); // => 8454192 +lzma.easyEncoderMemusage(6); // => 97620499 +lzma.versionString(); // => '5.2.3' +lzma.versionNumber(); // => 50020012 +lzma.isXZ("Banana"); // => false + +fs.open("test/hamlet.txt.xz", "r", function(err: string, fd: number) { + // handle error + lzma.parseFileIndexFD(fd, function(err, info) { + // handle error + if (err) { + console.log(err); + } + // do something with e.g. info.uncompressedSize + + fs.close(fd, function(err: any) { + /* handle error */ + if (err) { + console.log(err); + } + }); + }); +}); diff --git a/types/lzma-native/tsconfig.json b/types/lzma-native/tsconfig.json new file mode 100644 index 0000000000..524764224f --- /dev/null +++ b/types/lzma-native/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "strict": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "lzma-native-tests.ts"] +} diff --git a/types/lzma-native/tslint.json b/types/lzma-native/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/lzma-native/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 2607ff16899410f665872764468e0c17285edfb3 Mon Sep 17 00:00:00 2001 From: Evan Cameron Date: Fri, 2 Nov 2018 16:36:07 -0400 Subject: [PATCH 46/68] Fix lint errors --- types/lzma-native/index.d.ts | 215 ++++++++++++------------- types/lzma-native/lzma-native-tests.ts | 34 ++-- types/lzma-native/tsconfig.json | 5 +- 3 files changed, 128 insertions(+), 126 deletions(-) diff --git a/types/lzma-native/index.d.ts b/types/lzma-native/index.d.ts index 2581f4dc65..33165885da 100644 --- a/types/lzma-native/index.d.ts +++ b/types/lzma-native/index.d.ts @@ -2,129 +2,128 @@ // Project: https://github.com/addaleax/lzma-native // Definitions by: Evan Cameron // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// -declare module "lzma-native" { - import { Stream } from "stream"; - export type LzmaOptions = { - synchronous?: boolean; - bufsize?: number; - memlimit?: number; - check?: Check; - preset?: Preset; - flags?: - | "TELL_NO_CHECK" - | "TELL_UNSUPPORTED_CHECK" - | "TELL_ANY_CHECK" - | "CONCATENATED"; - threads?: number; - blockSize?: number; - timeout?: number; - }; +import { Stream } from "stream"; +export interface LzmaOptions { + synchronous?: boolean; + bufsize?: number; + memlimit?: number; + check?: Check; + preset?: Preset; + flags?: + | "TELL_NO_CHECK" + | "TELL_UNSUPPORTED_CHECK" + | "TELL_ANY_CHECK" + | "CONCATENATED"; + threads?: number; + blockSize?: number; + timeout?: number; +} - export type Check = - | "CHECK_CRC32" - | "CHECK_CRC64" - | "CHECK_NONE" - | "CHECK_SHA256"; +export type Check = + | "CHECK_CRC32" + | "CHECK_CRC64" + | "CHECK_NONE" + | "CHECK_SHA256"; - export type Coders = - | "easyEncoder" - | "aloneDecoder" - | "rawEncoder" - | "autoDecoder" - | "aloneEncoder" - | "streamEncoder" - | "streamDecoder"; +export type Coders = + | "easyEncoder" + | "aloneDecoder" + | "rawEncoder" + | "autoDecoder" + | "aloneEncoder" + | "streamEncoder" + | "streamDecoder"; - export type Preset = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; +export type Preset = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; - export type FileOptions = { - fileSize: number; - memlimit?: number; - read: ( - count: number, - offset: number, - cb: (err: any, buffer: Buffer) => void - ) => void; - }; +export interface FileOptions { + fileSize: number; + memlimit?: number; + read: ( + count: number, + offset: number, + cb: (err: any, buffer: Buffer) => void + ) => void; +} - export type StreamInfo = { - streamPadding: number; - memlimit: number; - streams: number; - blocks: number; - fileSize: number; - uncompressedSize: number; - checks: number; - }; +export interface StreamInfo { + streamPadding: number; + memlimit: number; + streams: number; + blocks: number; + fileSize: number; + uncompressedSize: number; + checks: number; +} - export function createStream( - coder: Coders, - options?: LzmaOptions - ): JSLzmaStream; +export function createStream( + coder: Coders, + options?: LzmaOptions +): JSLzmaStream; - export function createCompressor(options?: LzmaOptions): JSLzmaStream; - export function createDecompressor(options?: LzmaOptions): JSLzmaStream; - export function crc32( - input: string, - encoding?: string, - previous?: number - ): string; - export function isXZ(buf: Buffer | string): boolean; - export function versionString(): string; - export function versionNumber(): number; - export function checkSize(check: Check): number; - export function easyDecoderMemusage(preset: Preset): number; - export function easyEncoderMemusage(preset: Preset): number; - export function rawDecoderMemusage(preset: Preset): number; - export function rawEncoderMemusage(preset: Preset): number; +export function createCompressor(options?: LzmaOptions): JSLzmaStream; +export function createDecompressor(options?: LzmaOptions): JSLzmaStream; +export function crc32( + input: string, + encoding?: string, + previous?: number +): string; +export function isXZ(buf: Buffer | string): boolean; +export function versionString(): string; +export function versionNumber(): number; +export function checkSize(check: Check): number; +export function easyDecoderMemusage(preset: Preset): number; +export function easyEncoderMemusage(preset: Preset): number; +export function rawDecoderMemusage(preset: Preset): number; +export function rawEncoderMemusage(preset: Preset): number; - export function Compressor( - preset?: Preset, - options?: LzmaOptions - ): JSLzmaStream; - export function Decompressor(options?: LzmaOptions): JSLzmaStream; +export function Compressor( + preset?: Preset, + options?: LzmaOptions +): JSLzmaStream; +export function Decompressor(options?: LzmaOptions): JSLzmaStream; - export function parseFileIndex( - options: FileOptions, - callback?: (err: any, info?: StreamInfo) => void - ): void; - export function parseFileIndexFD( - fileDescriptor: number, - callback?: (err: any, info?: StreamInfo) => void - ): void; +export function parseFileIndex( + options: FileOptions, + callback?: (err: any, info?: StreamInfo) => void +): void; +export function parseFileIndexFD( + fileDescriptor: number, + callback?: (err: any, info?: StreamInfo) => void +): void; - export function compress( +export function compress( + buf: Buffer | string, + options?: LzmaOptions | Preset, + on_finish?: (result: Buffer) => void +): void; +export function decompress( + buf: Buffer | string, + options?: LzmaOptions | Preset, + on_finish?: (result: Buffer) => void +): void; +export function LZMA(): { + compress( buf: Buffer | string, - options?: LzmaOptions | Preset, - on_finish?: (result: Buffer) => void + mode: Preset, + on_finish: (result: Buffer) => void, + on_progress?: (progress: number) => void ): void; - export function decompress( + decompress( buf: Buffer | string, - options?: LzmaOptions | Preset, - on_finish?: (result: Buffer) => void + on_finish: (result: Buffer) => void, + on_progress?: (progress: number) => void ): void; - export function LZMA(): { - compress( - buf: Buffer | string, - mode: Preset, - on_finish: (result: Buffer) => void, - on_progress?: (progress: number) => void - ): void; - decompress( - buf: Buffer | string, - on_finish: (result: Buffer) => void, - on_progress?: (progress: number) => void - ): void; - }; +}; - export class JSLzmaStream extends Stream.Transform { - constructor(nativeStream: Stream, options: LzmaOptions); - bufsize(): number; - bufsize(size: number): void; - totalInt(): number; - totalOut(): number; - cleanUp(): void; - } +export class JSLzmaStream extends Stream.Transform { + constructor(nativeStream: Stream, options: LzmaOptions); + bufsize(): number; + bufsize(size: number): void; + totalInt(): number; + totalOut(): number; + cleanUp(): void; } diff --git a/types/lzma-native/lzma-native-tests.ts b/types/lzma-native/lzma-native-tests.ts index 2b94092c00..44a5eab221 100644 --- a/types/lzma-native/lzma-native-tests.ts +++ b/types/lzma-native/lzma-native-tests.ts @@ -1,32 +1,31 @@ import * as lzma from "lzma-native"; -import { CHECK_CRC32 } from "lzma-native"; -var fs = require("fs"); +import * as fs from "fs"; -var compressor = lzma.createCompressor(); -var input = fs.createReadStream("tsconfig.json"); -var output = fs.createWriteStream("tsconfig.json.xz"); +const compressor = lzma.createCompressor(); +const input = fs.createReadStream("tsconfig.json"); +const output = fs.createWriteStream("tsconfig.json.xz"); input.pipe(compressor).pipe(output); -lzma.compress("Banana", undefined, function(result) { +lzma.compress("Banana", undefined, result => { console.log(result); // }); -lzma.compress("Bananas", 6, function(result) { - lzma.decompress(result, undefined, function(decompressedResult) { - console.log(decompressedResult.toString() == "Bananas"); +lzma.compress("Bananas", 6, result => { + lzma.decompress(result, undefined, decompressedResult => { + console.log(decompressedResult.toString() === "Bananas"); }); }); -lzma.LZMA().compress("Bananas", 4, function(result) { - lzma.LZMA().decompress(result, function(decompressedResult) { - console.log("Bananas" == decompressedResult.toString()); +lzma.LZMA().compress("Bananas", 4, result => { + lzma.LZMA().decompress(result, decompressedResult => { + console.log("Bananas" === decompressedResult.toString()); }); }); -var compressor = lzma.Compressor(); +const comp = lzma.Compressor(); -process.stdin.pipe(compressor).pipe(process.stdout); +process.stdin.pipe(comp).pipe(process.stdout); lzma.crc32("Banana"); // => 69690105 lzma.checkSize("CHECK_SHA256"); // => 16 lzma.checkSize("CHECK_CRC32"); // => 4 @@ -36,16 +35,17 @@ lzma.versionString(); // => '5.2.3' lzma.versionNumber(); // => 50020012 lzma.isXZ("Banana"); // => false -fs.open("test/hamlet.txt.xz", "r", function(err: string, fd: number) { +fs.open("test/hamlet.txt.xz", "r", (err: any, fd: number) => { + if (err) return; // handle error - lzma.parseFileIndexFD(fd, function(err, info) { + lzma.parseFileIndexFD(fd, (err, info) => { // handle error if (err) { console.log(err); } // do something with e.g. info.uncompressedSize - fs.close(fd, function(err: any) { + fs.close(fd, (err: any) => { /* handle error */ if (err) { console.log(err); diff --git a/types/lzma-native/tsconfig.json b/types/lzma-native/tsconfig.json index 524764224f..fa7667f123 100644 --- a/types/lzma-native/tsconfig.json +++ b/types/lzma-native/tsconfig.json @@ -2,7 +2,10 @@ "compilerOptions": { "module": "commonjs", "lib": ["es6"], - "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noImplicitThis": true, "baseUrl": "../", "typeRoots": ["../"], "types": [], From 7f58de6fb2c248e0347d539b31dcfa4687bfec05 Mon Sep 17 00:00:00 2001 From: g1eny0ung Date: Sat, 3 Nov 2018 12:37:04 +0800 Subject: [PATCH 47/68] Add alert prop's types --- types/react-alert/index.d.ts | 73 +++++++++++++++++++++++-- types/react-alert/react-alert-tests.tsx | 14 +++-- 2 files changed, 76 insertions(+), 11 deletions(-) diff --git a/types/react-alert/index.d.ts b/types/react-alert/index.d.ts index cbc48d247f..6c94da77b0 100644 --- a/types/react-alert/index.d.ts +++ b/types/react-alert/index.d.ts @@ -17,18 +17,81 @@ export type AlertPosition = export type AlertType = 'info' | 'success' | 'error'; export type AlertTransition = 'fade' | 'scale'; -export interface ProviderProps { +export interface ProviderOptions { + /** + * The margin of each alert + * + * Default value: '10px' + */ offset?: string; + /** + * The position of the alerts in the page + * + * Default value: 'top center' + */ position?: AlertPosition; + /** + * Timeout to alert remove itself, if set to 0 it never removes itself + * + * Default value: 0 + */ timeout?: number; + /** + * The default alert type used when calling this.props.alert.show + * + * Default value: 'info' + */ type?: AlertType; + /** + * The transition animation + * + * Default value: 'fade' + */ transition?: AlertTransition; + /** + * The z-index of alerts + * + * Default value: 100 + */ zIndex?: number; - template: React.ComponentType; } -export class Provider extends React.Component {} +export class Provider extends React.Component {} -export const Alert: React.Consumer; +export const Alert: React.Consumer; -export function withAlert

(c: React.ComponentType

): React.ComponentType

; +export interface AlertCustomOptions { + /** + * Custom timeout just for this one alert + */ + timeout?: number; + /** + * Callback that will be executed after this alert open + */ + onOpen?(): undefined; + /** + * Callback that will be executed after this alert is removed + */ + onClose?(): undefined; +} + +export interface AlertCustomOptionsWithType extends AlertCustomOptions { + type?: AlertType; +} + +export interface InjectedAlertProp { + show( + message?: string, + options?: AlertCustomOptionsWithType + ): InjectedAlertProp; + remove(alert: InjectedAlertProp): undefined; + success(message?: string, options?: AlertCustomOptions): InjectedAlertProp; + error(message?: string, options?: AlertCustomOptions): InjectedAlertProp; + info(message?: string, options?: AlertCustomOptions): InjectedAlertProp; +} + +export function withAlert

( + c: React.ComponentType

+): React.ComponentType>>; diff --git a/types/react-alert/react-alert-tests.tsx b/types/react-alert/react-alert-tests.tsx index d421d8cc88..c6088a52a8 100644 --- a/types/react-alert/react-alert-tests.tsx +++ b/types/react-alert/react-alert-tests.tsx @@ -4,10 +4,12 @@ import { Alert, withAlert, AlertPosition, - AlertTransition + AlertTransition, + ProviderOptions, + InjectedAlertProp } from 'react-alert'; -class AppWithoutAlert extends React.Component { +class AppWithoutAlert extends React.Component<{ alert: InjectedAlertProp }> { render() { return (