From 63cb83efaff90030108171a5fd5cdf10efae209e Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Tue, 8 Aug 2017 19:41:28 -0400 Subject: [PATCH 01/12] Add htmlbars-inline-precompile definition. --- .../htmlbars-inline-precompile-tests.ts | 3 +++ types/htmlbars-inline-precompile/index.d.ts | 13 +++++++++++ .../htmlbars-inline-precompile/tsconfig.json | 22 +++++++++++++++++++ types/htmlbars-inline-precompile/tslint.json | 1 + 4 files changed, 39 insertions(+) create mode 100644 types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts create mode 100644 types/htmlbars-inline-precompile/index.d.ts create mode 100644 types/htmlbars-inline-precompile/tsconfig.json create mode 100644 types/htmlbars-inline-precompile/tslint.json diff --git a/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts b/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts new file mode 100644 index 0000000000..1fa13cd72f --- /dev/null +++ b/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts @@ -0,0 +1,3 @@ +import hbs from 'htmlbars-inline-precompile'; + +hbs`this is allowed`; diff --git a/types/htmlbars-inline-precompile/index.d.ts b/types/htmlbars-inline-precompile/index.d.ts new file mode 100644 index 0000000000..f8bf17f3ea --- /dev/null +++ b/types/htmlbars-inline-precompile/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for htmlbars-inline-precompile 1.0 +// Project: ember-cli-htmlbars-inline-precompile +// Definitions by: Chris Krycho +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// This is a bit of a funky one: it's from a [Babel plugin], but is exported for +// Ember applications as the module `"htmlbars-incline-precompile"`. It acts +// like a tagged string from the perspective of consumers, but is actually an +// AST transformation which generates a function as its output. +// +// [Babel plugin]: https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile#babel-plugin-htmlbars-inline-precompile- + +export default function hbs(tagged: TemplateStringsArray): () => {}; diff --git a/types/htmlbars-inline-precompile/tsconfig.json b/types/htmlbars-inline-precompile/tsconfig.json new file mode 100644 index 0000000000..32ad3d22fb --- /dev/null +++ b/types/htmlbars-inline-precompile/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "htmlbars-inline-precompile-tests.ts" + ] +} diff --git a/types/htmlbars-inline-precompile/tslint.json b/types/htmlbars-inline-precompile/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/htmlbars-inline-precompile/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 0527bc3489bd1a4f1e33de059690f1b3551a25dd Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Tue, 8 Aug 2017 20:18:00 -0400 Subject: [PATCH 02/12] Fix typo in htmlbars-inline-precompile comments. --- types/htmlbars-inline-precompile/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/htmlbars-inline-precompile/index.d.ts b/types/htmlbars-inline-precompile/index.d.ts index f8bf17f3ea..31e21b2576 100644 --- a/types/htmlbars-inline-precompile/index.d.ts +++ b/types/htmlbars-inline-precompile/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // This is a bit of a funky one: it's from a [Babel plugin], but is exported for -// Ember applications as the module `"htmlbars-incline-precompile"`. It acts +// Ember applications as the module `"htmlbars-inline-precompile"`. It acts // like a tagged string from the perspective of consumers, but is actually an // AST transformation which generates a function as its output. // From 66f2c7e249c6c7b2734247ab7a32747dfaf6e86e Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Tue, 8 Aug 2017 20:56:08 -0400 Subject: [PATCH 03/12] Update htmlbars-inline-precompile given Ember `this.render()`. --- .../htmlbars-inline-precompile-tests.ts | 4 +++- types/htmlbars-inline-precompile/index.d.ts | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts b/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts index 1fa13cd72f..3a8d722db6 100644 --- a/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts +++ b/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts @@ -1,3 +1,5 @@ import hbs from 'htmlbars-inline-precompile'; -hbs`this is allowed`; +const likeThisDotRender = (s: string | Array) => {}; + +likeThisDotRender(hbs`this is allowed`); diff --git a/types/htmlbars-inline-precompile/index.d.ts b/types/htmlbars-inline-precompile/index.d.ts index 31e21b2576..db03d2fad1 100644 --- a/types/htmlbars-inline-precompile/index.d.ts +++ b/types/htmlbars-inline-precompile/index.d.ts @@ -6,8 +6,11 @@ // This is a bit of a funky one: it's from a [Babel plugin], but is exported for // Ember applications as the module `"htmlbars-inline-precompile"`. It acts // like a tagged string from the perspective of consumers, but is actually an -// AST transformation which generates a function as its output. +// AST transformation which generates a function as its output. That function in +// turn [generates a string or array of strings][output] to use with the Ember +// testing helper `this.render()`. // // [Babel plugin]: https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile#babel-plugin-htmlbars-inline-precompile- +// [output]: https://github.com/emberjs/ember-test-helpers/blob/77f9a53da9d8c19a85b3122788caadbcc59274c2/lib/ember-test-helpers/-legacy-overrides.js#L17-L42 -export default function hbs(tagged: TemplateStringsArray): () => {}; +export default function hbs(tagged: TemplateStringsArray): string | Array; From 503c81ae213b63712bec94fc07c0977667cdddf2 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Tue, 8 Aug 2017 20:59:01 -0400 Subject: [PATCH 04/12] Fix array lint in htmlbars-inline-precompile. --- .../htmlbars-inline-precompile-tests.ts | 2 +- types/htmlbars-inline-precompile/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts b/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts index 3a8d722db6..c8adb26d1a 100644 --- a/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts +++ b/types/htmlbars-inline-precompile/htmlbars-inline-precompile-tests.ts @@ -1,5 +1,5 @@ import hbs from 'htmlbars-inline-precompile'; -const likeThisDotRender = (s: string | Array) => {}; +const likeThisDotRender = (s: string | string[]) => {}; likeThisDotRender(hbs`this is allowed`); diff --git a/types/htmlbars-inline-precompile/index.d.ts b/types/htmlbars-inline-precompile/index.d.ts index db03d2fad1..21bbe63545 100644 --- a/types/htmlbars-inline-precompile/index.d.ts +++ b/types/htmlbars-inline-precompile/index.d.ts @@ -13,4 +13,4 @@ // [Babel plugin]: https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile#babel-plugin-htmlbars-inline-precompile- // [output]: https://github.com/emberjs/ember-test-helpers/blob/77f9a53da9d8c19a85b3122788caadbcc59274c2/lib/ember-test-helpers/-legacy-overrides.js#L17-L42 -export default function hbs(tagged: TemplateStringsArray): string | Array; +export default function hbs(tagged: TemplateStringsArray): string | string[]; From b102312ac99faed18dde95f5b5cca898625398d4 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Wed, 9 Aug 2017 13:41:47 -0400 Subject: [PATCH 05/12] Change project to URL for htmlbars-inline-precompile. --- types/htmlbars-inline-precompile/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/htmlbars-inline-precompile/index.d.ts b/types/htmlbars-inline-precompile/index.d.ts index 21bbe63545..ab4bf9a1b7 100644 --- a/types/htmlbars-inline-precompile/index.d.ts +++ b/types/htmlbars-inline-precompile/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for htmlbars-inline-precompile 1.0 -// Project: ember-cli-htmlbars-inline-precompile +// Project: https://github.com/ember-cli/ember-cli-htmlbars-inline-precompile // Definitions by: Chris Krycho // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From baacececc1cdd340e0a8585effaec3f0c060d224 Mon Sep 17 00:00:00 2001 From: Martin Donkersloot Date: Tue, 15 Aug 2017 21:36:07 +0200 Subject: [PATCH 06/12] TelegramBot now properly extends EventEmitter. --- types/node-telegram-bot-api/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/node-telegram-bot-api/index.d.ts b/types/node-telegram-bot-api/index.d.ts index 1a7d15ec34..a727e6f3c4 100644 --- a/types/node-telegram-bot-api/index.d.ts +++ b/types/node-telegram-bot-api/index.d.ts @@ -3,8 +3,11 @@ // Definitions by: Alex Muench // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 +/// -declare class TelegramBot { +import { EventEmitter } from 'events'; + +declare class TelegramBot extends EventEmitter { constructor(token: string, opts?: any); startPolling(options?: any): Promise; From 9a94ceb5cd148bc9d608dc782a9b9213f2a2d073 Mon Sep 17 00:00:00 2001 From: Matt Bishop Date: Tue, 15 Aug 2017 17:24:52 -0700 Subject: [PATCH 07/12] Add type definition for js.spec --- types/js.spec/index.d.ts | 330 +++++++++++++++++++++++++++++++++ types/js.spec/js.spec-tests.ts | 87 +++++++++ types/js.spec/tsconfig.json | 20 ++ types/js.spec/tslint.json | 1 + 4 files changed, 438 insertions(+) create mode 100644 types/js.spec/index.d.ts create mode 100644 types/js.spec/js.spec-tests.ts create mode 100644 types/js.spec/tsconfig.json create mode 100644 types/js.spec/tslint.json diff --git a/types/js.spec/index.d.ts b/types/js.spec/index.d.ts new file mode 100644 index 0000000000..b33a0fd475 --- /dev/null +++ b/types/js.spec/index.d.ts @@ -0,0 +1,330 @@ +// Type definitions for js.spec 1.0 +// Project: http://js-spec.online +// Definitions by: Matt Bishop +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/** + * A Spec provides a predicate that can test a value for conformance. + */ +export interface Spec { + /** + * The name of the spec, displayed in explain() results. + */ + readonly name: string; + + /** + * Data necessary to check values for conformity. + */ + readonly options: object; + + /** + * Returns the conformed value to this spec. + * @param value the value to test for conformance + * @returns {symbol.invalid} if the value does not conform to the spec, or the value if it does. + */ + conform(value: any): any; + + /** + * Explain why a value does not conform to this spec. + * @param value the value to examine + * @returns {Problem[]} list of problems or null if none + */ + explain(value: any): Problem[]; +} + +/** + * A Spec with a boolean conform function. Test the value and return true if it conforms. + */ +export interface Predicate extends Spec { + (value: any): boolean; +} + +/** + * An explanation of why a part of a value does not conform to a spec. + */ +export interface Problem { + /** + * The path to the value. + */ + readonly path: string[]; + + /** + * Pth to he Spec that applies. + */ + readonly via: string[]; + + /** + * The value associated with the problem. + */ + readonly value: any; + + /** + * A predicate function to test new values for conformance. + */ + readonly predicate: Predicate; +} + +/** + * Given a Spec, tests the value for confomrance. If it passes, then returns true. + * @param {Spec} spec the spec to test with + * @param value the value to test + * @returns {boolean} true if valid + */ +export function valid(spec: Spec, value: any): boolean; + +/** + * Returns the conformed value to this spec. + * @param {Spec} spec the spec to test with + * @param value the value to test + * @returns {symbol.invalid} if the value does not conform to the spec, or the conformed value if it does. + */ +export function conform(spec: Spec, value: any): any; + +/** + * Like explain(), but returns Problems array. + * @param {Spec} spec the spec to test with + * @param value the value to test + * @returns {Problem[]} list of problems or null if none + */ +export function explainData(spec: Spec, value: any): Problem[]; + +/** + * Prints, to the console, reasons why the value did not conform to this spec. + * @param {Spec} spec the spec to test with + * @param value the value to test + */ +export function explain(spec: Spec, value: any): void; + +/** + * Returns a multiline string with reasons why the value did not conform to this spec. + * @param {Spec} spec the spec to test with + * @param value the value to test + */ +export function explainStr(spec: Spec, value: any): string; + +/** + * Tests if a value conforms to a spec, and if not, throws an Error. + * @param {Spec} spec the spec to test with + * @param value the value to test + */ +export function assert(spec: Spec, value: any): void; + +export namespace symbol { + /** + * Returned by conform() to indicate a value does not conform to a spec. + */ + const invalid: symbol; + + /** + * Used as an option in collection() to specify the size of a collection. + */ + const count: symbol; + + /** + * Used as an option in collection() to specify the maximum size of a collection. + */ + const maxCount: symbol; + + /** + * Used as an option in collection() to specify the minimum size of a collection. + */ + const minCount: symbol; + + /** + * Used as an option in map() to specify a key spec that is optional. + */ + const optional: symbol; +} + +export namespace spec { + /** + * Predicate function definition to describe non-spec predicate functions. + */ + type PredFn = (value: any) => boolean; + + /** + * Defins an input to a spec. Can be a Spec instance or a predicate function. + */ + type SpecInput = PredFn | Spec; + + /** + * Data must conform to every provided spec. + * @param {string} name the name of the spec + * @param {spec.SpecInput} specs the array of specs that must all match + * @returns {Spec} the constructed Spec + */ + function and(name: string, ...specs: SpecInput[]): Spec; + + /** + * Data must conform to at least one provided spec. The order in which they are validated is not defined. + * The conform() function returns matched branches along with input data. + * @param {string} name the name of the spec + * @param {object} alts map of alternative keys with their respective SpecInputs + * @returns {Spec} the constructed Spec + */ + function or(name: string, alts: {[key: string]: SpecInput}): Spec; + + /** + * By default no spec accepts null or undefined as valid input. Wrap your spec in nilable() to change this. + * @param {string} name the name of the spec + * @param {spec.SpecInput} spec the spec to apply if a value is non-nil + * @returns {Spec} the constructed spec + */ + function nilable(name: string, spec: SpecInput): Spec; + + // Cannot specify 'symbol' as a key type: https://github.com/Microsoft/TypeScript/issues/7660 + /** + * Used to define collections with items of the same type. Works with Arrays and Sets. + * Accepts an option map as optional second parameter. + * NOTE: the keys in this option map are symbols but Typescript will not allow 'symbol' to be specified + * as a key type but the TS compiler will allow it. + * @param {string} name the name of the spec + * @param {spec.SpecInput} spec the spec to apply to values in the collection + * @param {object} options symbol.count or symbol.minCount / symbol.maxCount + * @returns {Spec} + */ + function collection(name: string, spec: SpecInput, options?: {[option: string]: number}): Spec; + + /** + * Used to define collections with items of possibly different types. Works only with arrays as order is important. + * @param {string} name the name of the spec + * @param {spec.SpecInput} specs the specs to test the value array + * @returns {Spec} the constructed spec + */ + function tuple(name: string, ...specs: SpecInput[]): Spec; + + /** + * Used to define the shape of maps. By default all keys are required. Use {symbol.optional} key to define + * optional keys. Shape map can contain nested key specs. + * @param {string} name the name of the spec + * @param {Object} shape the shape map with keys and associated specs + * @returns {Spec} the constructed spec + */ + function map(name: string, shape: object): Spec; + + /** + * Used to define "one out of these values", like an enum. (It's called oneOf because enum is a reserved word.) + * @param {string} name the name of the spec + * @param values the emum of values + * @returns {Spec} the constructed spec + */ + function oneOf(name: string, ...values: any[]): Spec; + + // Predicates + /** + * Returns true if data is an integer. + */ + const int: Predicate; + + /** + * Returns true if data is an integer. + */ + const integer: Predicate; + + /** + * Returns true if data is a finite number. + */ + const finite: Predicate; + + /** + * Returns true if data is a number (can be double or integer). + */ + const number: Predicate; + + /** + * Returns true if data is an odd number. + */ + const odd: Predicate; + + /** + * Returns true if data is an even number. + */ + const even: Predicate; + + /** + * Returns true if data is a number greater than zero. + */ + const positive: Predicate; + + /** + * Returns true if data is a number smaller than zero. + */ + const negative: Predicate; + + /** + * Returns true if data is the number zero. + * Why: To easily construct specs for >= 0. + */ + const zero: Predicate; + + /** + * Returns true if data is a string. + */ + const str: Predicate; + + /** + * Returns true if data is a string. + */ + const string: Predicate; + + /** + * Returns true if data is a function. + */ + const fn: Predicate; + + /** + * Returns true if data is a Symbol. + */ + const sym: Predicate; + + /** + * Returns true if data is a Symbol. + */ + const symbol: Predicate; + + /** + * Returns true if data is null or undefined. + */ + const nil: Predicate; + + /** + * Returns true if data is a boolean. + */ + const bool: Predicate; + + /** + * Returns true if data is a boolean. + */ + const boolean: Predicate; + + /** + * Returns true if data is a Date. + */ + const date: Predicate; + + /** + * Returns true if data is a plain object. + */ + const obj: Predicate; + + /** + * Returns true if data is a plain object. + */ + const object: Predicate; + + /** + * Returns true if data is an Array. + */ + const array: Predicate; + + /** + * Returns true if data is a Set. + */ + const set: Predicate; + + /** + * Returns true if data is an Array or Set. + */ + const coll: Predicate; +} diff --git a/types/js.spec/js.spec-tests.ts b/types/js.spec/js.spec-tests.ts new file mode 100644 index 0000000000..8bb9611e87 --- /dev/null +++ b/types/js.spec/js.spec-tests.ts @@ -0,0 +1,87 @@ +import * as S from "js.spec"; + +const spec: S.Spec = S.spec.bool; +const c: symbol = spec.conform("water"); +const waterProblems: S.Problem[] = spec.explain("water"); +const name: string = spec.name; +const options: object = spec.options; + +const isValid: boolean = S.valid(S.spec.boolean, true); + +const result = S.conform(S.spec.map("dancing", {field: S.spec.string}), "not a map"); + +const problems: S.Problem[] = S.explainData(S.spec.int, "not a number"); + +const {path, via, value, predicate}: {path: string[], via: string[], value: any, predicate: S.Predicate} = problems[0]; + +const problemStr: string = S.explainStr(S.spec.even, 3); + +// $ExpectType void +S.explain(S.spec.positive, true); + +// $ExpectType void +S.assert(S.spec.string, "things"); + +const symbols: symbol[] = [S.symbol.count, S.symbol.invalid, S.symbol.maxCount, S.symbol.minCount, S.symbol.optional]; + +const orSpec: S.Spec = S.spec.or("or test", { ball: (value: any) => value === "whale", fish: S.spec.number }); + +const nilableSpec: S.Spec = S.spec.nilable("nilable test", (value: any) => false); + +const collectionSpec: S.Spec = S.spec.collection("collection test", S.spec.positive); + +const collection2Spec: S.Spec = S.spec.collection("collection test", S.spec.string, {[S.symbol.count]: 3}); + +const tupleSpec: S.Spec = S.spec.tuple("tuple test", S.spec.bool, S.spec.date, S.spec.array); + +const mapSpec: S.Spec = S.spec.map("map test", { email: S.spec.string, [S.symbol.optional]: { name: S.spec.string } }); + +const oneOfSpec: S.Spec = S.spec.oneOf("oneOf test", "a", "b", "c"); + +// Predicates + +const intPred: S.Predicate = S.spec.int; + +const integerPred: S.Predicate = S.spec.integer; + +const finitePred: S.Predicate = S.spec.finite; + +const numberPred: S.Predicate = S.spec.number; + +const oddPred: S.Predicate = S.spec.odd; + +const evenPred: S.Predicate = S.spec.even; + +const positivePred: S.Predicate = S.spec.positive; + +const negativePred: S.Predicate = S.spec.negative; + +const zeroPred: S.Predicate = S.spec.zero; + +const strPred: S.Predicate = S.spec.str; + +const stringPred: S.Predicate = S.spec.string; + +const fnPred: S.Predicate = S.spec.fn; + +const symPred: S.Predicate = S.spec.sym; + +const symbolPred: S.Predicate = S.spec.symbol; + +const nilPred: S.Predicate = S.spec.nil; + +const boolPred: S.Predicate = S.spec.bool; + +const booleanPred: S.Predicate = S.spec.boolean; + +const datePred: S.Predicate = S.spec.date; + +const objPred: S.Predicate = S.spec.obj; + +const objectPred: S.Predicate = S.spec.object; + +const arrayPred: S.Predicate = S.spec.array; + +const setPred: S.Predicate = S.spec.set; + +const collPred: S.Predicate = S.spec.coll; diff --git a/types/js.spec/tsconfig.json b/types/js.spec/tsconfig.json new file mode 100644 index 0000000000..b3afe65da2 --- /dev/null +++ b/types/js.spec/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "js.spec-tests.ts" + ] +} diff --git a/types/js.spec/tslint.json b/types/js.spec/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/js.spec/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file From d4df9bedaf9b13a0dcb8d78b122587479d7be993 Mon Sep 17 00:00:00 2001 From: Martin Donkersloot Date: Thu, 17 Aug 2017 20:12:28 +0200 Subject: [PATCH 08/12] Added new functions, narrowed down and updated parameters of existing functions. --- types/node-telegram-bot-api/index.d.ts | 34 +++++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/types/node-telegram-bot-api/index.d.ts b/types/node-telegram-bot-api/index.d.ts index a727e6f3c4..6eeeabe3f2 100644 --- a/types/node-telegram-bot-api/index.d.ts +++ b/types/node-telegram-bot-api/index.d.ts @@ -6,6 +6,7 @@ /// import { EventEmitter } from 'events'; +import { Stream } from "stream"; declare class TelegramBot extends EventEmitter { constructor(token: string, opts?: any); @@ -26,27 +27,38 @@ declare class TelegramBot extends EventEmitter { sendMessage(chatId: number | string, text: string, options?: any): Promise; answerInlineQuery(inlineQueryId: string, results: any[], options?: any): Promise; forwardMessage(chatId: number | string, fromChatId: number | string, messageId: number | string, options?: any): Promise; - sendPhoto(chatId: number | string, photo: any, options?: any): Promise; - sendAudio(chatId: number | string, audio: any, options?: any): Promise; - sendDocument(chatId: number | string, doc: any, options?: any, fileOpts?: any): Promise; - sendSticker(chatId: number | string, sticker: any, options?: any): Promise; - sendVideo(chatId: number | string, video: any, options?: any): Promise; - sendVoice(chatId: number | string, voice: any, options?: any): Promise; + sendPhoto(chatId: number | string, photo: string | Stream | Buffer, options?: any): Promise; + sendAudio(chatId: number | string, audio: string | Stream | Buffer, options?: any): Promise; + sendDocument(chatId: number | string, doc: string | Stream | Buffer, options?: any, fileOpts?: any): Promise; + sendSticker(chatId: number | string, sticker: string | Stream | Buffer, options?: any): Promise; + sendVideo(chatId: number | string, video: string | Stream | Buffer, options?: any): Promise; + sendVideoNote(chatId: number | string, videoNote: string | Stream | Buffer, options?: any): Promise; + sendVoice(chatId: number | string, voice: string | Stream | Buffer, options?: any): Promise; sendChatAction(chatId: number | string, action: string): Promise; kickChatMember(chatId: number | string, userId: string): Promise; unbanChatMember(chatId: number | string, userId: string): Promise; - answerCallbackQuery(callbackQueryId: number | string, text: string, showAlert: boolean, options?: any): Promise; + restrictChatMember(chatId: number | string, userId: string, options?: any): Promise; + promoteChatMember(chatId: number | string, userId: string, options?: any): Promise; + exportChatInviteLink(chatId: number | string): Promise; + sendChatPhoto(chatId: number | string, photo: string | Stream | Buffer): Promise; + deleteChatPhoto(chatId: number | string): Promise; + setChatTitle(chatId: number | string, title: string): Promise; + setChatDescription(chatId: number | string, description: string): Promise; + pinChatMessage(chatId: number | string, messageId: string): Promise; + unpinChatMessage(chatId: number | string): Promise; + answerCallbackQuery(options?: any): Promise; editMessageText(text: string, options?: any): Promise; editMessageCaption(caption: string, options?: any): Promise; editMessageReplyMarkup(replyMarkup: any, options?: any): Promise; - getUserProfilePhotos(userId: string, options?: any): Promise; + getUserProfilePhotos(userId: number | string, options?: any): Promise; sendLocation(chatId: number | string, latitude: number, longitude: number, options?: any): Promise; sendVenue(chatId: number | string, latitude: number, longitude: number, title: string, address: string, options?: any): Promise; sendContact(chatId: number | string, phoneNumber: string, firstName: string, options?: any): Promise; getFile(fileId: string): Promise; getFileLink(fileId: string): Promise; downloadFile(fileId: string, downloadDir: string): Promise; - onText(regexp: any, callback: ((msg: any, match: any[]) => void)): void; + onText(regexp: RegExp, callback: ((msg: any, match: any[]) => void)): void; + removeTextListener(regexp: RegExp): any; onReplyToMessage(chatId: number | string, messageId: number | string, callback: ((msg: any) => void)): number; removeReplyListener(replyListenerId: number): any; getChat(chatId: number | string): Promise; @@ -57,6 +69,10 @@ declare class TelegramBot extends EventEmitter { sendGame(chatId: number | string, gameShortName: string, options?: any): Promise; setGameScore(userId: string, score: number, options?: any): Promise; getGameHighScores(userId: string, options?: any): Promise; + deleteMessage(chatId: string, messageId: string, options?: any): Promise; + sendInvoice(chatId: number | string, title: string, description: string, payload: string, providerToken: string, startParameter: string, currency: string, prices: any[], options?: any): Promise; + answerShippingQuery(shippingQueryId: string, ok: boolean, options?: any): Promise; + answerPreCheckoutQuery(preCheckoutQueryId: string, ok: boolean, options?: any): Promise; } export = TelegramBot; From 9324608ea446195c319abd774fdf655ac8af474a Mon Sep 17 00:00:00 2001 From: Martin Donkersloot Date: Thu, 17 Aug 2017 20:24:30 +0200 Subject: [PATCH 09/12] Updated tests. --- types/node-telegram-bot-api/index.d.ts | 2 +- .../node-telegram-bot-api-tests.ts | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/types/node-telegram-bot-api/index.d.ts b/types/node-telegram-bot-api/index.d.ts index 6eeeabe3f2..f163f485be 100644 --- a/types/node-telegram-bot-api/index.d.ts +++ b/types/node-telegram-bot-api/index.d.ts @@ -69,7 +69,7 @@ declare class TelegramBot extends EventEmitter { sendGame(chatId: number | string, gameShortName: string, options?: any): Promise; setGameScore(userId: string, score: number, options?: any): Promise; getGameHighScores(userId: string, options?: any): Promise; - deleteMessage(chatId: string, messageId: string, options?: any): Promise; + deleteMessage(chatId: number | string, messageId: string, options?: any): Promise; sendInvoice(chatId: number | string, title: string, description: string, payload: string, providerToken: string, startParameter: string, currency: string, prices: any[], options?: any): Promise; answerShippingQuery(shippingQueryId: string, ok: boolean, options?: any): Promise; answerPreCheckoutQuery(preCheckoutQueryId: string, ok: boolean, options?: any): Promise; diff --git a/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts b/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts index 80b44216fb..70482a7b38 100644 --- a/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts +++ b/types/node-telegram-bot-api/node-telegram-bot-api-tests.ts @@ -23,11 +23,21 @@ MyTelegramBot.sendAudio(1234, "audio/path", { foo: "bar" }); MyTelegramBot.sendDocument(1234, "doc/path", { foo: "bar" }, { fileOption: true }); MyTelegramBot.sendSticker(1234, "sticker/path", { foo: "bar" }); MyTelegramBot.sendVideo(1234, "video/path", { foo: "bar" }); +MyTelegramBot.sendVideoNote(1234, "video/path", { foo: "bar" }); MyTelegramBot.sendVoice(1234, "voice/path", { foo: "bar" }); MyTelegramBot.sendChatAction(1234, "ACTION!"); MyTelegramBot.kickChatMember(1234, "myUserID"); MyTelegramBot.unbanChatMember(1234, "myUserID"); -MyTelegramBot.answerCallbackQuery("myCallbackQueryID", "test-text", false, { foo: "bar" }); +MyTelegramBot.restrictChatMember(1234, 'myUserID', { foo: "bar" }); +MyTelegramBot.promoteChatMember(1234, 'myUserID', { foo: "bar" }); +MyTelegramBot.exportChatInviteLink(1234); +MyTelegramBot.sendChatPhoto(1234, "My/File/ID"); +MyTelegramBot.deleteChatPhoto(1234); +MyTelegramBot.setChatTitle(1234, 'Chat Title'); +MyTelegramBot.setChatDescription(1234, 'Chat Description'); +MyTelegramBot.pinChatMessage(1234, 'Pinned Message'); +MyTelegramBot.unpinChatMessage(1234); +MyTelegramBot.answerCallbackQuery({ foo: "bar" }); MyTelegramBot.editMessageText("test-text", { foo: "bar" }); MyTelegramBot.editMessageCaption("My Witty Caption", { foo: "bar" }); MyTelegramBot.editMessageReplyMarkup({ replyMarkup: "something" }, { foo: "bar" }); @@ -39,6 +49,7 @@ MyTelegramBot.getFile("My/File/ID"); MyTelegramBot.getFileLink("My/File/ID"); MyTelegramBot.downloadFile("My/File/ID", "mydownloaddir/"); MyTelegramBot.onText(/regex/, (msg, match) => { }); +MyTelegramBot.removeTextListener(/regex/); MyTelegramBot.onReplyToMessage(1234, "mymessageID", (msg) => { }); MyTelegramBot.removeReplyListener(5466); MyTelegramBot.getChat(1234); @@ -49,3 +60,7 @@ MyTelegramBot.leaveChat(1234); MyTelegramBot.sendGame(1234, "MygameName", { foo: "bar" }); MyTelegramBot.setGameScore("myUserID", 99, { foo: "bar" }); MyTelegramBot.getGameHighScores("myUserID", { foo: "bar" }); +MyTelegramBot.deleteMessage(1234, 'mymessageID', { foo: "bar" }); +MyTelegramBot.sendInvoice(1234, 'Invoice Title', 'Invoice Description', 'Invoice Payload', 'Providertoken', 'Startparameter', 'Currency', [1, 2, 4], { foo: "bar" }); +MyTelegramBot.answerShippingQuery('shippingQueryId', true, { foo: "bar" }); +MyTelegramBot.answerPreCheckoutQuery('preCheckoutQueryId', true, { foo: "bar" }); From d6fc15c6240d88e1cee1555edad57a7a3a1f58c3 Mon Sep 17 00:00:00 2001 From: Martin Donkersloot Date: Thu, 17 Aug 2017 20:32:36 +0200 Subject: [PATCH 10/12] Updated version and contributors, made it lint-compliant. --- types/node-telegram-bot-api/index.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/types/node-telegram-bot-api/index.d.ts b/types/node-telegram-bot-api/index.d.ts index f163f485be..2b67bac385 100644 --- a/types/node-telegram-bot-api/index.d.ts +++ b/types/node-telegram-bot-api/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for node-telegram-bot-api 0.27 +// Type definitions for node-telegram-bot-api 0.28.0 // Project: https://github.com/yagop/node-telegram-bot-api // Definitions by: Alex Muench +// Agadar // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 /// @@ -70,7 +71,8 @@ declare class TelegramBot extends EventEmitter { setGameScore(userId: string, score: number, options?: any): Promise; getGameHighScores(userId: string, options?: any): Promise; deleteMessage(chatId: number | string, messageId: string, options?: any): Promise; - sendInvoice(chatId: number | string, title: string, description: string, payload: string, providerToken: string, startParameter: string, currency: string, prices: any[], options?: any): Promise; + sendInvoice(chatId: number | string, title: string, description: string, payload: string, providerToken: string, startParameter: string, + currency: string, prices: any[], options?: any): Promise; answerShippingQuery(shippingQueryId: string, ok: boolean, options?: any): Promise; answerPreCheckoutQuery(preCheckoutQueryId: string, ok: boolean, options?: any): Promise; } From 8302e13a9ce7c8e052aa1e4febd5c215440ac09b Mon Sep 17 00:00:00 2001 From: Martin Donkersloot Date: Thu, 17 Aug 2017 20:45:55 +0200 Subject: [PATCH 11/12] Added and fixed node-cleanup typings. --- types/node-cleanup/index.d.ts | 17 +++++++++++++++++ types/node-cleanup/node-cleanup-tests.ts | 13 +++++++++++++ types/node-cleanup/tsconfig.json | 22 ++++++++++++++++++++++ types/node-cleanup/tslint.json | 1 + types/node-telegram-bot-api/index.d.ts | 2 +- 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 types/node-cleanup/index.d.ts create mode 100644 types/node-cleanup/node-cleanup-tests.ts create mode 100644 types/node-cleanup/tsconfig.json create mode 100644 types/node-cleanup/tslint.json diff --git a/types/node-cleanup/index.d.ts b/types/node-cleanup/index.d.ts new file mode 100644 index 0000000000..103f0bc813 --- /dev/null +++ b/types/node-cleanup/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for node-cleanup 2.1 +// Project: https://github.com/jtlapp/node-cleanup +// Definitions by: Agadar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Note that ES6 modules cannot directly export callable functions. +// This file should be imported using the CommonJS-style: +// import nodeCleanup = require('node-cleanup'); + +export = install; + +declare function install(cleanupHandler?: ((exitCode: number | null, signal: string | null) => boolean | undefined), + stderrMessages?: { ctrl_C: string; uncaughtException: string }): void; + +declare namespace install { + function uninstall(): void; +} diff --git a/types/node-cleanup/node-cleanup-tests.ts b/types/node-cleanup/node-cleanup-tests.ts new file mode 100644 index 0000000000..ec42821dff --- /dev/null +++ b/types/node-cleanup/node-cleanup-tests.ts @@ -0,0 +1,13 @@ +import nodeCleanup = require('node-cleanup'); + +function cleanupHandler(exitCode: number | null, signal: string | null): boolean | undefined { + return true; +} +const stderrMessages = { ctrl_C: 'ctrl_c', uncaughtException: 'UncaughtException' }; + +nodeCleanup(); +nodeCleanup(cleanupHandler); +nodeCleanup(cleanupHandler, undefined); +nodeCleanup(cleanupHandler, stderrMessages); +nodeCleanup(undefined, stderrMessages); +nodeCleanup.uninstall(); diff --git a/types/node-cleanup/tsconfig.json b/types/node-cleanup/tsconfig.json new file mode 100644 index 0000000000..c05b3b90bf --- /dev/null +++ b/types/node-cleanup/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-cleanup-tests.ts" + ] +} diff --git a/types/node-cleanup/tslint.json b/types/node-cleanup/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/node-cleanup/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/node-telegram-bot-api/index.d.ts b/types/node-telegram-bot-api/index.d.ts index 2b67bac385..60b46b137c 100644 --- a/types/node-telegram-bot-api/index.d.ts +++ b/types/node-telegram-bot-api/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for node-telegram-bot-api 0.28.0 +// Type definitions for node-telegram-bot-api 0.28 // Project: https://github.com/yagop/node-telegram-bot-api // Definitions by: Alex Muench // Agadar From 9c3b2de1b6e0a371dc43381bb1bed4646d45a0a0 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 17 Aug 2017 15:55:53 -0700 Subject: [PATCH 12/12] datatables.net: Allow "search" to be a boolean (#19092) --- types/datatables.net/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/datatables.net/index.d.ts b/types/datatables.net/index.d.ts index 99a2aae7b8..8017017d8c 100644 --- a/types/datatables.net/index.d.ts +++ b/types/datatables.net/index.d.ts @@ -1321,7 +1321,7 @@ declare namespace DataTables { /** * Set an initial filter in DataTables and / or filtering options. Since: 1.10 */ - search?: SearchSettings; + search?: SearchSettings | boolean; /** * Set placeholder attribute for input type="text" tag elements. Since: 1.10