From 33dfeb9d34d7d1973871938222ec7d86ef52546a Mon Sep 17 00:00:00 2001 From: Yongbeen Im Date: Sun, 30 Dec 2018 17:12:38 +0900 Subject: [PATCH 01/15] classnames tsconfig file modified strictNullChecks option to true --- types/classnames/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/classnames/tsconfig.json b/types/classnames/tsconfig.json index f9b03432fc..0e8475e613 100644 --- a/types/classnames/tsconfig.json +++ b/types/classnames/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ From d81e5b3218210620695c15c8aa2a853721c6e1bc Mon Sep 17 00:00:00 2001 From: Yongbeen Im Date: Sun, 30 Dec 2018 17:13:44 +0900 Subject: [PATCH 02/15] calssnames module bind error fixed --- types/classnames/bind.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/classnames/bind.d.ts b/types/classnames/bind.d.ts index 4af94d1835..9befbabd4c 100644 --- a/types/classnames/bind.d.ts +++ b/types/classnames/bind.d.ts @@ -1,3 +1,3 @@ -import * as cn from "./index"; +import classNames = require('./index'); -export function bind(styles: Record): typeof cn; +export function bind(styles: Record): typeof classNames; From fb0afa719b54852c66efedbef76df8c6a04fc99d Mon Sep 17 00:00:00 2001 From: freewind Date: Sun, 30 Dec 2018 21:32:52 +0800 Subject: [PATCH 03/15] superagent: cookie related headers has special types --- types/superagent/index.d.ts | 2 ++ types/superagent/superagent-tests.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/types/superagent/index.d.ts b/types/superagent/index.d.ts index 7c1898cdc2..7915277b37 100644 --- a/types/superagent/index.d.ts +++ b/types/superagent/index.d.ts @@ -100,6 +100,7 @@ declare namespace request { files: any; forbidden: boolean; get(header: string): string; + get(header: 'Set-Cookie'): string[]; header: any; info: boolean; links: object; @@ -148,6 +149,7 @@ declare namespace request { serialize(serializer: Serializer): this; set(field: object): this; set(field: string, val: string): this; + set(field: 'Cookie', val: string[]): this; timeout(ms: number | { deadline?: number, response?: number }): this; type(val: string): this; unset(field: string): this; diff --git a/types/superagent/superagent-tests.ts b/types/superagent/superagent-tests.ts index 44ef7cf773..b261a551d7 100644 --- a/types/superagent/superagent-tests.ts +++ b/types/superagent/superagent-tests.ts @@ -83,6 +83,12 @@ request .set({ 'API-Key': 'foobar', Accept: 'application/json' }) .end(callback); +// Setting cookie header +request + .get('/search') + .set('Cookie', ['name1=value1; Domain=.test.com; Path=/', 'name2=value2; Domain=.test.com; Path=/']) + .end(callback); + // GET requests request .get('/search') @@ -198,6 +204,12 @@ request('/search') const charset: string = res.charset; }); +// Getting response 'Set-Cookie' +request('/search') + .end((res: request.Response) => { + const setCookie: string[] = res.get('Set-Cookie'); + }); + // Custom parsers request .post('/search') From 8d21ac9216f47c1a4739b5deb4df266a98fa2160 Mon Sep 17 00:00:00 2001 From: davidgoli Date: Thu, 3 Jan 2019 18:09:14 -0800 Subject: [PATCH 04/15] add extra parse signature --- types/url-parse/index.d.ts | 6 +++++- types/url-parse/url-parse-tests.ts | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/types/url-parse/index.d.ts b/types/url-parse/index.d.ts index 58a14f3f4d..4d33354e9e 100644 --- a/types/url-parse/index.d.ts +++ b/types/url-parse/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for url-parse 1.4 // Project: https://github.com/unshiftio/url-parse -// Definitions by: Pavlo Chernenko , Hari Sivaramakrishnan , Dmitry Dushkin +// Definitions by: Pavlo Chernenko +// Hari Sivaramakrishnan +// Dmitry Dushkin +// David Golightly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -43,6 +46,7 @@ interface URLParse { declare const URLParse: { new(address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse; (address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse; + (address: string, parser?: boolean | URLParse.QueryParser): URLParse; extractProtocol(url: string): { slashes: boolean; diff --git a/types/url-parse/url-parse-tests.ts b/types/url-parse/url-parse-tests.ts index 87904b7f13..be8b8afe8c 100644 --- a/types/url-parse/url-parse-tests.ts +++ b/types/url-parse/url-parse-tests.ts @@ -5,6 +5,10 @@ new URL('foo/bar', 'https://github.com/'); new URL('foo/bar', 'https://github.com/', (query: string) => ({ query })); parse('foo/bar', 'https://github.com/'); parse('foo/bar', 'https://github.com/', (query: string) => ({ query })); +const result = parse('foo/bar?baz=quux', true); +if (result.query.baz !== 'quux') { + throw new Error('bad query parsing'); +} const url1: URL = new URL('https://github.com/foo/bar?baz=true'); url1.hash; From 305151cf2d4fdd0ce1ba36b4e0cd4e5ef381dddf Mon Sep 17 00:00:00 2001 From: paibamboo Date: Fri, 4 Jan 2019 10:22:41 +0700 Subject: [PATCH 05/15] Add onAfterClose prop to ReactModal --- types/react-modal/index.d.ts | 5 ++++- types/react-modal/react-modal-tests.tsx | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/types/react-modal/index.d.ts b/types/react-modal/index.d.ts index d04a6b5c18..2daa2a1a6f 100644 --- a/types/react-modal/index.d.ts +++ b/types/react-modal/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-modal 3.6 +// Type definitions for react-modal 3.8.1 // Project: https://github.com/reactjs/react-modal // Definitions by: Rajab Shakirov , // Drew Noakes , @@ -64,6 +64,9 @@ declare namespace ReactModal { /* Function that will be run after the modal has opened. */ onAfterOpen?(): void; + /* Function that will be run after the modal has closed. */ + onAfterClose?(): void; + /* Function that will be run when the modal is requested to be closed, prior to actually closing. */ onRequestClose?(event: (MouseEvent | KeyboardEvent)): void; diff --git a/types/react-modal/react-modal-tests.tsx b/types/react-modal/react-modal-tests.tsx index 8dfd6d35e3..96c18ea881 100644 --- a/types/react-modal/react-modal-tests.tsx +++ b/types/react-modal/react-modal-tests.tsx @@ -12,6 +12,7 @@ class ExampleOfUsingReactModal extends React.Component { overlayRef: HTMLDivElement; render() { const onAfterOpenFn = () => { }; + const onAfterCloseFn = () => { }; const onRequestCloseFn = () => { }; const customStyle = { overlay: { @@ -59,6 +60,7 @@ class ExampleOfUsingReactModal extends React.Component { Date: Fri, 4 Jan 2019 14:09:05 +0800 Subject: [PATCH 06/15] [opentype.js] add annotations for BoundingBox and some tests, finish prev todo --- types/opentype.js/index.d.ts | 15 +++++++++++++-- types/opentype.js/opentype.js-tests.ts | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/types/opentype.js/index.d.ts b/types/opentype.js/index.d.ts index 8dc449784d..5fdc257362 100644 --- a/types/opentype.js/index.d.ts +++ b/types/opentype.js/index.d.ts @@ -367,8 +367,19 @@ export interface PathCommand { * UTIL CLASSES ******************************************/ -export type BoundingBox = () => any; -// TODO add methods +export class BoundingBox { + x1: number; + y1: number; + x2: number; + y2: number; + + isEmpty(): boolean; + addPoint(x: number, y: number): void; + addX(x: number): void; + addY(y: number): void; + addBezier(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x: number, y: number): void; + addQuad(x0: number, y0: number, x1: number, y1: number, x: number, y: number): void; +} export interface Encoding { charset: string; diff --git a/types/opentype.js/opentype.js-tests.ts b/types/opentype.js/opentype.js-tests.ts index 04781d5415..e3695944db 100644 --- a/types/opentype.js/opentype.js-tests.ts +++ b/types/opentype.js/opentype.js-tests.ts @@ -113,6 +113,8 @@ aPath.extend(aPath); aPath.extend(aPath.commands); aPath.extend(aPath.getBoundingBox()); const pathBBox: opentype.BoundingBox = aPath.getBoundingBox(); +pathBBox.addQuad(1, 1, 1, 1, 1, 1); +const yDist = pathBBox.y2 - pathBBox.y1; aPath.draw(ctx); const pathData: string = aPath.toPathData(7); const pathSvg: string = aPath.toSVG(7); From f4417875ccd9964b8e64822b7dd8c582353178b8 Mon Sep 17 00:00:00 2001 From: paibamboo Date: Fri, 4 Jan 2019 13:26:08 +0700 Subject: [PATCH 07/15] Fix build error patch version not allowed --- types/react-modal/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-modal/index.d.ts b/types/react-modal/index.d.ts index 2daa2a1a6f..0117a69656 100644 --- a/types/react-modal/index.d.ts +++ b/types/react-modal/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-modal 3.8.1 +// Type definitions for react-modal 3.8 // Project: https://github.com/reactjs/react-modal // Definitions by: Rajab Shakirov , // Drew Noakes , From c8aebb07540f5b9e66a5d80707594c6750e4fc65 Mon Sep 17 00:00:00 2001 From: Vince Varga Date: Thu, 3 Jan 2019 16:27:01 +0100 Subject: [PATCH 08/15] Add navigator.permissions API type definitions --- types/navigator-permissions/index.d.ts | 180 ++++++++++++++++++ .../navigator-permissions-tests.ts | 45 +++++ types/navigator-permissions/tsconfig.json | 24 +++ types/navigator-permissions/tslint.json | 1 + 4 files changed, 250 insertions(+) create mode 100644 types/navigator-permissions/index.d.ts create mode 100644 types/navigator-permissions/navigator-permissions-tests.ts create mode 100644 types/navigator-permissions/tsconfig.json create mode 100644 types/navigator-permissions/tslint.json diff --git a/types/navigator-permissions/index.d.ts b/types/navigator-permissions/index.d.ts new file mode 100644 index 0000000000..a62c7f77ef --- /dev/null +++ b/types/navigator-permissions/index.d.ts @@ -0,0 +1,180 @@ +// Type definitions for Navigator.Permissions 0.1 +// Project: https://developer.mozilla.org/en-US/docs/Web/API/Permissions +// Definitions by: Vince Varga , MindDoc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/** + * Namespace for `navigator.permissions` type definitions. + * + * As the Permissions API is only supported by Firefox and Chrome + * https://caniuse.com/#feat=permissions-api + * the TypeScript team has not yet added it to lib.dom.d.ts + * https://github.com/Microsoft/TypeScript/issues/24923 + * In the meantime, these type definitions can be used. + * + * The documentation is based on the MDN web docs + * https://developer.mozilla.org/en-US/docs/Web/API/Permissions + */ +declare namespace NavigatorPermissions { + /** + * Permission state values. + */ + type PermissionState = + 'granted' | + 'denied' | + 'prompt'; + + /** + * The `PermissionStatus` interface of the Permissions API provides the state + * of an object and an event handler for monitoring changes to said state. + * + * This is an experimental technology + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus} + */ + interface PermissionStatus extends EventTarget { + /** + * Returns the state of a requested permission. + */ + readonly state: PermissionState; + /** + * Returns the state of a requested permission. + * Later versions of the specification replace this with + * `PermissionStatus.state`. + * @deprecated + */ + readonly status: PermissionState; + /** + * An event called whenever `PermissionStatus.status` changes. + */ + onchange: ((this: this, event: Event) => any) | null; + } + + /** + * Permission name options. + */ + type PermissionName = + 'accelerometer' | + 'accessibility-events' | + 'ambient-light-sensor' | + 'background-sync' | + 'camera' | + 'clipboard-read' | + 'clipboard-write' | + 'geolocation' | + 'gyroscope' | + 'magnetometer' | + 'microphone' | + 'midi' | + 'notifications' | + 'payment-handler' | + 'persistent-storage' | + 'push'; + + /** + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query} + */ + interface PermissionDescriptor { + /** + * The name of the API whose permissions you want to query. + * + * Please, be aware, that not all of these are supported in every browser + * that supports the Permissions API. For example, in Firefox you can't query + * the `'microphone'` or `'camera'` and it'll throw `TypeError` + */ + name: N; + } + + interface PushPermissionDescriptor extends PermissionDescriptor<'push'> { + /** + * Indicates whether you want to show a notification for every message + * or be able to send silent push + * notifications. The default is `false`. Not supported in Firefox. + */ + userVisibleOnly?: boolean; + } + + interface MidiPermissionDescriptor extends PermissionDescriptor<'midi'> { + /** + * Indicates whether you need and/or receive system exclusive + * messages. The default is false. + */ + sysex?: boolean; + } + + // Map permission names to correctly typed descriptors. + interface NameDescriptorMap { + // ??? Question ???: + // Is there a better way to handle this case and remove repeated code, + // something like + // > { + // [n in N]: D; // this line to cover all basic cases + // // and the custom permission descriptors for midi and push + // } + 'accelerometer': PermissionDescriptor<'accelerometer'>; + 'accessibility-events': PermissionDescriptor<'accessibility-events'>; + 'ambient-light-sensor': PermissionDescriptor<'ambient-light-sensor'>; + 'background-sync': PermissionDescriptor<'background-sync'>; + 'camera': PermissionDescriptor<'camera'>; + 'clipboard-read': PermissionDescriptor<'clipboard-read'>; + 'clipboard-write': PermissionDescriptor<'clipboard-write'>; + 'geolocation': PermissionDescriptor<'geolocation'>; + 'gyroscope': PermissionDescriptor<'gyroscope'>; + 'magnetometer': PermissionDescriptor<'magnetometer'>; + 'microphone': PermissionDescriptor<'microphone'>; + 'notifications': PermissionDescriptor<'notifications'>; + 'payment-handler': PermissionDescriptor<'payment-handler'>; + 'persistent-storage': PermissionDescriptor<'persistent-storage'>; + // These permission descriptors support extra properties + 'midi': MidiPermissionDescriptor; + 'push': PushPermissionDescriptor; + } + + /** + * The `Permissions` interface of the Permissions API provides the core + * Permission API functionality, such as methods for querying and + * revoking permissions. + * + * This is an experimental technology. + * + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions} + */ + interface Permissions { + /** + * The `Permissions.query()` method of the `Permissions` interface returns + * the state of a user permission on the global scope. + * @param permissionDescriptor object that sets + * options for the query operation consisting of a comma-separated list + * of name-value pairs. + * (Is comma-separated list really supported? It is mentioned in the docs, but does not work). + * @returns the user permission status for a given API. + * @throws `TypeError` Retrieving the `PermissionDescriptor` information + * failed in some way, or the permission doesn't exist or is currently + * unsupported (e.g. `midi`, or `push` with `userVisibleOnly`). + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query} + */ + query(permissionDescriptor: NameDescriptorMap[keyof NameDescriptorMap]): Promise; + /** + * The `Permissions.revoke()` method of the `Permissions` interface reverts a + * currently set permission back to its default state, which is usually `prompt`. + * + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/revoke} + */ + revoke(permissionDescriptor: NameDescriptorMap[keyof NameDescriptorMap]): Promise; + } + + /** + * Navigator type definition with possible `permissions` API support. + * + * This interface adds the `permissions` property to the navigator. + */ + interface NavigatorPermissions extends Navigator { + /** + * Provides the core Permission API functionality, such as querying and revoking permissions. + * + * The typing takes into account that the feature is not widely supported, + * making code using this API more secure by forcing considering the `undefined` case. + */ + permissions?: Permissions; + } +} diff --git a/types/navigator-permissions/navigator-permissions-tests.ts b/types/navigator-permissions/navigator-permissions-tests.ts new file mode 100644 index 0000000000..918726b23d --- /dev/null +++ b/types/navigator-permissions/navigator-permissions-tests.ts @@ -0,0 +1,45 @@ +// Here are some examples for Navigator.Permissions types. +// Open it in your IDE with TypeScript support and observe the types and documentation help +// that this module provides + +// Navigator from lib.dom might have permissions +const nav = navigator as NavigatorPermissions.NavigatorPermissions; + +async function exampleQueryAndEventListeners() { + // Force users to check for undefined as the feature is not widely supported + if (typeof nav.permissions === 'undefined') { return; } + const permissionsStatus = await nav.permissions.query({ name: 'camera' }); + // Possible state values are known to users: + const isDenied = permissionsStatus.state === 'denied'; + // if compared to any non-valid value, it warns + // const tsShouldWarn = permissionsStatus.state === 'can you see the warning?'; + permissionsStatus.addEventListener('change', (event) => { + console.log('permission state changed'); + // I couldn't find a way to set the EventTarget's type to PermissionStatus + console.log('new PermissionStatus', event.target); + }); +} + +function exampleQueryOptions() { + // Force users to check for undefined as the feature is not widely supported + if (typeof nav.permissions === 'undefined') { return; } + // query method checks if the name is a valid permission name + nav.permissions.query({ name: 'camera' }); + // Other names would cause type errors + // nav.permissions.query({ name: 'invalid name' }); + + // When permission name is 'push', userVisibleOnly property is also supported + nav.permissions.query({ name: 'push', userVisibleOnly: true }); + // For other names, it would fail: + // nav.permissions.query({ name: 'camera', userVisibleOnly: true }); + + // When permission name is 'midi', sysex property is also supported + nav.permissions.query({ name: 'midi', sysex: true }); + // For other names, it would fail: + // nav.permissions.query({ name: 'camera', sysex: true }); +} + +function exampleIgnoreUndefinedCheck() { + // Using the ! after permissions will let you bypass the undefined-check + nav.permissions!.query({ name: 'microphone' }); +} diff --git a/types/navigator-permissions/tsconfig.json b/types/navigator-permissions/tsconfig.json new file mode 100644 index 0000000000..c072886b33 --- /dev/null +++ b/types/navigator-permissions/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", + "navigator-permissions-tests.ts" + ] +} diff --git a/types/navigator-permissions/tslint.json b/types/navigator-permissions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/navigator-permissions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 5950b10aed88f4fc785a6e92158603f4d6713e41 Mon Sep 17 00:00:00 2001 From: Guillaume Mayer Date: Fri, 4 Jan 2019 11:48:30 -0300 Subject: [PATCH 09/15] failing test (sort of) --- types/koa-router/koa-router-tests.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/koa-router/koa-router-tests.ts b/types/koa-router/koa-router-tests.ts index 51e95fb8a5..50e66509ea 100644 --- a/types/koa-router/koa-router-tests.ts +++ b/types/koa-router/koa-router-tests.ts @@ -49,6 +49,10 @@ const match = router.match('/users/:id', 'GET'); let layer: Router.Layer let layerOptions: Router.ILayerOptions +const mw: Router.IMiddleware = (ctx: Router.IRouterContext, next: () => Promise) => { + ctx.body = "Ok"; +}; + app.use(router.routes()); app.use(router.allowedMethods()); From 6e13e6088f3eab8874141412f27d23a6c6d4975a Mon Sep 17 00:00:00 2001 From: Guillaume Mayer Date: Fri, 4 Jan 2019 11:49:20 -0300 Subject: [PATCH 10/15] fix --- types/koa-router/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/koa-router/index.d.ts b/types/koa-router/index.d.ts index 81b0f697e6..b2163d09d1 100644 --- a/types/koa-router/index.d.ts +++ b/types/koa-router/index.d.ts @@ -43,7 +43,7 @@ declare namespace Router { strict?: boolean; } - export interface IRouterContext { + export interface IRouterContext extends Koa.Context { /** * url params */ From 8085094f30ad662b8226355079c3f75f4388ef3d Mon Sep 17 00:00:00 2001 From: Daniel Schopf Date: Fri, 4 Jan 2019 17:27:19 +0100 Subject: [PATCH 11/15] Add terser-webpack-plugin (#31863) * Added terser plugin typings * add webpack chunk typing * added 'ExtractCommentOptions' instead of just 'object' --- types/terser-webpack-plugin/index.d.ts | 54 +++++++++++++++++++ .../terser-webpack-plugin-tests.ts | 36 +++++++++++++ types/terser-webpack-plugin/tsconfig.json | 23 ++++++++ types/terser-webpack-plugin/tslint.json | 1 + 4 files changed, 114 insertions(+) create mode 100644 types/terser-webpack-plugin/index.d.ts create mode 100644 types/terser-webpack-plugin/terser-webpack-plugin-tests.ts create mode 100644 types/terser-webpack-plugin/tsconfig.json create mode 100644 types/terser-webpack-plugin/tslint.json diff --git a/types/terser-webpack-plugin/index.d.ts b/types/terser-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..5d1afa1a52 --- /dev/null +++ b/types/terser-webpack-plugin/index.d.ts @@ -0,0 +1,54 @@ +// Type definitions for terser-webpack-plugin 1.2 +// Project: https://github.com/webpack-contrib/terser-webpack-plugin +// Definitions by: Daniel Schopf +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0 + +import { Plugin } from 'webpack'; +import { MinifyOptions } from 'terser'; +import webpack = require('webpack'); + +export = TerserPlugin; + +declare class TerserPlugin extends Plugin { + constructor(opts?: TerserPlugin.TerserPluginOptions); +} + +declare namespace TerserPlugin { + interface MinifyResult { + error: any; + map: any; + code: any; + warnings: any; + extractedComments: any; + } + + interface ExtractCommentOptions { + condition: boolean | string | RegExp | ExtractCommentFn | object; + filename?: string | FormatFn; + banner?: boolean | string | FormatFn; + } + + type ExtractCommentFn = (node: any, comment: any) => (boolean | object); + + type FormatFn = (input: string) => string; + + interface TerserPluginOptions { + test?: string | RegExp | Array; + include?: string | RegExp | Array; + exclude?: string | RegExp | Array; + chunkFilter?: (chunk: webpack.compilation.Chunk) => boolean; + cache?: boolean | string; + cacheKeys?: (defaultCacheKeys: any, file: any) => object; + parallel?: boolean | number; + sourceMap?: boolean; + minify?: (file: any, sourceMap: any) => MinifyResult; + terserOptions?: MinifyOptions; + extractComments?: boolean + | string + | RegExp + | ExtractCommentFn + | ExtractCommentOptions; + warningsFilter?: (warning: any, source: any) => boolean; + } +} diff --git a/types/terser-webpack-plugin/terser-webpack-plugin-tests.ts b/types/terser-webpack-plugin/terser-webpack-plugin-tests.ts new file mode 100644 index 0000000000..5b0540a4ff --- /dev/null +++ b/types/terser-webpack-plugin/terser-webpack-plugin-tests.ts @@ -0,0 +1,36 @@ +import * as webpack from 'webpack'; +import * as TerserPlugin from "terser-webpack-plugin"; + +const compiler = webpack({ + plugins: [ + new TerserPlugin(), + ], +}); + +const compilerOptions = webpack({ + plugins: [ + new TerserPlugin({ + // Uncomment lines below for cache invalidation correctly + cache: true, + cacheKeys: (defaultCacheKeys) => { + delete defaultCacheKeys.terser; + + return { + ...defaultCacheKeys, + 'uglify-js': require('uglify-js/package.json').version, + }; + }, + minify: (file, sourceMap) => { + // https://github.com/mishoo/UglifyJS2#minify-options + const uglifyJsOptions = { + /* your `uglify-js` package options */ + }; + return require('uglify-js').minify(file, uglifyJsOptions); + }, + include: /src\//, + exclude: /node_modules\//, + sourceMap: true, + terserOptions: { mangle: true } + }), + ], +}); diff --git a/types/terser-webpack-plugin/tsconfig.json b/types/terser-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..02669a9daa --- /dev/null +++ b/types/terser-webpack-plugin/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "terser-webpack-plugin-tests.ts" + ] +} diff --git a/types/terser-webpack-plugin/tslint.json b/types/terser-webpack-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/terser-webpack-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 8a18392af3b5dd555cb920168668d15d11485e24 Mon Sep 17 00:00:00 2001 From: Nathan Fast Date: Fri, 4 Jan 2019 10:44:06 -0600 Subject: [PATCH 12/15] Add ignorePunctuation parameter to MarkOptions (#31873) --- types/mark.js/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/mark.js/index.d.ts b/types/mark.js/index.d.ts index 7b410ad65e..8b214c3e15 100644 --- a/types/mark.js/index.d.ts +++ b/types/mark.js/index.d.ts @@ -24,6 +24,7 @@ declare namespace Mark { acrossElements?: boolean; caseSensitive?: boolean; ignoreJoiners?: boolean; + ignorePunctuation?: string[]; wildcards?: 'disabled' | 'enabled' | 'withSpaces'; each?(element: Element): void; From 62b167feca55ad8b5c865f76c6bc63d7eb5a0b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E4=B9=90?= Date: Sat, 5 Jan 2019 00:44:52 +0800 Subject: [PATCH 13/15] Update ACLType in index.d.ts@types/ali-oss (#31819) * Update ACLType in index.d.ts ### From ```ts type ACLType = "public-read-write" | "public-read" | "and private"; ``` ### Tto ```ts type ACLType = "public-read-write" | "public-read" | "private"; ``` * Update index.d.ts * Update index.d.ts * Update index.d.ts --- types/ali-oss/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/ali-oss/index.d.ts b/types/ali-oss/index.d.ts index 13f7f56ff9..e4f9e09e7c 100644 --- a/types/ali-oss/index.d.ts +++ b/types/ali-oss/index.d.ts @@ -18,6 +18,7 @@ declare namespace OSS { internal?: boolean; // access OSS with aliyun internal network or not, default is false. If your servers are running on aliyun too, you can set true to save lot of money. secure?: boolean; // instruct OSS client to use HTTPS (secure: true) or HTTP (secure: false) protocol. timeout?: string | number; // instance level timeout for all operations, default is 60s + cname?: boolean; // use custom domain name } interface Bucket { @@ -29,7 +30,7 @@ declare namespace OSS { type StorageType = "Standard" | "IA" | "Archive"; - type ACLType = "public-read-write" | "public-read" | "and private"; + type ACLType = "public-read-write" | "public-read" | "private"; type HTTPMethods = "GET" | "POST" | "DELETE" | "PUT"; @@ -174,6 +175,7 @@ declare namespace OSS { mime?: string; // custom mime, will send with Content-Type entity header meta?: UserMeta; // user meta, will send with x-oss-meta- prefix string e.g.: { uid: 123, pid: 110 } callback: ObjectCallback; + headers?: object; } interface PutObjectResult { @@ -188,6 +190,7 @@ declare namespace OSS { mime: string; // custom mime, will send with Content-Type entity header meta: UserMeta; callback: ObjectCallback; + headers?: object; } interface AppendObjectOptions { From 0a779e312e545de2ab989d7eec72def644719a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Kadi=C5=A1a?= <8273932+martynaskadisa@users.noreply.github.com> Date: Fri, 4 Jan 2019 19:43:36 +0200 Subject: [PATCH 14/15] add typings for @loadable/component --- types/loadable__component/index.d.ts | 47 +++++++ .../loadable__component-tests.tsx | 117 ++++++++++++++++++ types/loadable__component/tsconfig.json | 29 +++++ types/loadable__component/tslint.json | 1 + 4 files changed, 194 insertions(+) create mode 100644 types/loadable__component/index.d.ts create mode 100644 types/loadable__component/loadable__component-tests.tsx create mode 100644 types/loadable__component/tsconfig.json create mode 100644 types/loadable__component/tslint.json diff --git a/types/loadable__component/index.d.ts b/types/loadable__component/index.d.ts new file mode 100644 index 0000000000..c4877bd8a9 --- /dev/null +++ b/types/loadable__component/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for @loadable/component 5.2 +// Project: https://github.com/smooth-code/loadable-components +// Definitions by: Martynas KadiĊĦa +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export interface DefaultImportedComponent

{ + default: React.ComponentType

; +} + +export type DefaultComponent

= React.ComponentType

| DefaultImportedComponent

; + +export interface Options { + fallback?: JSX.Element; +} + +export type LoadableComponent = React.ComponentType; +export type LoadableLibrary = React.ComponentType<{ + fallback?: JSX.Element; + children?: (module: TModule) => React.ReactNode; + ref?: React.Ref; +}> & + TModule; + +declare function lib( + loadFn: (props: object) => Promise, + options?: Options +): LoadableLibrary; + +declare function loadableFunc( + loadFn: (props: T) => Promise>, + options?: Options +): LoadableComponent; + +declare const loadable: typeof loadableFunc & { lib: typeof lib }; + +export default loadable; + +export namespace lazy { + function lib(loadFn: (props: object) => Promise): LoadableLibrary; +} + +export function lazy(loadFn: (props: T) => Promise>): LoadableComponent; + +export function loadableReady(done?: () => any): Promise; diff --git a/types/loadable__component/loadable__component-tests.tsx b/types/loadable__component/loadable__component-tests.tsx new file mode 100644 index 0000000000..d286711be1 --- /dev/null +++ b/types/loadable__component/loadable__component-tests.tsx @@ -0,0 +1,117 @@ +import * as React from 'react'; +import loadable, { lazy, loadableReady } from '@loadable/component'; + +const TestComponent: React.SFC<{ foo: string }> = () => <>test; + +function defaultImportComponentLoader() { + return new Promise<{ default: typeof TestComponent }>(resolve => resolve({ default: TestComponent })); +} + +function importComponentLoader() { + return new Promise(resolve => resolve(TestComponent)); +} + +const lib = { + getTestObj: () => ({ bar: 'bar', foo: 'foo' }) +}; + +function defaultImportLibLoader() { + return new Promise<{ default: typeof lib }>(resolve => resolve(({ default: lib }))); +} + +function importLibLoader() { + return new Promise(resolve => resolve(lib)); +} + +// loadable +{ + // Should infer props from imported component with default export + const LoadableDefaultComponent = loadable(defaultImportComponentLoader); + ; + + // Should infer props from imported component without default export + const LoadableComponent = loadable(importComponentLoader); + ; + + // Should allow passing JSX element to fallback in options + loadable(defaultImportComponentLoader, { fallback:

loading...
}); + + // Should allow passing `fallback` prop to loadable component + loading...} />; +} + +// lazy +{ + // Should infer props from imported component with default export + const LazyDefaultComponent = lazy(defaultImportComponentLoader); + ; + + // Should infer props from imported component without default export + const LazyComponent = lazy(importComponentLoader); + ; + + // Should allow passing fallback prop + loading...} />; +} + +// loadable.lib +{ + // Should infer types from module with default export and reflect them in children render prop + const LoadableDefaultLibrary = loadable.lib(defaultImportLibLoader); + + {({ default: { getTestObj } }) => getTestObj().foo} + ; + + // Should infer types from module without default export and reflect them in children render prop + const LoadableLibrary = loadable.lib(importLibLoader); + + {({ getTestObj }) => getTestObj().foo} + ; + + // Should allow passing fallback JSX element + loadable.lib(importLibLoader, { fallback:
loading lib...
}); + + // Should allow passing fallback prop + Loading library...}> + {({ getTestObj }) => getTestObj().foo} + ; + + // Should reflect inferred types from module in ref + const ref = React.createRef(); + ; + ref.current!.getTestObj().foo; +} + +// lazy.lib +{ + // Should infer types from module with default export and reflect them in children render prop + const LazyDefaultLibrary = lazy.lib(defaultImportLibLoader); + + {({ default: { getTestObj } }) => getTestObj().foo} + ; + + // Should infer types from module without default export and reflect them in children render prop + const LazyLibrary = lazy.lib(importLibLoader); + + {({ getTestObj }) => getTestObj().foo} + ; + + // Should allow passing fallback prop + Loading library...}> + {({ getTestObj }) => getTestObj().foo} + ; + + // Should reflect inferred types from module in ref + const ref = React.createRef(); + ; + ref.current!.getTestObj().foo; +} + +// loadableReady +{ + // Should allow passing callback argument + loadableReady(() => {}); + + // Should return a promise + loadableReady().then(() => {}); +} diff --git a/types/loadable__component/tsconfig.json b/types/loadable__component/tsconfig.json new file mode 100644 index 0000000000..440535e42b --- /dev/null +++ b/types/loadable__component/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@loadable/component": [ + "loadable__component" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "loadable__component-tests.tsx" + ] +} diff --git a/types/loadable__component/tslint.json b/types/loadable__component/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/loadable__component/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 23df99dceef7659f8798ddcf46f5fa9dc87fdf0c Mon Sep 17 00:00:00 2001 From: davidgoli Date: Fri, 4 Jan 2019 10:23:21 -0800 Subject: [PATCH 15/15] reorder signatures; implement constructor signature --- types/url-parse/index.d.ts | 3 ++- types/url-parse/url-parse-tests.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/types/url-parse/index.d.ts b/types/url-parse/index.d.ts index 4d33354e9e..8fc22dbfc0 100644 --- a/types/url-parse/index.d.ts +++ b/types/url-parse/index.d.ts @@ -44,9 +44,10 @@ interface URLParse { } declare const URLParse: { + new(address: string, parser?: boolean | URLParse.QueryParser): URLParse; new(address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse; - (address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse; (address: string, parser?: boolean | URLParse.QueryParser): URLParse; + (address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse; extractProtocol(url: string): { slashes: boolean; diff --git a/types/url-parse/url-parse-tests.ts b/types/url-parse/url-parse-tests.ts index be8b8afe8c..b25603763c 100644 --- a/types/url-parse/url-parse-tests.ts +++ b/types/url-parse/url-parse-tests.ts @@ -3,6 +3,7 @@ const parse = URL; new URL('foo/bar', 'https://github.com/'); new URL('foo/bar', 'https://github.com/', (query: string) => ({ query })); +new URL('foo/bar', 'https://github.com/', true); parse('foo/bar', 'https://github.com/'); parse('foo/bar', 'https://github.com/', (query: string) => ({ query })); const result = parse('foo/bar?baz=quux', true);