From 97b73b32723374e6350a74a68a2b2711cadae323 Mon Sep 17 00:00:00 2001 From: Alexander Tesfamichael Date: Mon, 25 Mar 2019 17:25:30 +0100 Subject: [PATCH 01/36] Add instance methods to React Native Material Textfield (#34175) * Add methods * Add examples of method use --- .../index.d.ts | 27 ++++++++++++- .../react-native-material-textfield-tests.tsx | 39 +++++++++++++------ 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/types/react-native-material-textfield/index.d.ts b/types/react-native-material-textfield/index.d.ts index c21caa15b4..1aed9e03aa 100644 --- a/types/react-native-material-textfield/index.d.ts +++ b/types/react-native-material-textfield/index.d.ts @@ -66,4 +66,29 @@ export interface TextFieldProps extends TextInputProps { * Material Style Text Field * @see https://github.com/n4kz/react-native-material-textfield/blob/master/src/components/field/index.js */ -export class TextField extends React.Component {} +export class TextField extends React.Component { + /* + * Acquire focus + */ + focus(): void; + /* + * Release focus + */ + blur(): void; + /* + * Clear text field + */ + clear(): void; + /* + * Get current value + */ + value(): string; + /* + * Get current focus state + */ + isFocused(): boolean; + /* + * Get current restriction state + */ + isRestricted(): boolean; +} diff --git a/types/react-native-material-textfield/react-native-material-textfield-tests.tsx b/types/react-native-material-textfield/react-native-material-textfield-tests.tsx index 50fb2b166b..7219dd9a3f 100644 --- a/types/react-native-material-textfield/react-native-material-textfield-tests.tsx +++ b/types/react-native-material-textfield/react-native-material-textfield-tests.tsx @@ -2,14 +2,31 @@ import * as React from 'react'; import { View } from 'react-native'; import { TextField } from 'react-native-material-textfield'; -const Example = () => ( - - - -); +export class Example extends React.Component { + textFieldRef = React.createRef(); + + componentDidMount() { + if (this.textFieldRef.current) { + this.textFieldRef.current.focus(); + this.textFieldRef.current.blur(); + this.textFieldRef.current.clear(); + this.textFieldRef.current.value(); + this.textFieldRef.current.isFocused(); + this.textFieldRef.current.isRestricted(); + } + } + + render() { + return ( + + + + ); + } +} From 919f6b0dc7649e7e3b912d4ddff42f95c6d91a70 Mon Sep 17 00:00:00 2001 From: codert Date: Tue, 26 Mar 2019 00:26:02 +0800 Subject: [PATCH 02/36] fabric.Image.setElement method has no callback argument (#34173) * fix: setElement type definition * chore: add definitions by --- types/fabric/fabric-impl.d.ts | 4 ++-- types/fabric/index.d.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/fabric/fabric-impl.d.ts b/types/fabric/fabric-impl.d.ts index 96034c0b5f..cd52bd54e5 100644 --- a/types/fabric/fabric-impl.d.ts +++ b/types/fabric/fabric-impl.d.ts @@ -2212,10 +2212,10 @@ export class Image { * Sets image element for this instance to a specified one. * If filters defined they are applied to new image. * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area. - * @param [callback] Callback is invoked when all filters have been applied and new image is generated + * @param element image element * @param [options] Options object */ - setElement(element: HTMLImageElement, callback: Function, options: IImageOptions): Image; + setElement(element: HTMLImageElement, options?: IImageOptions): Image; /** * Delete a single texture if in webgl mode */ diff --git a/types/fabric/index.d.ts b/types/fabric/index.d.ts index 3897987589..7444f481b8 100644 --- a/types/fabric/index.d.ts +++ b/types/fabric/index.d.ts @@ -9,6 +9,7 @@ // Bradley Hill // Bryan Krol // Glenn Gartner +// Codertx // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 export import fabric = require("./fabric-impl"); From f51241ad20f948467a73e34168f72fab5c879b95 Mon Sep 17 00:00:00 2001 From: Ryo Ota Date: Tue, 26 Mar 2019 01:27:33 +0900 Subject: [PATCH 03/36] Remove the type definition of get-port (#34165) --- notNeededPackages.json | 6 ++++++ types/get-port/get-port-tests.ts | 10 ---------- types/get-port/index.d.ts | 12 ------------ types/get-port/tsconfig.json | 23 ----------------------- types/get-port/tslint.json | 3 --- 5 files changed, 6 insertions(+), 48 deletions(-) delete mode 100644 types/get-port/get-port-tests.ts delete mode 100644 types/get-port/index.d.ts delete mode 100644 types/get-port/tsconfig.json delete mode 100644 types/get-port/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index cf61daf58d..33ac19b762 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -786,6 +786,12 @@ "sourceRepoURL": "https://github.com/manuelbieh/Geolib", "asOfVersion": "2.0.23" }, + { + "libraryName": "get-port", + "typingsPackageName": "get-port", + "sourceRepoURL": "https://github.com/sindresorhus/get-port", + "asOfVersion": "4.2.0" + }, { "libraryName": "get-stream", "typingsPackageName": "get-stream", diff --git a/types/get-port/get-port-tests.ts b/types/get-port/get-port-tests.ts deleted file mode 100644 index 5e47c33c1a..0000000000 --- a/types/get-port/get-port-tests.ts +++ /dev/null @@ -1,10 +0,0 @@ -import getPort = require('get-port'); - -// $ExpectType Promise -getPort(); -// $ExpectType Promise -getPort({ port: 3000 }); -// $ExpectType Promise -getPort({ port: [3000, 3001] }); -// $ExpectType Promise -getPort({ host: 'foo.local' }); diff --git a/types/get-port/index.d.ts b/types/get-port/index.d.ts deleted file mode 100644 index 9af3b311fc..0000000000 --- a/types/get-port/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Type definitions for get-port 4.0 -// Project: https://github.com/sindresorhus/get-port -// Definitions by: York Yao -// BendingBender -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare function getPort(options?: { - port?: number | ReadonlyArray; - host?: string; -}): Promise; - -export = getPort; diff --git a/types/get-port/tsconfig.json b/types/get-port/tsconfig.json deleted file mode 100644 index 0d9f3a8975..0000000000 --- a/types/get-port/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "get-port-tests.ts" - ] -} diff --git a/types/get-port/tslint.json b/types/get-port/tslint.json deleted file mode 100644 index f93cf8562a..0000000000 --- a/types/get-port/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "dtslint/dt.json" -} From ded108693b02df1041b2d00a052ca63071ee1717 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Mon, 25 Mar 2019 12:28:10 -0400 Subject: [PATCH 04/36] [cacheable-request] Include type alias for cache adapter (#34155) * [cacheable-request] Include type alias for cache adapter This allows easily declaring a parameter that will be passed into the constructor. Ref https://github.com/sindresorhus/got/pull/760#discussion_r268277506 * Fix missing semicolon * Move StorageAdapter into namespace --- types/cacheable-request/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/cacheable-request/index.d.ts b/types/cacheable-request/index.d.ts index 98d858d3f6..16e778274a 100644 --- a/types/cacheable-request/index.d.ts +++ b/types/cacheable-request/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for cacheable-request 6.0 // Project: https://github.com/lukechilds/cacheable-request#readme // Definitions by: BendingBender +// Paul Melnikow // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -20,7 +21,7 @@ declare const CacheableRequest: CacheableRequest; type RequestFn = typeof request; interface CacheableRequest { - new (requestFn: RequestFn, storageAdapter?: string | Store): ( + new (requestFn: RequestFn, storageAdapter?: string | CacheableRequest.StorageAdapter): ( opts: string | URL | (RequestOptions & CacheSemanticsOptions), cb?: (response: ServerResponse | ResponseLike) => void ) => CacheableRequest.Emitter; @@ -30,6 +31,8 @@ interface CacheableRequest { } declare namespace CacheableRequest { + type StorageAdapter = Store; + interface Options { /** * If the cache should be used. Setting this to `false` will completely bypass the cache for the current request. From de12981020aebe17afb2c81dbe52d853285b2789 Mon Sep 17 00:00:00 2001 From: Silas Rech Date: Mon, 25 Mar 2019 17:29:06 +0100 Subject: [PATCH 05/36] [bull] allow supplying of the queue type when creating a new instance (#34154) --- types/bull/index.d.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index 07de38e05d..648e2ba360 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -26,10 +26,12 @@ import { EventEmitter } from "events"; * Everytime the same queue is instantiated it tries to process all the old jobs that may exist from a previous unfinished session. */ declare const Bull: { - (queueName: string, opts?: Bull.QueueOptions): Bull.Queue; - (queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; // tslint:disable-line unified-signatures - new (queueName: string, opts?: Bull.QueueOptions): Bull.Queue; - new (queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; // tslint:disable-line unified-signatures + /* tslint:disable:no-unnecessary-generics unified-signatures */ + (queueName: string, opts?: Bull.QueueOptions): Bull.Queue; + (queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; + new (queueName: string, opts?: Bull.QueueOptions): Bull.Queue; + new (queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; + /* tslint:enable:no-unnecessary-generics unified-signatures */ }; declare namespace Bull { From 0cbf2d2865db2f26c696209d830d9bae99629bf9 Mon Sep 17 00:00:00 2001 From: TokugawaT_YD <41653501+TokugawaTakesi@users.noreply.github.com> Date: Tue, 26 Mar 2019 01:31:33 +0900 Subject: [PATCH 06/36] Types for gulp-tap (#31917) * Types for "gulp-tap" added * Types for "gulp-tap" added * Requested changes applied * Requested changes applied --- types/gulp-tap/gulp-tap-tests.ts | 11 +++++++++++ types/gulp-tap/index.d.ts | 22 ++++++++++++++++++++++ types/gulp-tap/tsconfig.json | 23 +++++++++++++++++++++++ types/gulp-tap/tslint.json | 3 +++ 4 files changed, 59 insertions(+) create mode 100644 types/gulp-tap/gulp-tap-tests.ts create mode 100644 types/gulp-tap/index.d.ts create mode 100644 types/gulp-tap/tsconfig.json create mode 100644 types/gulp-tap/tslint.json diff --git a/types/gulp-tap/gulp-tap-tests.ts b/types/gulp-tap/gulp-tap-tests.ts new file mode 100644 index 0000000000..7d89c50ba0 --- /dev/null +++ b/types/gulp-tap/gulp-tap-tests.ts @@ -0,0 +1,11 @@ +import gulpTap = require('gulp-tap'); +import gulp = require('gulp'); +import Vinyl = require('vinyl'); + +gulp.task('testTask', () => { + return gulp.src(['src/*.html']) + .pipe(gulpTap((sourceFile: Vinyl) => { + console.log(sourceFile.path); + })) + .pipe(gulp.dest('dist/')); +}); diff --git a/types/gulp-tap/index.d.ts b/types/gulp-tap/index.d.ts new file mode 100644 index 0000000000..30af7663f8 --- /dev/null +++ b/types/gulp-tap/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for gulp-tap 1.0 +// Project: https://github.com/geejs/gulp-tap +// Definitions by: Takesi Tokugawa +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import Vinyl = require('vinyl'); + +declare namespace tap { + interface Tap { + (tapFunction: TapFunction, t?: any): NodeJS.ReadWriteStream; + } + + interface TapFunction { + (file: Vinyl): any; + } +} + +declare function tap(tapFunction: (file: Vinyl, t?: {}) => void): NodeJS.ReadWriteStream; + +export = tap; diff --git a/types/gulp-tap/tsconfig.json b/types/gulp-tap/tsconfig.json new file mode 100644 index 0000000000..d48ac90475 --- /dev/null +++ b/types/gulp-tap/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "gulp-tap-tests.ts" + ] +} diff --git a/types/gulp-tap/tslint.json b/types/gulp-tap/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/gulp-tap/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From a4e52c5eb19eed6e30aaa31439cdbaadd6a75694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Gon=C3=A7alves=20da=20Silva?= Date: Mon, 25 Mar 2019 13:34:48 -0300 Subject: [PATCH 07/36] Add type definitions to webpack-plugin-serve (#33948) * feat(wps): add webpack-plugin-serve types * fix export method * fix declaration * add strictFunctionTypes * fix declaration problems * remove redundant declare * add correct level types * export history api interfaces * reuse koa-compress and koa-static * fix padding --- types/connect-history-api-fallback/index.d.ts | 38 +++++----- types/koa-compress/index.d.ts | 22 +++--- types/webpack-plugin-serve/index.d.ts | 69 +++++++++++++++++++ types/webpack-plugin-serve/tsconfig.json | 23 +++++++ types/webpack-plugin-serve/tslint.json | 1 + .../webpack-plugin-serve-tests.ts | 39 +++++++++++ 6 files changed, 162 insertions(+), 30 deletions(-) create mode 100644 types/webpack-plugin-serve/index.d.ts create mode 100644 types/webpack-plugin-serve/tsconfig.json create mode 100644 types/webpack-plugin-serve/tslint.json create mode 100644 types/webpack-plugin-serve/webpack-plugin-serve-tests.ts diff --git a/types/connect-history-api-fallback/index.d.ts b/types/connect-history-api-fallback/index.d.ts index a39fbfdbd6..b32e61e147 100644 --- a/types/connect-history-api-fallback/index.d.ts +++ b/types/connect-history-api-fallback/index.d.ts @@ -10,26 +10,28 @@ import { Url } from 'url'; import * as core from "express-serve-static-core"; -declare function historyApiFallback(options?: Options): core.RequestHandler; -declare namespace historyApiFallback {} export = historyApiFallback; -interface Options { - disableDotRule?: true; - htmlAcceptHeaders?: string[]; - index?: string; - logger?: typeof console.log; - rewrites?: Rewrite[]; - verbose?: boolean; -} +declare function historyApiFallback(options?: historyApiFallback.Options): core.RequestHandler; -interface Context { - match: RegExpMatchArray; - parsedUrl: Url; -} -type RewriteTo = (context: Context) => string; +declare namespace historyApiFallback { + interface Options { + disableDotRule?: true; + htmlAcceptHeaders?: string[]; + index?: string; + logger?: typeof console.log; + rewrites?: Rewrite[]; + verbose?: boolean; + } -interface Rewrite { - from: RegExp; - to: string | RegExp | RewriteTo; + interface Context { + match: RegExpMatchArray; + parsedUrl: Url; + } + type RewriteTo = (context: Context) => string; + + interface Rewrite { + from: RegExp; + to: string | RegExp | RewriteTo; + } } diff --git a/types/koa-compress/index.d.ts b/types/koa-compress/index.d.ts index 24b7a1e1af..9b0a4415be 100644 --- a/types/koa-compress/index.d.ts +++ b/types/koa-compress/index.d.ts @@ -16,12 +16,18 @@ /// /// -declare module "koa-compress" { +import * as Koa from "koa"; +import * as zlib from "zlib"; - import * as Koa from "koa"; - import * as zlib from "zlib"; +/** + * Compress middleware for Koa + */ +declare function koaCompress(options?: koaCompress.CompressOptions): Koa.Middleware; - interface CompressOptions extends zlib.ZlibOptions { +export = koaCompress; + +declare namespace koaCompress { + export interface CompressOptions extends zlib.ZlibOptions { /** * An optional function that checks the response content type to decide whether to compress. By default, it uses compressible. */ @@ -32,12 +38,4 @@ declare module "koa-compress" { */ threshold?: number } - - /** - * Compress middleware for Koa - */ - function compress(options?: CompressOptions): Koa.Middleware; - - namespace compress {} - export = compress; } diff --git a/types/webpack-plugin-serve/index.d.ts b/types/webpack-plugin-serve/index.d.ts new file mode 100644 index 0000000000..1233333ebc --- /dev/null +++ b/types/webpack-plugin-serve/index.d.ts @@ -0,0 +1,69 @@ +// Type definitions for webpack-plugin-serve 0.7 +// Project: https://github.com/shellscape/webpack-plugin-serve +// Definitions by: Matheus Gonçalves da Silva +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 +/// + +import { Url } from 'url'; +import { Config as HttpProxyMiddlewareConfig, Proxy } from 'http-proxy-middleware'; +import * as Koa from 'koa'; +import { + ServerOptions as Http2ServerOptions, + SecureServerOptions as Http2SecureServerOptions, +} from 'http2'; +import { ServerOptions as HttpsServerOptions } from 'https'; +import { ZlibOptions } from 'zlib'; +import { Compiler } from 'webpack'; +import { Options as HistoryApiFallbackOptions } from 'connect-history-api-fallback'; +import { CompressOptions } from 'koa-compress'; +import { Options as KoaStaticOptions } from 'koa-static'; + +export interface Builtins { + proxy: (args: HttpProxyMiddlewareConfig) => Proxy; + compress: (opts: CompressOptions) => void; + static: (paths: string[], opts?: KoaStaticOptions) => void; + historyFallback: (opts: HistoryApiFallbackOptions) => void; + websocket: () => void; + four0four: (fn?: (ctx: Koa.Context) => void) => void; +} + +export interface WebpackPluginServeOptions { + client?: { + address?: string; + retry?: boolean; + silent?: boolean; + }; + compress?: boolean; + historyFallback?: boolean | HistoryApiFallbackOptions; + hmr?: boolean; + host?: string | Promise; + http2?: boolean | Http2ServerOptions | Http2SecureServerOptions; + https?: HttpsServerOptions; + liveReload?: boolean; + log?: { + level: 'trace' | 'debug' | 'info' | 'warn' | 'error'; + timestamp?: boolean; + }; + middleware?: (app: Koa, builtins: Builtins) => void; + open?: + | boolean + | { + wait?: boolean; + app?: string | ReadonlyArray; + }; + port?: number | Promise; + progress?: boolean | 'minimal'; + static?: string | string[]; + status?: boolean; + waitForBuild?: boolean; +} + +export class WebpackPluginServe { + constructor(opts?: WebpackPluginServeOptions); + attach(): { + apply(compiler: Compiler): void; + }; + hook(compiler: Compiler): void; + apply(compiler: Compiler): void; +} diff --git a/types/webpack-plugin-serve/tsconfig.json b/types/webpack-plugin-serve/tsconfig.json new file mode 100644 index 0000000000..8b70e1d1d4 --- /dev/null +++ b/types/webpack-plugin-serve/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "webpack-plugin-serve-tests.ts" + ] +} diff --git a/types/webpack-plugin-serve/tslint.json b/types/webpack-plugin-serve/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/webpack-plugin-serve/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/webpack-plugin-serve/webpack-plugin-serve-tests.ts b/types/webpack-plugin-serve/webpack-plugin-serve-tests.ts new file mode 100644 index 0000000000..7abddcc600 --- /dev/null +++ b/types/webpack-plugin-serve/webpack-plugin-serve-tests.ts @@ -0,0 +1,39 @@ +import { WebpackPluginServe } from 'webpack-plugin-serve'; +import { Configuration } from 'webpack'; + +const usage = (config: Configuration) => { + (config.entry as string[]).push('webpack-plugin-serve/client'); + + config.watch = true; + + config.plugins!.push( + new WebpackPluginServe({ + compress: true, + historyFallback: true, + host: '0.0.0.0', + port: 3808, + liveReload: true, + middleware: (app: any, builtins: any) => + app.use(async (ctx: any, next: any) => { + await next(); + ctx.set('Access-Control-Allow-Headers', '*'); + ctx.set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); + ctx.set('Access-Control-Allow-Origin', '*'); + }), + static: '/', + + status: true, + progress: true, + }), + ); + + config.output!.publicPath = '/'; + + return config; +}; + +const baseConfig = { + entry: 'index.js' +}; + +const configWithServer = usage(baseConfig); From 30468b4db176a0aed810d880dfc42006465dc2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20F=C3=BCrst?= Date: Mon, 25 Mar 2019 17:36:43 +0100 Subject: [PATCH 08/36] [@types/react-color] Fix wrong color type on swatch hover (#33984) * Fix wrong type on swatch hover * Change variable name for consistency * Add user as definitions author * Change major version due to breaking changes --- types/react-color/index.d.ts | 5 +++-- types/react-color/lib/components/block/Block.d.ts | 4 ++-- types/react-color/lib/components/circle/Circle.d.ts | 2 +- types/react-color/lib/components/compact/Compact.d.ts | 4 ++-- types/react-color/lib/components/github/Github.d.ts | 4 ++-- types/react-color/lib/components/sketch/Sketch.d.ts | 4 ++-- types/react-color/lib/components/swatches/Swatches.d.ts | 4 ++-- types/react-color/lib/components/twitter/Twitter.d.ts | 4 ++-- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/types/react-color/index.d.ts b/types/react-color/index.d.ts index 9935814feb..3e0b0f3989 100644 --- a/types/react-color/index.d.ts +++ b/types/react-color/index.d.ts @@ -1,10 +1,11 @@ -// Type definitions for react-color 2.17 +// Type definitions for react-color 3.0 // Project: https://github.com/casesandberg/react-color/, http://casesandberg.github.io/react-color // Definitions by: Karol Janyst , // Marks Polakovs , // Matthieu Montaudouin , // Nokogiri , -// 0815Strohhut +// 0815Strohhut , +// Daniel Fürst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 diff --git a/types/react-color/lib/components/block/Block.d.ts b/types/react-color/lib/components/block/Block.d.ts index 20ea123eed..6761cf3f90 100644 --- a/types/react-color/lib/components/block/Block.d.ts +++ b/types/react-color/lib/components/block/Block.d.ts @@ -1,11 +1,11 @@ import { Component } from "react"; -import { ColorPickerProps, Color } from "../../.."; +import { ColorPickerProps, ColorResult } from "../../.."; export interface BlockPickerProps extends ColorPickerProps { colors?: string[]; width?: string; triangle?: 'hide' | 'top'; - onSwatchHover?(color: Color, event: MouseEvent): void; + onSwatchHover?(color: ColorResult, event: MouseEvent): void; } export default class BlockPicker extends Component {} diff --git a/types/react-color/lib/components/circle/Circle.d.ts b/types/react-color/lib/components/circle/Circle.d.ts index 98eec039a0..df230cf71d 100644 --- a/types/react-color/lib/components/circle/Circle.d.ts +++ b/types/react-color/lib/components/circle/Circle.d.ts @@ -6,7 +6,7 @@ export interface CirclePickerProps extends ColorPickerProps { width?: string; circleSize?: number; circleSpacing?: number; - onSwatchHover?(colorResult: ColorResult, event: MouseEvent): void; + onSwatchHover?(color: ColorResult, event: MouseEvent): void; } export default class CirclePicker extends Component {} diff --git a/types/react-color/lib/components/compact/Compact.d.ts b/types/react-color/lib/components/compact/Compact.d.ts index 5609899128..c79e331a33 100644 --- a/types/react-color/lib/components/compact/Compact.d.ts +++ b/types/react-color/lib/components/compact/Compact.d.ts @@ -1,9 +1,9 @@ import { Component } from "react"; -import { ColorPickerProps, Color } from "../../.."; +import { ColorPickerProps, ColorResult } from "../../.."; export interface CompactPickerProps extends ColorPickerProps { colors?: string[]; - onSwatchHover?(color: Color, event: MouseEvent): void; + onSwatchHover?(color: ColorResult, event: MouseEvent): void; } export default class CompactPicker extends Component {} diff --git a/types/react-color/lib/components/github/Github.d.ts b/types/react-color/lib/components/github/Github.d.ts index 18b6a21121..8155152f28 100644 --- a/types/react-color/lib/components/github/Github.d.ts +++ b/types/react-color/lib/components/github/Github.d.ts @@ -1,11 +1,11 @@ import { Component } from "react"; -import { ColorPickerProps, Color } from "../../.."; +import { ColorPickerProps, ColorResult } from "../../.."; export interface GithubPickerProps extends ColorPickerProps { colors?: string[]; width?: string; triangle?: 'hide' | 'top-left' | 'top-right'; - onSwatchHover?(color: Color, event: MouseEvent): void; + onSwatchHover?(color: ColorResult, event: MouseEvent): void; } export default class GithubPicker extends Component {} diff --git a/types/react-color/lib/components/sketch/Sketch.d.ts b/types/react-color/lib/components/sketch/Sketch.d.ts index 7aec9fb82f..bf11556a98 100644 --- a/types/react-color/lib/components/sketch/Sketch.d.ts +++ b/types/react-color/lib/components/sketch/Sketch.d.ts @@ -1,11 +1,11 @@ import { Component } from "react"; -import { ColorPickerProps, Color } from "../../.."; +import { ColorPickerProps, ColorResult } from "../../.."; export interface SketchPickerProps extends ColorPickerProps { disableAlpha?: boolean; presetColors?: string[]; width?: string; - onSwatchHover?(color: Color, event: MouseEvent): void; + onSwatchHover?(color: ColorResult, event: MouseEvent): void; } export default class SketchPicker extends Component {} diff --git a/types/react-color/lib/components/swatches/Swatches.d.ts b/types/react-color/lib/components/swatches/Swatches.d.ts index b2a7f72dc2..bf0b9dbd4a 100644 --- a/types/react-color/lib/components/swatches/Swatches.d.ts +++ b/types/react-color/lib/components/swatches/Swatches.d.ts @@ -1,11 +1,11 @@ import { Component } from "react"; -import { ColorPickerProps, Color } from "../../.."; +import { ColorPickerProps, ColorResult } from "../../.."; export interface SwatchesPickerProps extends ColorPickerProps { colors?: string[][]; height?: number; width?: number; - onSwatchHover?(color: Color, event: MouseEvent): void; + onSwatchHover?(color: ColorResult, event: MouseEvent): void; } export default class SwatchesPicker extends Component {} diff --git a/types/react-color/lib/components/twitter/Twitter.d.ts b/types/react-color/lib/components/twitter/Twitter.d.ts index 8d5eb2e6dd..73fbd6f984 100644 --- a/types/react-color/lib/components/twitter/Twitter.d.ts +++ b/types/react-color/lib/components/twitter/Twitter.d.ts @@ -1,11 +1,11 @@ import { Component } from "react"; -import { ColorPickerProps, Color } from "../../.."; +import { ColorPickerProps, ColorResult } from "../../.."; export interface TwitterPickerProps extends ColorPickerProps { colors?: string[]; width?: string; triangle?: 'hide' | 'top-left' | 'top-right'; - onSwatchHover?(color: Color, event: MouseEvent): void; + onSwatchHover?(color: ColorResult, event: MouseEvent): void; } export default class TwitterPicker extends Component {} From d9437c4fd6e18bccc0784d1dbe1604fa4535d287 Mon Sep 17 00:00:00 2001 From: James Nimlos Date: Mon, 25 Mar 2019 09:38:31 -0700 Subject: [PATCH 09/36] Update fluent definitions for v0.11 (#33859) * update fluent definitions for v0.11 * remove circular reference * add typescript version requiring fix * downgrade ts version definitelytyped-header-parser errors on prereleases versions but TS v3.4 is not actually released so it also errors --- types/fluent-react/index.d.ts | 4 ++-- types/fluent/fluent-tests.ts | 6 ++++++ types/fluent/index.d.ts | 6 ++++-- types/fluent/tsconfig.json | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/types/fluent-react/index.d.ts b/types/fluent-react/index.d.ts index 5ffc93d874..b3fa7c9dec 100644 --- a/types/fluent-react/index.d.ts +++ b/types/fluent-react/index.d.ts @@ -2,7 +2,7 @@ // Project: http://projectfluent.org // Definitions by: Huy Nguyen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 3.3 import * as React from 'react'; import { @@ -76,7 +76,7 @@ export type Matching = { */ export type Shared< InjectedProps, - DecorationTargetProps extends Shared + DecorationTargetProps > = { [P in Extract]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never; }; diff --git a/types/fluent/fluent-tests.ts b/types/fluent/fluent-tests.ts index d2fcd4a6c4..90b4bffa61 100644 --- a/types/fluent/fluent-tests.ts +++ b/types/fluent/fluent-tests.ts @@ -29,6 +29,7 @@ const bundle4 = new FluentBundle(['en-US'], { // FluentBundle addMessages examples: bundle1.addMessages('foo = Foo'); +bundle2.hasMessage('foo'); bundle2.getMessage('foo'); // FluentBundle addResource examples: @@ -42,3 +43,8 @@ bundle1.addMessages('hello = Hello, { $name }!'); const hello = bundle2.getMessage('hello'); bundle3.format(hello, { name: 'Jane' }, errors2); bundle3.format(hello, undefined, errors2); + +for (const [id, message] of bundle1.messages) { + bundle1.getMessage(id); + bundle1.format(message); +} diff --git a/types/fluent/index.d.ts b/types/fluent/index.d.ts index 56014044ab..8520443354 100644 --- a/types/fluent/index.d.ts +++ b/types/fluent/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for fluent 0.10 +// Type definitions for fluent 0.11 // Project: http://projectfluent.org -// Definitions by: Huy Nguyen +// Definitions by: Huy Nguyen , James Nimlos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -28,6 +28,8 @@ export class FluentResource extends Map { export class FluentBundle { constructor(locales: string | string[], options?: FluentBundleContructorOptions); + messages: IterableIterator<[string, FluentNode[]]>; + hasMessage(source: string): boolean; addMessages(source: string): string[]; getMessage(id: string): FluentNode[]; format(message: FluentNode[], args?: object, errors?: string[]): string; diff --git a/types/fluent/tsconfig.json b/types/fluent/tsconfig.json index 64e2460dcd..c08fe97570 100644 --- a/types/fluent/tsconfig.json +++ b/types/fluent/tsconfig.json @@ -4,6 +4,7 @@ "lib": [ "es6" ], + "target": "es6", "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, From 3c9fd4a6920d779cbfecffc296b0054559ab02a1 Mon Sep 17 00:00:00 2001 From: Johan Davidsson Date: Mon, 25 Mar 2019 17:39:20 +0100 Subject: [PATCH 10/36] [@types/htmlparser2] Update typings for Htmlparser2 (and related modules) to match updates (#33921) * Added new types for domelementtype * Modify existing types for htmlparser2 * Updating PULL_REQUEST_TEMPLATE.md * Revert changes to .github/PULL_REQUEST_TEMPLATE.md * Fixed missing optional * Adding DomUtils * Update dependencies * Removed requirement for TypeScript 2.1 and updated test * Updated test to include DomUtils and DomHandlerOptions. * Updated domhandler tests * Remove incorrect constructor in Parser * Remove incorrect constructor in WritableStream * Change way of importing in tests * Adding deprecated fallback to Options * Add deprecated Options as a fallback to sanitize-html * Add ParserOptions * Use the deprecated Options --- types/domhandler/domhandler-tests.ts | 8 +-- types/domhandler/index.d.ts | 1 - types/domutils/index.d.ts | 1 - types/htmlparser2/htmlparser2-tests.ts | 37 ++++++++------ types/htmlparser2/index.d.ts | 68 ++++++++++++++++++-------- types/sanitize-html/index.d.ts | 1 + 6 files changed, 74 insertions(+), 42 deletions(-) diff --git a/types/domhandler/domhandler-tests.ts b/types/domhandler/domhandler-tests.ts index eea6441ad7..4b1c5406ec 100644 --- a/types/domhandler/domhandler-tests.ts +++ b/types/domhandler/domhandler-tests.ts @@ -1,6 +1,6 @@ -import { DomHandler, DomHandlerOptions, Node } from "domhandler"; +import { DomHandler, DomHandlerOptions, Node, DomElement } from "domhandler"; -const handler = new DomHandler((error: Error, dom: any) => { +const handler = new DomHandler((error: Error, dom: DomElement[]) => { if (error) console.error('There has been an error...'); else @@ -8,7 +8,7 @@ const handler = new DomHandler((error: Error, dom: any) => { }); handler.ontext = (data: string) => { console.log(data); }; handler.onreset = () => { console.log('We have a reset.'); }; -handler.onerror = (error: Error) => { console.error(Error); }; -handler.onopentag = (name: string, attribs) => { console.log(name, attribs); }; +handler.onerror = (error: Error) => { console.error(error); }; +handler.onopentag = (name: string, attribs: { [s: string]: string }) => { console.log(name, attribs); }; const dho: DomHandlerOptions = { normalizeWhitespace: true, withDomLvl1: true, withEndIndices: true, withStartIndices: true }; diff --git a/types/domhandler/index.d.ts b/types/domhandler/index.d.ts index 9d33055bbd..49dcd6325f 100644 --- a/types/domhandler/index.d.ts +++ b/types/domhandler/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/fb55/DomHandler#readme // Definitions by: Johan Davidsson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 export interface DomHandlerOptions { /*** diff --git a/types/domutils/index.d.ts b/types/domutils/index.d.ts index 5300a68a8c..6790f9bf82 100644 --- a/types/domutils/index.d.ts +++ b/types/domutils/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/FB55/domutils#readme // Definitions by: Johan Davidsson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 import { DomElement } from "domhandler"; /*** diff --git a/types/htmlparser2/htmlparser2-tests.ts b/types/htmlparser2/htmlparser2-tests.ts index 21289b96f5..807f2fe904 100644 --- a/types/htmlparser2/htmlparser2-tests.ts +++ b/types/htmlparser2/htmlparser2-tests.ts @@ -1,23 +1,30 @@ /** * Created by staticfunction on 8/4/14. */ -import htmlparser = require("htmlparser2"); +import htmlparser = require('htmlparser2'); -var parser = new htmlparser.Parser({ - onopentag: (name:string, attribs:{[s:string]:string}) => { - if(name === "script" && attribs['type'] === "text/javascript"){ - console.log("JS! Hooray!"); - } - }, - ontext: (text: string) => { - console.log("-->", text); - }, - onclosetag: (tagname:string) => { - if(tagname === "script"){ - console.log("That's it?!"); - } +const options: htmlparser.DomHandlerOptions = { withEndIndices: false, withDomLvl1: true } +const dh = new htmlparser.DomHandler((err: Error, dom: htmlparser.DomElement[]) => { + if(err) { + throw err; } -}); + + // Use DomUtils to get name of first element in dom + console.log(htmlparser.DomUtils.getName(dom[0])); +}, options); +dh.onopentag = (name:string, attribs:{[s:string]:string}) => { + if(name === "script" && attribs['type'] === "text/javascript"){ + console.log("JS! Hooray!"); + } +}; +dh.ontext = (text: string) => { + console.log("-->", text); +}; +dh.onclosetag = () => { + console.log("That's it?!"); +}; + +var parser = new htmlparser.Parser(dh); parser.write("Xyz "); parser.end(); diff --git a/types/htmlparser2/index.d.ts b/types/htmlparser2/index.d.ts index 313ff56a96..c10dea047e 100644 --- a/types/htmlparser2/index.d.ts +++ b/types/htmlparser2/index.d.ts @@ -1,30 +1,20 @@ -// Type definitions for htmlparser2 v3.7.x +// Type definitions for htmlparser2 v3.10.x // Project: https://github.com/fb55/htmlparser2/ // Definitions by: James Roland Cabresos // Linus Unnebäck +// Johan Davidsson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// +/// +/// import { Writable } from 'stream' +import { DomHandler } from 'domhandler'; +import * as DomUtils from 'domutils'; +export { DomElement, DomHandlerOptions, DomHandler, Element, Node } from 'domhandler'; -export interface Handler { - onopentag?: (name: string, attribs: { [type: string]: string }) => void; - onopentagname?: (name: string) => void; - onattribute?: (name: string, value: string) => void; - ontext?: (text: string) => void; - onclosetag?: (text: string) => void; - onprocessinginstruction?: (name: string, data: string) => void; - oncomment?: (data: string) => void; - oncommentend?: () => void; - oncdatastart?: () => void; - oncdataend?: () => void; - onerror?: (error: Error) => void; - onreset?: () => void; - onend?: () => void; -} - -export interface Options { +export interface ParserOptions { /*** * Indicates whether special tags (