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 { 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; 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": [ 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 */ 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()); 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" } 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; 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" } 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); diff --git a/types/react-modal/index.d.ts b/types/react-modal/index.d.ts index d04a6b5c18..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.6 +// Type definitions for react-modal 3.8 // 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 { { + const setCookie: string[] = res.get('Set-Cookie'); + }); + // Custom parsers request .post('/search') 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" } diff --git a/types/url-parse/index.d.ts b/types/url-parse/index.d.ts index 58a14f3f4d..8fc22dbfc0 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 @@ -41,7 +44,9 @@ 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, parser?: boolean | URLParse.QueryParser): URLParse; (address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse; extractProtocol(url: string): { diff --git a/types/url-parse/url-parse-tests.ts b/types/url-parse/url-parse-tests.ts index 87904b7f13..b25603763c 100644 --- a/types/url-parse/url-parse-tests.ts +++ b/types/url-parse/url-parse-tests.ts @@ -3,8 +3,13 @@ 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); +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;