From c6dd365c4b743f38f1783a35b27b38f888b65160 Mon Sep 17 00:00:00 2001 From: Alejandro Haro Date: Thu, 13 Sep 2018 18:08:40 +0100 Subject: [PATCH 01/12] NeDB: Add expireAfterSeconds in ensureIndex options --- types/nedb/index.d.ts | 2 ++ types/nedb/nedb-tests.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/types/nedb/index.d.ts b/types/nedb/index.d.ts index 02ed81be4f..dd3035dd72 100644 --- a/types/nedb/index.d.ts +++ b/types/nedb/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/louischatriot/nedb // Definitions by: Stefan Steinhart // Anthony Nichols +// Alejandro Fernandez Haro // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = Nedb; @@ -215,6 +216,7 @@ declare namespace Nedb { fieldName: string; unique?: boolean; sparse?: boolean; + expireAfterSeconds?: number; } interface Persistence { diff --git a/types/nedb/nedb-tests.ts b/types/nedb/nedb-tests.ts index c1ba5459cd..0df7168cf1 100644 --- a/types/nedb/nedb-tests.ts +++ b/types/nedb/nedb-tests.ts @@ -496,6 +496,11 @@ db.ensureIndex({ fieldName: 'somefield', unique: true }, (err: Error) => { db.ensureIndex({ fieldName: 'somefield', unique: true, sparse: true }, (err: Error) => { }); +// Example of using expireAfterSeconds to remove documents 1 hour +// after their creation (db's timestampData option is true here) +db.ensureIndex({ fieldName: 'somefield', expireAfterSeconds: 3600 }, (err: Error) => { +}); + // Format of the error message when the unique constraint is not met db.insert({ somefield: 'nedb' }, (err: Error) => { // err is null From 2543f375d8d32857ea93616c8e12e87e2f4d920b Mon Sep 17 00:00:00 2001 From: James Ide Date: Thu, 13 Sep 2018 17:44:53 -0700 Subject: [PATCH 02/12] [react-native] Declare StyleSheet.setStyleAttributePreprocessor Added the type declaration and copied the documentation for this static function. The type of the `process` parameter should be `(nextProp: unknown) => unknown` but I stuck with `any` to preserve 2.x compatibility. --- types/react-native/index.d.ts | 14 ++++++++++++++ types/react-native/test/index.tsx | 2 ++ 2 files changed, 16 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index ad8abe57fd..1a91e55c90 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -5216,6 +5216,20 @@ export namespace StyleSheet { export function flatten(style?: StyleProp): ImageStyle; export function flatten(style?: StyleProp): ViewStyle; + /** + * WARNING: EXPERIMENTAL. Breaking changes will probably happen a lot and will + * not be reliably announced. The whole thing might be deleted, who knows? Use + * at your own risk. + * + * Sets a function to use to pre-process a style property value. This is used + * internally to process color and transform values. You should not use this + * unless you really know what you are doing and have exhausted other options. + */ + export function setStyleAttributePreprocessor( + property: string, + process: (nextProp: any) => any + ): void; + /** * This is defined as the width of a thin line on the platform. It can be * used as the thickness of a border or division between two elements. diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 8bc6757c48..21d859d771 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -151,6 +151,8 @@ const stylesAlt = StyleSheet.create({ }, }); +StyleSheet.setStyleAttributePreprocessor('fontFamily', (family: string) => family); + const welcomeFontSize = StyleSheet.flatten(styles.welcome).fontSize; const viewStyle: StyleProp = { From 3c4f383e95ca335b32755e8715fb2d19cd39adee Mon Sep 17 00:00:00 2001 From: James Ide Date: Thu, 13 Sep 2018 17:56:35 -0700 Subject: [PATCH 03/12] [react-native] Add types for devtools modules Adds type declarations for `parseErrorStack` and `symbolicateStackTrace`, which are used to process caught errors. --- types/react-native/Devtools.d.ts | 22 ++++++++++++++++++++++ types/react-native/index.d.ts | 1 + 2 files changed, 23 insertions(+) create mode 100644 types/react-native/Devtools.d.ts diff --git a/types/react-native/Devtools.d.ts b/types/react-native/Devtools.d.ts new file mode 100644 index 0000000000..18f17540b9 --- /dev/null +++ b/types/react-native/Devtools.d.ts @@ -0,0 +1,22 @@ +declare module 'react-native/Libraries/Core/Devtools/parseErrorStack' { + export type StackFrame = { + file: string; + methodName: string; + lineNumber: number; + column: number | null; + }; + + export interface ExtendedError extends Error { + framesToPop?: number; + } + + export default function parseErrorStack(error: ExtendedError): StackFrame[]; +} + +declare module 'react-native/Libraries/Core/Devtools/symbolicateStackTrace' { + import { StackFrame } from 'react-native/Libraries/Core/Devtools/parseErrorStack'; + + export default function symbolicateStackTrace( + stack: ReadonlyArray + ): Promise; +} diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index ad8abe57fd..0e01132d9e 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -30,6 +30,7 @@ /// /// /// +/// import * as React from 'react'; From c7d547e221726852b3bbde3ceee8f7d995b04354 Mon Sep 17 00:00:00 2001 From: Bradley Ayers Date: Sun, 16 Sep 2018 19:08:14 +1000 Subject: [PATCH 04/12] fix(stripe): ISubscription.ended_at is nullable --- types/stripe/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index fcb008c07b..33bc44b0ee 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -4585,7 +4585,7 @@ declare namespace Stripe { * If the subscription has ended (either because it was canceled or because the customer was switched to a subscription * to a new plan), the date the subscription ended */ - ended_at: number; + ended_at: number | null; metadata: IMetadata; From 8c8052ac49f5956b54711ef183b656b2a2495ff2 Mon Sep 17 00:00:00 2001 From: GP Date: Mon, 17 Sep 2018 16:43:26 +0530 Subject: [PATCH 05/12] Include new options introduced in pino 5.6.0. Related changes in pinojs/pino - https://github.com/pinojs/pino/pull/515 --- types/pino/index.d.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/types/pino/index.d.ts b/types/pino/index.d.ts index 42d7a4d1f6..ae74927145 100644 --- a/types/pino/index.d.ts +++ b/types/pino/index.d.ts @@ -150,6 +150,17 @@ declare namespace P { * Outputs the level as a string instead of integer. Default: `false`. */ useLevelLabels?: boolean; + /** + * Use this option to define additional logging levels. + * The keys of the object correspond the namespace of the log level, and the values should be the numerical value of the level. + */ + customLevels?: { [key: string]: number }; + /** + * Use this option to only use defined `customLevels` and omit Pino's levels. + * Logger's default `level` must be changed to a value in `customLevels` in order to use `useOnlyCustomLevels` + * Warning: this option may not be supported by downstream transports. + */ + useOnlyCustomLevels?: boolean; /** * When defining a custom log level via level, set to an integer value to define the new level. Default: `undefined`. */ @@ -277,6 +288,14 @@ declare namespace P { * Outputs the level as a string instead of integer. */ useLevelLabels: boolean; + /** + * Define additional logging levels. + */ + customLevels: { [key: string]: number }; + /** + * Use only defined `customLevels` and omit Pino's levels. + */ + useOnlyCustomLevels: boolean; /** * Returns the integer value for the logger instance's logging level. */ From 6126691b6c4fa96f82e0d844193c997eebef820b Mon Sep 17 00:00:00 2001 From: GP Date: Mon, 17 Sep 2018 16:44:11 +0530 Subject: [PATCH 06/12] Bump definition version in header. --- types/pino/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/pino/index.d.ts b/types/pino/index.d.ts index ae74927145..b1a8fe9c0d 100644 --- a/types/pino/index.d.ts +++ b/types/pino/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for pino 5.20 +// Type definitions for pino 5.6.0 // Project: https://github.com/pinojs/pino.git // Definitions by: Peter Snider // BendingBender From 1e3335009a168bf8c28746de9406bf7133f9f273 Mon Sep 17 00:00:00 2001 From: GP Date: Mon, 17 Sep 2018 16:47:16 +0530 Subject: [PATCH 07/12] Omit patch version because https://github.com/Microsoft/dtslint/blob/master/docs/dt-header.md --- types/pino/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/pino/index.d.ts b/types/pino/index.d.ts index b1a8fe9c0d..71cb957643 100644 --- a/types/pino/index.d.ts +++ b/types/pino/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for pino 5.6.0 +// Type definitions for pino 5.6 // Project: https://github.com/pinojs/pino.git // Definitions by: Peter Snider // BendingBender From f4b9e5acaab715e2ac3e47b7bdcb7c0b9554695a Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Wed, 12 Sep 2018 15:17:18 +0200 Subject: [PATCH 08/12] node: stream.finished function --- types/node/index.d.ts | 5 +++++ types/node/node-tests.ts | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index d0ebd2124f..7ad7ca3049 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -6415,6 +6415,11 @@ declare module "stream" { export class PassThrough extends Transform { } + export function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, callback?: (err: NodeJS.ErrnoException) => void): () => void; + export namespace finished { + export function __promisify__(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream): Promise; + } + export function pipeline(stream1: NodeJS.ReadableStream, stream2: T, callback?: (err: NodeJS.ErrnoException) => void): T; export function pipeline(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: T, callback?: (err: NodeJS.ErrnoException) => void): T; export function pipeline(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.ReadWriteStream, stream4: T, callback?: (err: NodeJS.ErrnoException) => void): T; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index b9a02f8dbd..731db242e8 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -1123,6 +1123,21 @@ function simplified_stream_ctor_test() { }); } +function streamPipelineFinished() { + const cancel = stream.finished(process.stdin, (err: Error) => {}); + cancel(); + + stream.pipeline(process.stdin, process.stdout, (err: Error) => {}); +} + +async function asyncStreamPipelineFinished() { + const finished = util.promisify(stream.finished); + await finished(process.stdin); + + const pipeline = util.promisify(stream.pipeline); + await pipeline(process.stdin, process.stdout); +} + //////////////////////////////////////////////////////// /// Crypto tests : http://nodejs.org/api/crypto.html /// //////////////////////////////////////////////////////// From a649bec809ce72d64dea3fa08de0eb77f4ce7981 Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Thu, 13 Sep 2018 10:08:55 +0200 Subject: [PATCH 09/12] node: stream.finished: err is optional --- types/node/index.d.ts | 2 +- types/node/node-tests.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 7ad7ca3049..c1974ef350 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -6415,7 +6415,7 @@ declare module "stream" { export class PassThrough extends Transform { } - export function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, callback?: (err: NodeJS.ErrnoException) => void): () => void; + export function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, callback: (err?: NodeJS.ErrnoException) => void): () => void; export namespace finished { export function __promisify__(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream): Promise; } diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 731db242e8..3feb7a4a86 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -1124,10 +1124,10 @@ function simplified_stream_ctor_test() { } function streamPipelineFinished() { - const cancel = stream.finished(process.stdin, (err: Error) => {}); + const cancel = stream.finished(process.stdin, (err?: Error) => {}); cancel(); - stream.pipeline(process.stdin, process.stdout, (err: Error) => {}); + stream.pipeline(process.stdin, process.stdout, (err?: Error) => {}); } async function asyncStreamPipelineFinished() { From b3cb36b8c461e424d3c3f059e5efd3769c01a5e2 Mon Sep 17 00:00:00 2001 From: higuri Date: Mon, 17 Sep 2018 23:57:45 +0900 Subject: [PATCH 10/12] Add type definitions for 'resize-img' --- types/resize-img/index.d.ts | 19 +++++++++++++++++++ types/resize-img/resize-img-tests.ts | 9 +++++++++ types/resize-img/tsconfig.json | 23 +++++++++++++++++++++++ types/resize-img/tslint.json | 1 + 4 files changed, 52 insertions(+) create mode 100644 types/resize-img/index.d.ts create mode 100644 types/resize-img/resize-img-tests.ts create mode 100644 types/resize-img/tsconfig.json create mode 100644 types/resize-img/tslint.json diff --git a/types/resize-img/index.d.ts b/types/resize-img/index.d.ts new file mode 100644 index 0000000000..b071488ac5 --- /dev/null +++ b/types/resize-img/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for resize-img 1.1 +// Project: https://github.com/kevva/resize-img#readme +// Definitions by: Yusuke Higuchi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = ResizeImg; + +declare function ResizeImg( + input: Buffer, + options: ResizeImg.ResizeImgOptions): Promise; + +declare namespace ResizeImg { + interface ResizeImgOptions { + width?: number; + height?: number; + } +} diff --git a/types/resize-img/resize-img-tests.ts b/types/resize-img/resize-img-tests.ts new file mode 100644 index 0000000000..b9fad114ea --- /dev/null +++ b/types/resize-img/resize-img-tests.ts @@ -0,0 +1,9 @@ +import * as fs from "fs"; +import resizeImg = require("resize-img"); + +resizeImg(fs.readFileSync("images/dog.jpg"), { + width: 128, + height: 128, +}).then((buf) => { + fs.writeFileSync("resized.jpg", buf); +}); diff --git a/types/resize-img/tsconfig.json b/types/resize-img/tsconfig.json new file mode 100644 index 0000000000..10f4aba357 --- /dev/null +++ b/types/resize-img/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", + "resize-img-tests.ts" + ] +} diff --git a/types/resize-img/tslint.json b/types/resize-img/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/resize-img/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 76a5fdc54027ec76efa66749bf2c444bed0702cb Mon Sep 17 00:00:00 2001 From: Mike North Date: Mon, 17 Sep 2018 09:12:01 -0700 Subject: [PATCH 11/12] [ember] Relax observable tests - Fixes #28942 --- types/ember__object/test/observable.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/ember__object/test/observable.ts b/types/ember__object/test/observable.ts index baa8e3d09a..aa41889d24 100644 --- a/types/ember__object/test/observable.ts +++ b/types/ember__object/test/observable.ts @@ -24,7 +24,7 @@ class MyComponent extends EmberObject { removeObserver(this, 'foo', lambda); } - fooDidChange(sender: this, key: keyof this) { + fooDidChange(sender: this, key: string) { // your code } } From ca9a362f29600697ce514cccf39ced9e5461da78 Mon Sep 17 00:00:00 2001 From: Daniil Dotsev Date: Mon, 17 Sep 2018 19:25:31 +0300 Subject: [PATCH 12/12] Add type definitions for prosemirror-dropcursor --- types/prosemirror-dropcursor/index.d.ts | 20 ++++++++++++++++ .../prosemirror-dropcursor-tests.ts | 4 ++++ types/prosemirror-dropcursor/tsconfig.json | 24 +++++++++++++++++++ types/prosemirror-dropcursor/tslint.json | 3 +++ 4 files changed, 51 insertions(+) create mode 100644 types/prosemirror-dropcursor/index.d.ts create mode 100644 types/prosemirror-dropcursor/prosemirror-dropcursor-tests.ts create mode 100644 types/prosemirror-dropcursor/tsconfig.json create mode 100644 types/prosemirror-dropcursor/tslint.json diff --git a/types/prosemirror-dropcursor/index.d.ts b/types/prosemirror-dropcursor/index.d.ts new file mode 100644 index 0000000000..548834b6df --- /dev/null +++ b/types/prosemirror-dropcursor/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for prosemirror-dropcursor 1.0 +// Project: https://github.com/ProseMirror/prosemirror-dropcursor +// Definitions by: Bradley Ayers +// David Hahn +// Daniil Dotsev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Plugin } from 'prosemirror-state'; + +/** + * Create a plugin that, when added to a ProseMirror instance, + * causes a decoration to show up at the drop position when something + * is dragged over the editor. + * + * @param options These options are supported: + * @param options.color The color of the cursor. Defaults to `black`. + * @param options.width The precise width of the cursor in pixels. Defaults to 1. + */ +export function dropCursor(options?: { color?: string | null, width?: number | null }): Plugin; diff --git a/types/prosemirror-dropcursor/prosemirror-dropcursor-tests.ts b/types/prosemirror-dropcursor/prosemirror-dropcursor-tests.ts new file mode 100644 index 0000000000..f6341817ea --- /dev/null +++ b/types/prosemirror-dropcursor/prosemirror-dropcursor-tests.ts @@ -0,0 +1,4 @@ +import { dropCursor } from 'prosemirror-dropcursor'; +import { Plugin } from 'prosemirror-state'; + +const dropCursorPlugin: Plugin = dropCursor(); diff --git a/types/prosemirror-dropcursor/tsconfig.json b/types/prosemirror-dropcursor/tsconfig.json new file mode 100644 index 0000000000..706e5b2d16 --- /dev/null +++ b/types/prosemirror-dropcursor/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", + "prosemirror-dropcursor-tests.ts" + ] +} \ No newline at end of file diff --git a/types/prosemirror-dropcursor/tslint.json b/types/prosemirror-dropcursor/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/prosemirror-dropcursor/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}