diff --git a/types/copy-webpack-plugin/index.d.ts b/types/copy-webpack-plugin/index.d.ts index eedf42f450..59c1b8d0cb 100644 --- a/types/copy-webpack-plugin/index.d.ts +++ b/types/copy-webpack-plugin/index.d.ts @@ -61,7 +61,7 @@ interface CopyWebpackPluginConfiguration { } interface CopyWebpackPlugin { - new (patterns?: CopyPattern[], options?: CopyWebpackPluginConfiguration): Plugin + new (patterns?: (string | CopyPattern)[], options?: CopyWebpackPluginConfiguration): Plugin } declare const copyWebpackPlugin: CopyWebpackPlugin diff --git a/types/dd-trace/package.json b/types/dd-trace/package.json new file mode 100644 index 0000000000..90deb3c97b --- /dev/null +++ b/types/dd-trace/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "opentracing": ">=0.14.1" + } +} diff --git a/types/dd-trace/src/opentracing/reference.d.ts b/types/dd-trace/src/opentracing/reference.d.ts deleted file mode 100644 index 57def49166..0000000000 --- a/types/dd-trace/src/opentracing/reference.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import Span = require('./span'); -import SpanContext = require('./span_context'); - -declare class Reference { - /** - * @return The Reference type (e.g., REFERENCE_CHILD_OF or - * REFERENCE_FOLLOWS_FROM). - */ - type(): string; - - /** - * @return The SpanContext being referred to (e.g., the - * parent in a REFERENCE_CHILD_OF Reference). - */ - referencedContext(): SpanContext; - - /** - * Initialize a new Reference instance. - * - * @param type - the Reference type constant (e.g., - * REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM). - * @param referencedContext - the SpanContext being referred - * to. As a convenience, a Span instance may be passed in instead - * (in which case its .context() is used here). - */ - constructor(type: string, referencedContext: SpanContext | Span); -} - -export = Reference; \ No newline at end of file diff --git a/types/dd-trace/src/opentracing/span.d.ts b/types/dd-trace/src/opentracing/span.d.ts index e61a611efd..cf9286210b 100644 --- a/types/dd-trace/src/opentracing/span.d.ts +++ b/types/dd-trace/src/opentracing/span.d.ts @@ -1,7 +1,8 @@ import Tracer = require('./tracer'); import SpanContext = require('./span_context'); +import { Span } from 'opentracing'; -declare class Span { +declare class DatadogSpan extends Span { /** * Returns the SpanContext object associated with this Span. */ @@ -117,4 +118,4 @@ declare class Span { finish(finishTime?: number): void; } -export = Span; +export = DatadogSpan; diff --git a/types/dd-trace/src/opentracing/span_context.d.ts b/types/dd-trace/src/opentracing/span_context.d.ts index 4e3b532649..cf9565d5a5 100644 --- a/types/dd-trace/src/opentracing/span_context.d.ts +++ b/types/dd-trace/src/opentracing/span_context.d.ts @@ -1,3 +1,5 @@ +import { SpanContext } from 'opentracing'; + /** * SpanContext represents Span state that must propagate to descendant Spans * and across process boundaries. @@ -8,7 +10,7 @@ * identify or otherwise contextualize the associated Span instance (e.g., a * tuple). */ -declare class SpanContext { +declare class DatadogSpanContext extends SpanContext { /** * Use to create references to parent spans. */ @@ -35,4 +37,4 @@ interface SpanContextLike { spanId: number; } -export = SpanContext; +export = DatadogSpanContext; diff --git a/types/dd-trace/src/opentracing/span_options.d.ts b/types/dd-trace/src/opentracing/span_options.d.ts deleted file mode 100644 index 054d9024d1..0000000000 --- a/types/dd-trace/src/opentracing/span_options.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -import Span = require('./span'); -import Reference = require('./reference'); -import SpanContext = require('./span_context'); - -interface SpanOptions { - /** - * a parent SpanContext (or Span, for convenience) that the newly-started - * span will be the child of (per REFERENCE_CHILD_OF). If specified, - * `references` must be unspecified. - */ - childOf?: Span | SpanContext; - - /** - * an array of Reference instances, each pointing to a causal parent - * SpanContext. If specified, `fields.childOf` must be unspecified. - */ - references?: Reference[]; - - /** - * set of key-value pairs which will be set as tags on the newly created - * Span. Ownership of the object is passed to the created span for - * efficiency reasons (the caller should not modify this object after - * calling startSpan). - */ - tags?: { - [key: string]: any; - }; - - /** - * a manually specified start time for the created Span object. The time - * should be specified in milliseconds as Unix timestamp. Decimal value are - * supported to represent time values with sub-millisecond accuracy. - */ - startTime?: number; -} - -export = SpanOptions; diff --git a/types/dd-trace/src/opentracing/tracer.d.ts b/types/dd-trace/src/opentracing/tracer.d.ts index a40559dbcd..252a0d558c 100644 --- a/types/dd-trace/src/opentracing/tracer.d.ts +++ b/types/dd-trace/src/opentracing/tracer.d.ts @@ -1,91 +1,11 @@ -import SpanOptions = require('./span_options'); -import Span = require('./span'); -import SpanContext = require('./span_context'); +import { Tracer } from 'opentracing'; /** * Tracer is the entry-point between the instrumentation API and the tracing * implementation. */ -declare class Tracer { - /** - * Starts and returns a new Span representing a logical unit of work. - * - * For example: - * - * // Start a new (parentless) root Span: - * var parent = Tracer.startSpan('DoWork'); - * - * // Start a new (child) Span: - * var child = Tracer.startSpan('load-from-db', { - * childOf: parent.context(), - * }); - * - * // Start a new async (FollowsFrom) Span: - * var child = Tracer.startSpan('async-cache-write', { - * references: [ - * opentracing.followsFrom(parent.context()) - * ], - * }); - * - * @param name - the name of the operation (REQUIRED). - * @param options - options for the newly created span. - * @return A new Span object. - */ - startSpan(name: string, options?: SpanOptions): Span; +declare class DatadogTracer extends Tracer { - /** - * Injects the given SpanContext instance for cross-process propagation - * within `carrier`. The expected type of `carrier` depends on the value of - * `format. - * - * OpenTracing defines a common set of `format` values (see - * FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has - * an expected carrier type. - * - * Consider this pseudocode example: - * - * var clientSpan = ...; - * ... - * // Inject clientSpan into a text carrier. - * var headersCarrier = {}; - * Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier); - * // Incorporate the textCarrier into the outbound HTTP request header - * // map. - * Object.assign(outboundHTTPReq.headers, headersCarrier); - * // ... send the httpReq - * - * @param spanContext - the SpanContext to inject into the - * carrier object. As a convenience, a Span instance may be passed - * in instead (in which case its .context() is used for the - * inject()). - * @param format - the format of the carrier. - * @param carrier - see the documentation for the chosen `format` - * for a description of the carrier object. - */ - inject(spanContext: SpanContext | Span, format: string, carrier: any): void; - - /** - * Returns a SpanContext instance extracted from `carrier` in the given - * `format`. - * - * OpenTracing defines a common set of `format` values (see - * FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has - * an expected carrier type. - * - * Consider this pseudocode example: - * - * // Use the inbound HTTP request's headers as a text map carrier. - * var headersCarrier = inboundHTTPReq.headers; - * var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier); - * var serverSpan = Tracer.startSpan('...', { childOf : wireCtx }); - * - * @param format - the format of the carrier. - * @param carrier - the type of the carrier object is determined by - * the format. - * @return The extracted SpanContext, or null if no such SpanContext could - * be found in `carrier` - */ - extract(format: string, carrier: any): SpanContext | null; } -export = Tracer; +export = DatadogTracer; diff --git a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts index 9043cdaf0e..51f8964423 100644 --- a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts +++ b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts @@ -95,13 +95,15 @@ const withSourceAndArgsAndContextTyped = createBatchResolver< SomeTestResult, SomeTestArgs, SomeTestContext ->(async (sources, args, context) => { +>(async (sources, args, context, info) => { // $ExpectType ReadonlyArray const verifySources = sources; // $ExpectType string const verifyArgs = args.someArg; // $ExpectType string const verifyContext = context.someContextProp; + // $ExpectType GraphQLResolveInfo + const verifyInfo = info; const result = await asyncBatchFunction(sources); return result; diff --git a/types/graphql-resolve-batch/index.d.ts b/types/graphql-resolve-batch/index.d.ts index ea90a83555..9908b7082a 100644 --- a/types/graphql-resolve-batch/index.d.ts +++ b/types/graphql-resolve-batch/index.d.ts @@ -4,6 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 +import { GraphQLResolveInfo } from 'graphql'; + /** * Creates a GraphQL.js field resolver that batches together multiple resolves * together that share the *exact* same GraphQL field selection. @@ -45,5 +47,6 @@ export type ResolverFunction = ( export type BatchResolveFunction = ( sources: ReadonlyArray, args: TArgs, - context: TContext + context: TContext, + info: GraphQLResolveInfo ) => TReturn[] | Promise; diff --git a/types/is-uuid/index.d.ts b/types/is-uuid/index.d.ts new file mode 100644 index 0000000000..f6e1f8626b --- /dev/null +++ b/types/is-uuid/index.d.ts @@ -0,0 +1,46 @@ +// Type definitions for is-uuid 1.0 +// Project: https://github.com/afram/is-uuid#readme +// Definitions by: André Thériault +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Returns true if the value is a v1 UUID + * @param value The value to test + */ +export function v1(value: string): boolean; + +/** + * Returns true if the value is a v2 UUID + * @param value The value to test + */ +export function v2(value: string): boolean; + +/** + * Returns true if the value is a v3 UUID + * @param value The value to test + */ +export function v3(value: string): boolean; + +/** + * Returns true if the value is a v4 UUID + * @param value The value to test + */ +export function v4(value: string): boolean; + +/** + * Returns true if the value is a v5 UUID + * @param value The value to test + */ +export function v5(value: string): boolean; + +/** + * Returns true if the value is a nil UUID + * @param value The value to test + */ +export function nil(value: string): boolean; + +/** + * Returns true for v1 - v5 UUID. Will return false for nil UUID + * @param value The value to test + */ +export function anyNonNil(value: string): boolean; diff --git a/types/is-uuid/is-uuid-tests.ts b/types/is-uuid/is-uuid-tests.ts new file mode 100644 index 0000000000..4e07b10905 --- /dev/null +++ b/types/is-uuid/is-uuid-tests.ts @@ -0,0 +1,10 @@ +import * as isUUID from 'is-uuid'; + +isUUID.v1('857b3f0a-a777-11e5-bf7f-feff819cdc9f'); +isUUID.v2('9a7b330a-a736-21e5-af7f-feaf819cdc9f'); +isUUID.v3('0a7b330a-a736-35ea-8f7f-feaf019cdc00'); +isUUID.v4('c51c80c2-66a1-442a-91e2-4f55b4256a72'); +isUUID.v5('5a2de30a-a736-5aea-8f7f-ad0f019cdc00'); + +isUUID.anyNonNil('c51c80c2-66a1-442a-91e2-4f55b4256a72'); +isUUID.nil('00000000-0000-0000-0000-000000000000'); diff --git a/types/is-uuid/tsconfig.json b/types/is-uuid/tsconfig.json new file mode 100644 index 0000000000..eec8e9597a --- /dev/null +++ b/types/is-uuid/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "is-uuid-tests.ts" + ] +} diff --git a/types/is-uuid/tslint.json b/types/is-uuid/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-uuid/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 821e7ec162..b03a48dc6f 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -146,12 +146,24 @@ interface JQueryStatic { * Return a collection of matched elements either found in the DOM based on passed argument(s) or created * by passing an HTML string. * - * @param element_elementArray A DOM element to wrap in a jQuery object. - * An array containing a set of DOM elements to wrap in a jQuery object. + * @param element A DOM element to wrap in a jQuery object. * @see \`{@link https://api.jquery.com/jQuery/ }\` * @since 1.0 */ - (element_elementArray: T | ArrayLike): JQuery; + // Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810) + // tslint:disable-next-line:unified-signatures + (element: T): JQuery; + /** + * Return a collection of matched elements either found in the DOM based on passed argument(s) or created + * by passing an HTML string. + * + * @param elementArray An array containing a set of DOM elements to wrap in a jQuery object. + * @see \`{@link https://api.jquery.com/jQuery/ }\` + * @since 1.0 + */ + // Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810) + // tslint:disable-next-line:unified-signatures + (elementArray: T[]): JQuery; /** * Return a collection of matched elements either found in the DOM based on passed argument(s) or created * by passing an HTML string. diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 309b1e2f89..417d2e7941 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -69,6 +69,12 @@ function JQueryStatic() { // $ExpectType JQuery $(); + // $ExpectType JQuery + $(new HTMLSelectElement()); + + // $ExpectType JQuery + $([new HTMLSelectElement()]); + // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19597#issuecomment-378218432 function issue_19597_378218432() { const myDiv = $(document.createElement('div')); diff --git a/types/node/index.d.ts b/types/node/index.d.ts index b702085203..63b06965f6 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -26,6 +26,7 @@ // Lishude // Andrew Makarov // Zane Hannan AU +// Thomas den Hollander // Eugene Y. Q. Shen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -172,6 +173,10 @@ interface SymbolConstructor { readonly asyncIterator: symbol; } declare var Symbol: SymbolConstructor; +interface SharedArrayBuffer { + readonly byteLength: number; + slice(begin?: number, end?: number): SharedArrayBuffer; +} // Node.js ESNEXT support interface String { @@ -349,13 +354,13 @@ declare var Buffer: { new(array: Uint8Array): Buffer; /** * Produces a Buffer backed by the same allocated memory as - * the given {ArrayBuffer}. + * the given {ArrayBuffer}/{SharedArrayBuffer}. * * * @param arrayBuffer The ArrayBuffer with which to share memory. * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead. */ - new(arrayBuffer: ArrayBuffer): Buffer; + new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer; /** * Allocates a new buffer containing the given {array} of octets. * @@ -379,8 +384,7 @@ declare var Buffer: { * * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer() */ - from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; - // from(arrayBuffer: SharedArrayBuffer, byteOffset?: number, length?: number): Buffer; + from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer; /** * Creates a new Buffer using the passed {data} * @param data data to create a new Buffer @@ -418,7 +422,7 @@ declare var Buffer: { * @param string string to test. * @param encoding encoding used to evaluate (defaults to 'utf8') */ - byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer /*| SharedArrayBuffer */, encoding?: string): number; + byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: string): number; /** * Returns a buffer which is the result of concatenating all the buffers in the list together. * diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 46154ce254..a7fcd4d44a 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -446,6 +446,11 @@ function bufferTests() { const arrUint8: Uint8Array = new Uint8Array(2); const buf5: Buffer = Buffer.from(arrUint8); const buf6: Buffer = Buffer.from(buf1); + const sharedArrayBuffer: SharedArrayBuffer = { + byteLength: 10, + slice: (begin?: number, end?: number) => sharedArrayBuffer + }; + const buf7: Buffer = Buffer.from(sharedArrayBuffer); } // Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]]) diff --git a/types/puppeteer/puppeteer-tests.ts b/types/puppeteer/puppeteer-tests.ts index 96cb4fd361..e883157fec 100644 --- a/types/puppeteer/puppeteer-tests.ts +++ b/types/puppeteer/puppeteer-tests.ts @@ -27,8 +27,8 @@ import * as puppeteer from "puppeteer"; // Get the "viewport" of the page, as reported by the page. const dimensions = await page.evaluate(() => { return { - width: document.documentElement.clientWidth, - height: document.documentElement.clientHeight, + width: document.documentElement!.clientWidth, + height: document.documentElement!.clientHeight, deviceScaleFactor: window.devicePixelRatio }; }); @@ -300,7 +300,7 @@ puppeteer.launch().then(async browser => { someElement; // $ExpectType ElementHandle // If one passes an ElementHandle, puppeteer will unwrap its DOM reference instead - await page.$eval('.hello-world', (e, x1: HTMLDivElement) => x1.noWrap, someElement); + await page.$eval('.hello-world', (e, x1) => (x1 as any).noWrap, someElement); browser.close(); })(); diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 5a49af5685..184fc39724 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -4754,7 +4754,7 @@ declare class MaskedViewComponent extends React.Component {} declare const MaskedViewBase: Constructor & typeof MaskedViewComponent; export class MaskedViewIOS extends MaskedViewBase {} -export interface ModalProps { +export interface ModalBaseProps { // Only `animated` is documented. The JS code says `animated` is // deprecated and `animationType` is preferred. animated?: boolean; @@ -4784,35 +4784,42 @@ export interface ModalProps { * The `onShow` prop allows passing a function that will be called once the modal has been shown. */ onShow?: (event: NativeSyntheticEvent) => void; +} + +export interface ModalPropsIOS { + /** + * The `presentationStyle` determines the style of modal to show + */ + presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen"; + /** * The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations. * On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field. - * @platform ios */ - supportedOrientations?: ( - | "portrait" - | "portrait-upside-down" - | "landscape" - | "landscape-left" - | "landscape-right")[]; + supportedOrientations?: Array<"portrait" | "portrait-upside-down" | "landscape" | "landscape-left" | "landscape-right">; + + /** + * The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed. + */ + onDismiss?: () => void; + /** * The `onOrientationChange` callback is called when the orientation changes while the modal is being displayed. * The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation. - * @platform ios */ onOrientationChange?: (event?: NativeSyntheticEvent) => void; - /** - * The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed. - * @platform ios - */ - onDismiss?: () => void; - /** - * The `presentationStyle` determines the style of modal to show - * @platform ios - */ - presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen"; } +export interface ModalPropsAndroid { + /** + * Controls whether to force hardware acceleration for the underlying window. + */ + hardwareAccelerated?: boolean; +} + + +export type ModalProps = ModalBaseProps & ModalPropsIOS & ModalPropsAndroid; + export class Modal extends React.Component {} /** diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 0399d41321..60c4d89302 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -71,6 +71,7 @@ import { TextInputSubmitEditingEventData, WebView, KeyboardAvoidingView, + Modal, } from "react-native"; declare module "react-native" { @@ -754,3 +755,7 @@ const AlertIOSTest = () => { 'email-address' ); } + +const ModalTest = () => ( + +) diff --git a/types/react-router-hash-link/index.d.ts b/types/react-router-hash-link/index.d.ts new file mode 100644 index 0000000000..9480f1aef0 --- /dev/null +++ b/types/react-router-hash-link/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for react-router-hash-link 1.2 +// Project: https://github.com/rafrex/react-router-hash-link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: Sam Baeck +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; +import { LinkProps, NavLinkProps } from 'react-router-dom'; + +export interface HashLinkProps extends LinkProps { + smooth?: boolean; + scroll?: (element: HTMLElement) => void; +} + +export class HashLink extends React.Component {} + +export interface NavHashLinkProps extends NavLinkProps, HashLinkProps {} + +export class NavHashLink extends React.Component {} diff --git a/types/react-router-hash-link/react-router-hash-link-tests.tsx b/types/react-router-hash-link/react-router-hash-link-tests.tsx new file mode 100644 index 0000000000..4c64a1b5c3 --- /dev/null +++ b/types/react-router-hash-link/react-router-hash-link-tests.tsx @@ -0,0 +1,24 @@ +import * as H from 'history'; +import * as React from 'react'; +import { match } from 'react-router'; +import { HashLink, NavHashLink, NavHashLinkProps } from 'react-router-hash-link'; + +interface Props extends NavHashLinkProps { + extraProp: string; +} + +const getIsActive = (extraProp: string) => (match: match, location: H.Location) => !!extraProp; + +export default function(props: Props) { + const {extraProp, ...rest} = props; + const isActive = getIsActive(extraProp); + return ( + + ); +} + +; + +const acceptRef = (node: HTMLAnchorElement | null) => { +}; +; diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json new file mode 100644 index 0000000000..fc830ac41d --- /dev/null +++ b/types/react-router-hash-link/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-router-hash-link-tests.tsx" + ] +} diff --git a/types/react-router-hash-link/tslint.json b/types/react-router-hash-link/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-router-hash-link/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react/index.d.ts b/types/react/index.d.ts index ce586b0869..e8de06ef62 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -1459,6 +1459,7 @@ declare namespace React { interface ImgHTMLAttributes extends HTMLAttributes { alt?: string; crossOrigin?: "anonymous" | "use-credentials" | ""; + decoding?: "async" | "auto" | "sync"; height?: number | string; sizes?: string; src?: string; diff --git a/types/select2/select2-tests.ts b/types/select2/select2-tests.ts index b3ce0d5896..a351dcc178 100644 --- a/types/select2/select2-tests.ts +++ b/types/select2/select2-tests.ts @@ -774,7 +774,7 @@ const selectedData: Select2.OptionData[] = $("#mySelect2").select2("data"); // jQuery Generic declare let select: HTMLSelectElement; -const $select: JQuery = $(select) as JQuery; +const $select: JQuery = $(select); select = $select.select2().get(0); select = $select.select2({tags: true}).get(0); diff --git a/types/shallow-equals/index.d.ts b/types/shallow-equals/index.d.ts new file mode 100644 index 0000000000..7d91b03923 --- /dev/null +++ b/types/shallow-equals/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for shallow-equals 1.0 +// Project: https://github.com/hughsk/shallow-equals +// Definitions by: Ross Solomon +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = shallow_equals; + +declare function shallow_equals( + a?: A, + b?: B, + compare?: (objA: A, objB: B) => boolean, +): boolean; diff --git a/types/shallow-equals/shallow-equals-tests.ts b/types/shallow-equals/shallow-equals-tests.ts new file mode 100644 index 0000000000..87512c9f43 --- /dev/null +++ b/types/shallow-equals/shallow-equals-tests.ts @@ -0,0 +1,19 @@ +import shallowEquals = require('shallow-equals'); + +interface A { + foo: string; +} + +interface B { + foo: string; + bar?: string; +} + +const a: A = { foo: 'bar' }; +const b: B = { foo: 'baz' }; +function compare(a: A, b: B) { + return false; +} + +shallowEquals(a, b); +shallowEquals(a, b, compare); diff --git a/types/shallow-equals/tsconfig.json b/types/shallow-equals/tsconfig.json new file mode 100644 index 0000000000..83137182f4 --- /dev/null +++ b/types/shallow-equals/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "shallow-equals-tests.ts"] +} diff --git a/types/shallow-equals/tslint.json b/types/shallow-equals/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/shallow-equals/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/steam-login/index.d.ts b/types/steam-login/index.d.ts new file mode 100644 index 0000000000..849a45b920 --- /dev/null +++ b/types/steam-login/index.d.ts @@ -0,0 +1,61 @@ +// Type definitions for steam-login 0.1 +// Project: http://github.com/cpancake/steam-login +// Definitions by: Nick Winans +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { Request, RequestHandler } from 'express'; + +export interface MiddlewareOptions { + verify: string; + realm: string; + apiKey: string; + useSession?: boolean; +} + +export interface SteamUser { + _json: { + steamid: string; + personaname: string; + profileurl: string; + avatar: string; + avatarmedium: string; + avatarfull: string; + personastate: number; + communityvisibilitystate: number; + profilestate?: number; + lastlogoff: number; + commentpermission?: number; + realname?: string; + primaryclanid?: string; + timecreated?: number; + gameid?: string; + gameserverip?: string; + gameextrainfo?: string; + loccountrycode?: string; + locstatecode?: string; + loccityid?: number; + }; + steamid: string; + username: string; + name: string; + profile: string; + avatar: { + small: string; + medium: string; + large: string; + }; +} + +export interface SteamRequest extends Request { + logout?(): (req: Request) => () => void; + user?: SteamUser; +} + +export function middleware(opts: MiddlewareOptions): RequestHandler; + +export function enforceLogin(redirect: string): RequestHandler; + +export function verify(): RequestHandler; + +export function authenticate(): RequestHandler; diff --git a/types/steam-login/steam-login-tests.ts b/types/steam-login/steam-login-tests.ts new file mode 100644 index 0000000000..84eae31a01 --- /dev/null +++ b/types/steam-login/steam-login-tests.ts @@ -0,0 +1,35 @@ +// Port of https://github.com/cpancake/steam-login/blob/master/example.js + +import * as express from 'express'; +import * as steam from 'steam-login'; +import * as session from 'express-session'; + +const app = express(); + +app.use(session({ resave: false, saveUninitialized: false, secret: 'a secret' })); +app.use(steam.middleware({ + realm: 'http://localhost:3000/', + verify: 'http://localhost:3000/verify', + apiKey: process.argv[2] +} +)); + +app.get('/', (req: steam.SteamRequest, res) => { + res.send(req.user == null ? 'not logged in' : 'hello ' + req.user.username).end(); +}); + +app.get('/authenticate', steam.authenticate(), (req, res) => { + res.redirect('/'); +}); + +app.get('/verify', steam.verify(), (req: steam.SteamRequest, res) => { + res.send(req.user).end(); +}); + +app.get('/logout', steam.enforceLogin('/'), (req: steam.SteamRequest, res) => { + req.logout ? req.logout() : null; + res.redirect('/'); +}); + +app.listen(3000); +console.log('listening'); diff --git a/types/steam-login/tsconfig.json b/types/steam-login/tsconfig.json new file mode 100644 index 0000000000..8548e16277 --- /dev/null +++ b/types/steam-login/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", + "steam-login-tests.ts" + ] +} diff --git a/types/steam-login/tslint.json b/types/steam-login/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/steam-login/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/superagent-bunyan/index.d.ts b/types/superagent-bunyan/index.d.ts new file mode 100644 index 0000000000..1dfec979e4 --- /dev/null +++ b/types/superagent-bunyan/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for superagent-bunyan 5.2 +// Project: https://github.com/joaquimserafim/superagent-bunyan#readme +// Definitions by: Alex Brick +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import * as Logger from 'bunyan'; +import { Plugin } from 'superagent'; + +declare function superagentLogger(logger: Logger, requestId?: string, extra?: object): Plugin; + +export = superagentLogger; diff --git a/types/superagent-bunyan/superagent-bunyan-tests.ts b/types/superagent-bunyan/superagent-bunyan-tests.ts new file mode 100644 index 0000000000..3a6f973e91 --- /dev/null +++ b/types/superagent-bunyan/superagent-bunyan-tests.ts @@ -0,0 +1,16 @@ +import * as request from 'superagent'; +import * as bunyan from 'bunyan'; + +import superagentLogger = require('superagent-bunyan'); + +const logger = bunyan.createLogger({name: 'my_log'}); + +logger.info('Hey!'); + +request + .get('http://localhost:3000') + .use(superagentLogger(logger)) + .use(superagentLogger(logger, 'requestId')) + .use(superagentLogger(logger, 'requestId', { foo: 'bar' })) + .use(superagentLogger(logger, undefined, { foo: 'bar' })) + .end((err, res) => {}); diff --git a/types/superagent-bunyan/tsconfig.json b/types/superagent-bunyan/tsconfig.json new file mode 100644 index 0000000000..0118838dcd --- /dev/null +++ b/types/superagent-bunyan/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", + "superagent-bunyan-tests.ts" + ] +} diff --git a/types/superagent-bunyan/tslint.json b/types/superagent-bunyan/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/superagent-bunyan/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ttf2woff2/index.d.ts b/types/ttf2woff2/index.d.ts new file mode 100644 index 0000000000..180c64f93e --- /dev/null +++ b/types/ttf2woff2/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for ttf2woff2 2.0 +// Project: https://github.com/nfroidure/ttf2woff2 +// Definitions by: Thomas den Hollander +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function ttf2woff2(inputContent: Buffer): Buffer; + +export = ttf2woff2; diff --git a/types/ttf2woff2/tsconfig.json b/types/ttf2woff2/tsconfig.json new file mode 100644 index 0000000000..0b6fc9778b --- /dev/null +++ b/types/ttf2woff2/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "ttf2woff2-tests.ts" + ] +} diff --git a/types/ttf2woff2/tslint.json b/types/ttf2woff2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ttf2woff2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ttf2woff2/ttf2woff2-tests.ts b/types/ttf2woff2/ttf2woff2-tests.ts new file mode 100644 index 0000000000..71b5a16d65 --- /dev/null +++ b/types/ttf2woff2/ttf2woff2-tests.ts @@ -0,0 +1,4 @@ +import ttf2woff2 = require('ttf2woff2'); + +const input = Buffer.alloc(10); +const result: Buffer = ttf2woff2(input); diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 8822deca98..72498e3591 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -1,13 +1,13 @@ // Type definitions for Underscore 1.8 // Project: http://underscorejs.org/ -// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman +// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman , Ard Timmerman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var _: _.UnderscoreStatic; export = _; export as namespace _; -// The DOM is not required to be present, but these definitions reference type Element for the +// The DOM is not required to be present, but these definitions reference type Element for the // isElement check. If the DOM is present, this declaration will merge. declare global { interface Element { } @@ -3631,7 +3631,7 @@ declare module _ { * @param object Convert this object to a list of [key, value] pairs. * @return List of [key, value] pairs on `object`. **/ - pairs(object: any): any[][]; + pairs(object: any): [string, any][]; /** * Returns a copy of the object where the keys have become the values and the values the keys. @@ -4738,7 +4738,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): any[][]; + pairs(): [string, any][]; /** * Wrapped type `object`. @@ -5692,7 +5692,7 @@ declare module _ { * Wrapped type `object`. * @see _.values **/ - values(): _Chain; + values(): _Chain; /** * Wrapped type `object`. @@ -5704,7 +5704,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): _Chain; + pairs(): _Chain<[string, any]>; /** * Wrapped type `object`. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 419479f689..6175c1874b 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -527,6 +527,16 @@ function chain_tests() { .keys() // return ['foo', 'bar'] : string[] .pairs() // return [['foo', '0'], ['bar', '1']] : string[][] .value(); + + interface IYears { + 2016: number; + 2017: number; + } + + let yearObject: IYears = {2016: 1, 2017: 2}; + let valuePerYear: number[] = _.chain(yearObject) + .values() + .value() } var obj: { [k: string] : number } = { diff --git a/types/universal-cookie/index.d.ts b/types/universal-cookie/index.d.ts new file mode 100644 index 0000000000..4bba4adee6 --- /dev/null +++ b/types/universal-cookie/index.d.ts @@ -0,0 +1,102 @@ +// Type definitions for universal-cookie 2.2 +// Project: https://github.com/reactivestack/cookies/tree/master/packages/universal-cookie#readme +// Definitions by: Tomi Turtiainen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export interface CookiesByName { + [cookieName: string]: string; +} + +export interface GetOpts { + /** + * do not convert the cookie into an object no matter what + */ + doNotParse: boolean; +} + +export interface CookieOpts { + /** + * cookie path, use / as the path if you want your cookie to be accessible on all pages + */ + path?: string; + + /** + * absolute expiration date for the cookie + */ + expires?: Date; + + /** + * relative max age of the cookie from when the client receives it in second + */ + maxAge?: number; + + /** + * domain for the cookie (sub.domain.com or .allsubdomains.com) + */ + domain?: string; + + /** + * Is only accessible through HTTPS? + */ + secure?: boolean; + + /** + * Is only the server can access the cookie? + */ + httpOnly?: boolean; +} + +export type ChangeListenerCallback = ( + name: string, + value: string | object, + options: CookieOpts +) => void; + +export default class Cookies { + constructor(cookieHeader?: string | CookiesByName); + + /** + * Get a cookie value + * + * @param name cookie name + * @param options.doNotParse do not convert the cookie into an object no matter what + */ + get(name: string, options?: GetOpts): string; + + /** + * Get all cookies + * + * @param options.doNotParse do not convert the cookie into an object no matter what + */ + getAll(options?: GetOpts): CookiesByName; + + /** + * Set a cookie value + * + * @param name cookie name + * @param value save the value and stringify the object if needed + * @param options Support all the cookie options from RFC 6265 + */ + set(name: string, value: string | object, options?: CookieOpts): void; + + /** + * Set a cookie value + * + * @param name cookie name + * @param options Support all the cookie options from RFC 6265 + */ + remove(name: string, options?: CookieOpts): void; + + /** + * Add a listener to when a cookie is set or removed. + * + * @param callback Call that will be called with the first argument containing name, value and options of the changed cookie. + */ + addChangeListener(callback: ChangeListenerCallback): void; + + /** + * Remove a listener from the change callback. + */ + removeChangeListener(callback: ChangeListenerCallback): void; +} diff --git a/types/universal-cookie/tsconfig.json b/types/universal-cookie/tsconfig.json new file mode 100644 index 0000000000..1c324ed8c6 --- /dev/null +++ b/types/universal-cookie/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "universal-cookie-tests.ts"] +} diff --git a/types/universal-cookie/tslint.json b/types/universal-cookie/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/universal-cookie/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/universal-cookie/universal-cookie-tests.ts b/types/universal-cookie/universal-cookie-tests.ts new file mode 100644 index 0000000000..9591fa3c5b --- /dev/null +++ b/types/universal-cookie/universal-cookie-tests.ts @@ -0,0 +1,20 @@ +import Cookies from "universal-cookie"; + +const cookies = new Cookies(); +new Cookies("My=Cookie"); +new Cookies({}); + +cookies.set("my", "cookie"); +cookies.set("object", { some: "value" }); +cookies.set("with", "options", { + path: "/" +}); + +cookies.get("my"); +cookies.getAll(); + +cookies.remove("object"); +cookies.remove("object", { path: "/" }); + +cookies.addChangeListener((name, value) => {}); +cookies.removeChangeListener((name, value) => {}); diff --git a/types/varint/index.d.ts b/types/varint/index.d.ts new file mode 100644 index 0000000000..ec490a2e70 --- /dev/null +++ b/types/varint/index.d.ts @@ -0,0 +1,46 @@ +// Type definitions for varint 5.0 +// Project: https://github.com/chrisdickinson/varint#readme +// Definitions by: David Brockman Smoliansky +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export const encode: { + /** + * Encodes `num` into `buffer` starting at `offset`. returns `buffer`, with the encoded varint written into it. + * `varint.encode.bytes` will now be set to the number of bytes modified. + */ + (num: number, buffer: Buffer, offset?: number): Buffer; + + /** + * Encodes `num` into `array` starting at `offset`. returns `array`, with the encoded varint written into it. + * If `array` is not provided, it will default to a new array. + * `varint.encode.bytes` will now be set to the number of bytes modified. + */ + (num: number, array?: number[], offset?: number): number[]; + + /** + * Similar to `decode.bytes` when encoding a number it can be useful to know how many bytes where written (especially if you pass an output array). + * You can access this via `varint.encode.bytes` which holds the number of bytes written in the last encode. + */ + bytes: number; +}; + +export const decode: { + /** + * Decodes `data`, which can be either a buffer or array of integers, from position `offset` or default 0 and returns the decoded original integer. + * Throws a `RangeError` when `data` does not represent a valid encoding. + */ + (buf: Buffer | number[], offset?: number): number; + + /** + * If you also require the length (number of bytes) that were required to decode the integer you can access it via `varint.decode.bytes`. + * This is an integer property that will tell you the number of bytes that the last .decode() call had to use to decode. + */ + bytes: number; +}; + +/** + * returns the number of bytes this number will be encoded as, up to a maximum of 8. + */ +export function encodingLength(num: number): number; diff --git a/types/varint/tsconfig.json b/types/varint/tsconfig.json new file mode 100644 index 0000000000..269a7016fe --- /dev/null +++ b/types/varint/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "varint-tests.ts"] +} diff --git a/types/varint/tslint.json b/types/varint/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/varint/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/varint/varint-tests.ts b/types/varint/varint-tests.ts new file mode 100644 index 0000000000..4ef8c91753 --- /dev/null +++ b/types/varint/varint-tests.ts @@ -0,0 +1,17 @@ +import { decode, encode, encodingLength } from 'varint'; + +encode(0); // $ExpectType number[] +encode(0, []); // $ExpectType number[] +encode(0, [], 0); // $ExpectType number[] + +encode(0, Buffer.alloc(1)); // $ExpectType Buffer +encode(0, Buffer.alloc(1), 0); // $ExpectType Buffer + +encode.bytes; // $ExpectType number + +decode(Buffer.alloc(1)); // $ExpectType number +decode(Buffer.alloc(1), 0); // $ExpectType number + +decode.bytes; // $ExpectType number + +encodingLength(0); // $ExpectType number diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index a228afc242..664439523b 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -117,7 +117,7 @@ declare namespace webpack { [name: string]: string | string[]; } - type EntryFunc = () => (string | string[] | Promise); + type EntryFunc = () => (string | string[] | Entry | Promise); interface DevtoolModuleFilenameTemplateInfo { identifier: string; diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index 2f75d11b31..16234d422a 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -55,6 +55,14 @@ configuration = { entry: () => ['./demo', './demo2'] }; +configuration = { + entry: () => ({ + p1: "./page1", + p2: "./page2", + p3: "./page3" + }) +}; + configuration = { entry: () => new Promise((resolve) => resolve('./demo')) }; @@ -63,6 +71,14 @@ configuration = { entry: () => new Promise((resolve) => resolve(['./demo', './demo2'])) }; +configuration = { + entry: () => new Promise((resolve) => resolve({ + p1: "./page1", + p2: "./page2", + p3: "./page3" + })) +}; + // // https://webpack.github.io/docs/optimization.html //