From ccb674adc72864b791b0b4f12b4e522733774c6f Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 10:00:58 +0200 Subject: [PATCH 01/32] Changed types for chained functions and added tests --- types/underscore/index.d.ts | 6 +++--- types/underscore/underscore-tests.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 8822deca98..db45cf606b 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -7,7 +7,7 @@ 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 { } @@ -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; /** * Wrapped type `object`. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 419479f689..220bbcb0ef 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -527,6 +527,20 @@ 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() + + let keyValuePerYear: (string|number)[][] = _.chain(yearObject) + .pairs() + .value() } var obj: { [k: string] : number } = { From 017ffb7238ce29d3a2bf9d066080c8dc18c4ab8f Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 11:19:40 +0200 Subject: [PATCH 02/32] Updated types for pairs --- types/underscore/index.d.ts | 4 ++-- types/underscore/underscore-tests.ts | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index db45cf606b..94ed13d099 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -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`. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 220bbcb0ef..6175c1874b 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -537,10 +537,6 @@ function chain_tests() { let valuePerYear: number[] = _.chain(yearObject) .values() .value() - - let keyValuePerYear: (string|number)[][] = _.chain(yearObject) - .pairs() - .value() } var obj: { [k: string] : number } = { From 2d9422f0cbfab797ad64f786ee33627af90d7fc0 Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 11:22:38 +0200 Subject: [PATCH 03/32] Added my name --- types/underscore/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 94ed13d099..27346d414d 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -1,6 +1,6 @@ // 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; From 7146aa04998d5453240fc273caa584cdf4e87d7c Mon Sep 17 00:00:00 2001 From: Confusus Date: Thu, 2 Aug 2018 11:29:05 +0200 Subject: [PATCH 04/32] Added space after comment which was removed by my editor --- types/underscore/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 27346d414d..95ff48eddc 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -7,7 +7,7 @@ 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 { } From 89eff5086697c1a254da6e0fe63aa46f8d61b543 Mon Sep 17 00:00:00 2001 From: Confusus Date: Wed, 8 Aug 2018 09:14:15 +0200 Subject: [PATCH 05/32] Changed pairs of chain from any to [string, any] --- types/underscore/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 95ff48eddc..72498e3591 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -7,7 +7,7 @@ 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 { } @@ -5704,7 +5704,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): _Chain; + pairs(): _Chain<[string, any]>; /** * Wrapped type `object`. From 094f7394b1506af12d18a777b879b07c0f00405c Mon Sep 17 00:00:00 2001 From: mail6543210 Date: Fri, 3 Aug 2018 21:07:41 +0800 Subject: [PATCH 06/32] CopyWebpackPlugin accepts string[] too --- types/copy-webpack-plugin/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 641c48d48e5cbe1b9fd22cb3677c32eddf275ad7 Mon Sep 17 00:00:00 2001 From: Thomas den Hollander Date: Thu, 9 Aug 2018 11:55:41 +0200 Subject: [PATCH 07/32] Add types for ttf2woff2 --- types/ttf2woff2/index.d.ts | 10 ++++++++++ types/ttf2woff2/tsconfig.json | 23 +++++++++++++++++++++++ types/ttf2woff2/tslint.json | 1 + types/ttf2woff2/ttf2woff2-tests.ts | 4 ++++ 4 files changed, 38 insertions(+) create mode 100644 types/ttf2woff2/index.d.ts create mode 100644 types/ttf2woff2/tsconfig.json create mode 100644 types/ttf2woff2/tslint.json create mode 100644 types/ttf2woff2/ttf2woff2-tests.ts diff --git a/types/ttf2woff2/index.d.ts b/types/ttf2woff2/index.d.ts new file mode 100644 index 0000000000..be49b9099d --- /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: My Self +// 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); From 1b962508348c0904128ffbad01cd9040938a1a47 Mon Sep 17 00:00:00 2001 From: David Brockman Smoliansky Date: Mon, 13 Aug 2018 17:29:03 +0200 Subject: [PATCH 08/32] add types for package varint Add types for [varint](https://github.com/chrisdickinson/varint) --- types/varint/index.d.ts | 46 ++++++++++++++++++++++++++++++++++++ types/varint/tsconfig.json | 16 +++++++++++++ types/varint/tslint.json | 1 + types/varint/varint-tests.ts | 17 +++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 types/varint/index.d.ts create mode 100644 types/varint/tsconfig.json create mode 100644 types/varint/tslint.json create mode 100644 types/varint/varint-tests.ts 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 From b48b1c803bf0eeeaad90579404450b24a3afa437 Mon Sep 17 00:00:00 2001 From: Thomas den Hollander Date: Mon, 13 Aug 2018 17:56:46 +0200 Subject: [PATCH 09/32] Add author note --- types/ttf2woff2/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/ttf2woff2/index.d.ts b/types/ttf2woff2/index.d.ts index be49b9099d..180c64f93e 100644 --- a/types/ttf2woff2/index.d.ts +++ b/types/ttf2woff2/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for ttf2woff2 2.0 // Project: https://github.com/nfroidure/ttf2woff2 -// Definitions by: My Self +// Definitions by: Thomas den Hollander // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From f77583e076ca67f11e533b54e6a7e972c2ed1233 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Mon, 13 Aug 2018 14:34:47 -0400 Subject: [PATCH 10/32] [graphql-resolve-batch] Batch resolvers receive ResolveInfo --- types/graphql-resolve-batch/graphql-resolve-batch-tests.ts | 4 +++- types/graphql-resolve-batch/index.d.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) 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; From 181f4d59223d0aee1b272908576211433af69a82 Mon Sep 17 00:00:00 2001 From: Sam Baeck <> Date: Mon, 13 Aug 2018 22:23:10 +0200 Subject: [PATCH 11/32] Added typings for react-router-hash-link --- types/react-router-hash-link/index.d.ts | 18 +++++++++++++++ .../react-router-hash-link-tests.ts | 23 +++++++++++++++++++ types/react-router-hash-link/tsconfig.json | 23 +++++++++++++++++++ types/react-router-hash-link/tslint.json | 1 + 4 files changed, 65 insertions(+) create mode 100644 types/react-router-hash-link/index.d.ts create mode 100644 types/react-router-hash-link/react-router-hash-link-tests.ts create mode 100644 types/react-router-hash-link/tsconfig.json create mode 100644 types/react-router-hash-link/tslint.json 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..545a31cc71 --- /dev/null +++ b/types/react-router-hash-link/index.d.ts @@ -0,0 +1,18 @@ +// 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 + +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.ts b/types/react-router-hash-link/react-router-hash-link-tests.ts new file mode 100644 index 0000000000..7825bbf6c4 --- /dev/null +++ b/types/react-router-hash-link/react-router-hash-link-tests.ts @@ -0,0 +1,23 @@ +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) => {}; +; \ No newline at end of file diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json new file mode 100644 index 0000000000..71c139a0f0 --- /dev/null +++ b/types/react-router-hash-link/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-router-hash-link-tests.ts" + ] +} 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" } From e04532a2b1e77c4b9e9276b54313e397e96caae9 Mon Sep 17 00:00:00 2001 From: Sam Baeck <> Date: Mon, 13 Aug 2018 22:30:23 +0200 Subject: [PATCH 12/32] added strictFunctionTypes": true to tsconfig --- types/react-router-hash-link/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json index 71c139a0f0..892d3999e3 100644 --- a/types/react-router-hash-link/tsconfig.json +++ b/types/react-router-hash-link/tsconfig.json @@ -8,6 +8,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From d29b89c1a85b0d7379affaab5abdd45aa68effb1 Mon Sep 17 00:00:00 2001 From: Sam Baeck <> Date: Mon, 13 Aug 2018 22:49:28 +0200 Subject: [PATCH 13/32] updated tsconfig, fixed broken tests --- types/react-router-hash-link/index.d.ts | 1 + ...link-tests.ts => react-router-hash-link-tests.tsx} | 11 ++++++----- types/react-router-hash-link/tsconfig.json | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) rename types/react-router-hash-link/{react-router-hash-link-tests.ts => react-router-hash-link-tests.tsx} (72%) diff --git a/types/react-router-hash-link/index.d.ts b/types/react-router-hash-link/index.d.ts index 545a31cc71..9480f1aef0 100644 --- a/types/react-router-hash-link/index.d.ts +++ b/types/react-router-hash-link/index.d.ts @@ -2,6 +2,7 @@ // 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'; diff --git a/types/react-router-hash-link/react-router-hash-link-tests.ts b/types/react-router-hash-link/react-router-hash-link-tests.tsx similarity index 72% rename from types/react-router-hash-link/react-router-hash-link-tests.ts rename to types/react-router-hash-link/react-router-hash-link-tests.tsx index 7825bbf6c4..4c64a1b5c3 100644 --- a/types/react-router-hash-link/react-router-hash-link-tests.ts +++ b/types/react-router-hash-link/react-router-hash-link-tests.tsx @@ -9,15 +9,16 @@ interface Props extends NavHashLinkProps { const getIsActive = (extraProp: string) => (match: match, location: H.Location) => !!extraProp; -export default function (props: Props) { +export default function(props: Props) { const {extraProp, ...rest} = props; const isActive = getIsActive(extraProp); return ( -); + ); } - +; -const acceptRef = (node: HTMLAnchorElement | null) => {}; -; \ No newline at end of file +const acceptRef = (node: HTMLAnchorElement | null) => { +}; +; diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json index 892d3999e3..fc830ac41d 100644 --- a/types/react-router-hash-link/tsconfig.json +++ b/types/react-router-hash-link/tsconfig.json @@ -19,6 +19,6 @@ }, "files": [ "index.d.ts", - "react-router-hash-link-tests.ts" + "react-router-hash-link-tests.tsx" ] } From 8f3a3fe440e9a9b84650f222580a05f92ebe7804 Mon Sep 17 00:00:00 2001 From: Ross Solomon Date: Mon, 13 Aug 2018 17:15:29 -0700 Subject: [PATCH 14/32] Add definition for shallow-equals --- .github/CODEOWNERS | 1 + types/shallow-equals/index.d.ts | 16 ++++++++++++++++ types/shallow-equals/shallow-equals-tests.ts | 10 ++++++++++ types/shallow-equals/tsconfig.json | 16 ++++++++++++++++ types/shallow-equals/tslint.json | 3 +++ 5 files changed, 46 insertions(+) create mode 100644 types/shallow-equals/index.d.ts create mode 100644 types/shallow-equals/shallow-equals-tests.ts create mode 100644 types/shallow-equals/tsconfig.json create mode 100644 types/shallow-equals/tslint.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8c7f823a07..d15d79bc9d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3968,6 +3968,7 @@ /types/set-value/ @DanielRosenwasser /types/settings/ @shreyjain1994 /types/sha1/ @arcdev1 +/types/shallow-equals/ @rsolomon /types/shallowequal/ @seansfkelley /types/shapefile/ @DenisCarriere /types/sharedworker/ @nakakura diff --git a/types/shallow-equals/index.d.ts b/types/shallow-equals/index.d.ts new file mode 100644 index 0000000000..126366f74f --- /dev/null +++ b/types/shallow-equals/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for shallow-equals v1.0.0 +// Project: https://github.com/hughsk/shallow-equals +// Definitions by: Ross Solomon +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function shallowEquals( + a?: A, + b?: B, + compare?: (objA?: A, objB?: B) => boolean, +): boolean; + +declare namespace shallowEquals { + +} + +export = shallowEquals; diff --git a/types/shallow-equals/shallow-equals-tests.ts b/types/shallow-equals/shallow-equals-tests.ts new file mode 100644 index 0000000000..092e3557e1 --- /dev/null +++ b/types/shallow-equals/shallow-equals-tests.ts @@ -0,0 +1,10 @@ +import shallowEquals = require('shallow-equals'); + +const a = {}; +const b = {}; +function compare(a: object, b: object) { + 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..74f59acd72 --- /dev/null +++ b/types/shallow-equals/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "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" +} From 193bd151a15c9bbd81f938136eea24a26b575c5a Mon Sep 17 00:00:00 2001 From: Ross Solomon Date: Mon, 13 Aug 2018 17:26:00 -0700 Subject: [PATCH 15/32] Use generator --- types/shallow-equals/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/shallow-equals/index.d.ts b/types/shallow-equals/index.d.ts index 126366f74f..87c4145585 100644 --- a/types/shallow-equals/index.d.ts +++ b/types/shallow-equals/index.d.ts @@ -3,14 +3,14 @@ // Definitions by: Ross Solomon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare function shallowEquals( +export = shallow_equals; + +declare function shallow_equals( a?: A, b?: B, compare?: (objA?: A, objB?: B) => boolean, ): boolean; -declare namespace shallowEquals { +declare namespace shallow_equals { } - -export = shallowEquals; From 2fe4a041ad416d25f667aa421e1f7d572dd20582 Mon Sep 17 00:00:00 2001 From: Ross Solomon Date: Mon, 13 Aug 2018 17:40:37 -0700 Subject: [PATCH 16/32] Fix prettier mistakes --- types/shallow-equals/index.d.ts | 12 +++++------- types/shallow-equals/shallow-equals-tests.ts | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/types/shallow-equals/index.d.ts b/types/shallow-equals/index.d.ts index 87c4145585..69e1a6c552 100644 --- a/types/shallow-equals/index.d.ts +++ b/types/shallow-equals/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for shallow-equals v1.0.0 +// Type definitions for shallow-equals 1.0 // Project: https://github.com/hughsk/shallow-equals // Definitions by: Ross Solomon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,11 +6,9 @@ export = shallow_equals; declare function shallow_equals( - a?: A, - b?: B, - compare?: (objA?: A, objB?: B) => boolean, + a?: A, + b?: B, + compare?: (objA?: A, objB?: B) => boolean, ): boolean; -declare namespace shallow_equals { - -} +declare namespace shallow_equals {} diff --git a/types/shallow-equals/shallow-equals-tests.ts b/types/shallow-equals/shallow-equals-tests.ts index 092e3557e1..87512c9f43 100644 --- a/types/shallow-equals/shallow-equals-tests.ts +++ b/types/shallow-equals/shallow-equals-tests.ts @@ -1,9 +1,18 @@ import shallowEquals = require('shallow-equals'); -const a = {}; -const b = {}; -function compare(a: object, b: object) { - return false; +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); From 6d06564862353038a6e13c4a70d44a1651735dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Th=C3=A9riault?= Date: Mon, 13 Aug 2018 21:49:44 -0400 Subject: [PATCH 17/32] Type def. for is-uuid npm package --- types/is-uuid/index.d.ts | 46 ++++++++++++++++++++++++++++++++++ types/is-uuid/is-uuid-tests.ts | 10 ++++++++ types/is-uuid/tsconfig.json | 23 +++++++++++++++++ types/is-uuid/tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 types/is-uuid/index.d.ts create mode 100644 types/is-uuid/is-uuid-tests.ts create mode 100644 types/is-uuid/tsconfig.json create mode 100644 types/is-uuid/tslint.json 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" } From 6dda1632760e007fd0c0eaeb177e9e32c92bebe4 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Aug 2018 23:42:18 -0500 Subject: [PATCH 18/32] steam-login: add types --- types/steam-login/index.d.ts | 61 ++++++++++++++++++++++++++ types/steam-login/steam-login-tests.ts | 35 +++++++++++++++ types/steam-login/tsconfig.json | 23 ++++++++++ types/steam-login/tslint.json | 1 + 4 files changed, 120 insertions(+) create mode 100644 types/steam-login/index.d.ts create mode 100644 types/steam-login/steam-login-tests.ts create mode 100644 types/steam-login/tsconfig.json create mode 100644 types/steam-login/tslint.json diff --git a/types/steam-login/index.d.ts b/types/steam-login/index.d.ts new file mode 100644 index 0000000000..13fc21c691 --- /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, Response, NextFunction } 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): (req: Request, res: Response, next: NextFunction) => void; + +export function enforceLogin(redirect: string): (req: Request, res: Response, next: NextFunction) => NextFunction; + +export function verify(): (req: Request, res: Response, next: NextFunction) => NextFunction; + +export function authenticate(): (req: Request, res: Response, next: NextFunction) => NextFunction; diff --git a/types/steam-login/steam-login-tests.ts b/types/steam-login/steam-login-tests.ts new file mode 100644 index 0000000000..e741a0f5de --- /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(); + 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..a1d49993f6 --- /dev/null +++ b/types/steam-login/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "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" } From 5cae8a991523293a42411a38644c639c4a74e2c9 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 13 Aug 2018 23:56:17 -0500 Subject: [PATCH 19/32] Update to support tsconfig "strictFunctionTypes": true --- types/steam-login/index.d.ts | 4 ++-- types/steam-login/steam-login-tests.ts | 2 +- types/steam-login/tsconfig.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/steam-login/index.d.ts b/types/steam-login/index.d.ts index 13fc21c691..a765f8e7e0 100644 --- a/types/steam-login/index.d.ts +++ b/types/steam-login/index.d.ts @@ -48,8 +48,8 @@ export interface SteamUser { } export interface SteamRequest extends Request { - logout(): (req: Request) => () => void; - user: SteamUser; + logout?(): (req: Request) => () => void; + user?: SteamUser; } export function middleware(opts: MiddlewareOptions): (req: Request, res: Response, next: NextFunction) => void; diff --git a/types/steam-login/steam-login-tests.ts b/types/steam-login/steam-login-tests.ts index e741a0f5de..84eae31a01 100644 --- a/types/steam-login/steam-login-tests.ts +++ b/types/steam-login/steam-login-tests.ts @@ -27,7 +27,7 @@ app.get('/verify', steam.verify(), (req: steam.SteamRequest, res) => { }); app.get('/logout', steam.enforceLogin('/'), (req: steam.SteamRequest, res) => { - req.logout(); + req.logout ? req.logout() : null; res.redirect('/'); }); diff --git a/types/steam-login/tsconfig.json b/types/steam-login/tsconfig.json index a1d49993f6..8548e16277 100644 --- a/types/steam-login/tsconfig.json +++ b/types/steam-login/tsconfig.json @@ -7,7 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strictFunctionTypes": false, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From c9244569c6aeb3a7149b71e15547b259fd783a81 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 14 Aug 2018 00:07:15 -0500 Subject: [PATCH 20/32] Simplify exported function returns --- types/steam-login/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/steam-login/index.d.ts b/types/steam-login/index.d.ts index a765f8e7e0..849a45b920 100644 --- a/types/steam-login/index.d.ts +++ b/types/steam-login/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -import { Request, Response, NextFunction } from 'express'; +import { Request, RequestHandler } from 'express'; export interface MiddlewareOptions { verify: string; @@ -52,10 +52,10 @@ export interface SteamRequest extends Request { user?: SteamUser; } -export function middleware(opts: MiddlewareOptions): (req: Request, res: Response, next: NextFunction) => void; +export function middleware(opts: MiddlewareOptions): RequestHandler; -export function enforceLogin(redirect: string): (req: Request, res: Response, next: NextFunction) => NextFunction; +export function enforceLogin(redirect: string): RequestHandler; -export function verify(): (req: Request, res: Response, next: NextFunction) => NextFunction; +export function verify(): RequestHandler; -export function authenticate(): (req: Request, res: Response, next: NextFunction) => NextFunction; +export function authenticate(): RequestHandler; From fe3c19d8bbac3c8e381e2d1e9cab5f7281cba6ce Mon Sep 17 00:00:00 2001 From: Alex Brick Date: Mon, 13 Aug 2018 09:45:12 +0200 Subject: [PATCH 21/32] [superagent-bunyan] Adding types for superagent-bunyan --- types/superagent-bunyan/index.d.ts | 12 ++++++++++ .../superagent-bunyan-tests.ts | 16 +++++++++++++ types/superagent-bunyan/tsconfig.json | 23 +++++++++++++++++++ types/superagent-bunyan/tslint.json | 1 + 4 files changed, 52 insertions(+) create mode 100644 types/superagent-bunyan/index.d.ts create mode 100644 types/superagent-bunyan/superagent-bunyan-tests.ts create mode 100644 types/superagent-bunyan/tsconfig.json create mode 100644 types/superagent-bunyan/tslint.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" } From be37428451f1ee300efcdde260c7064391211566 Mon Sep 17 00:00:00 2001 From: Colin Bradley Date: Tue, 14 Aug 2018 18:53:54 +0100 Subject: [PATCH 22/32] dd-trace - compatability with opentracing --- types/dd-trace/package.json | 6 ++ types/dd-trace/src/opentracing/reference.d.ts | 29 ------- types/dd-trace/src/opentracing/span.d.ts | 5 +- .../src/opentracing/span_context.d.ts | 6 +- .../src/opentracing/span_options.d.ts | 37 -------- types/dd-trace/src/opentracing/tracer.d.ts | 86 +------------------ 6 files changed, 16 insertions(+), 153 deletions(-) create mode 100644 types/dd-trace/package.json delete mode 100644 types/dd-trace/src/opentracing/reference.d.ts delete mode 100644 types/dd-trace/src/opentracing/span_options.d.ts 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; From 887a2752a3622d147f501ab7f2689fa47969263a Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen Date: Tue, 14 Aug 2018 22:26:18 +0300 Subject: [PATCH 23/32] Add typings for universal-cookie --- types/universal-cookie/index.d.ts | 102 ++++++++++++++++++ types/universal-cookie/tsconfig.json | 16 +++ types/universal-cookie/tslint.json | 1 + .../universal-cookie-tests.ts | 20 ++++ 4 files changed, 139 insertions(+) create mode 100644 types/universal-cookie/index.d.ts create mode 100644 types/universal-cookie/tsconfig.json create mode 100644 types/universal-cookie/tslint.json create mode 100644 types/universal-cookie/universal-cookie-tests.ts 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) => {}); From ae7488c42654616e3d7997866d058f09aa6dc899 Mon Sep 17 00:00:00 2001 From: Ross Solomon Date: Tue, 14 Aug 2018 17:13:06 -0700 Subject: [PATCH 24/32] Remove codeowner; add back lint rule; fix types --- .github/CODEOWNERS | 1 - types/shallow-equals/index.d.ts | 4 +--- types/shallow-equals/tsconfig.json | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d15d79bc9d..8c7f823a07 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3968,7 +3968,6 @@ /types/set-value/ @DanielRosenwasser /types/settings/ @shreyjain1994 /types/sha1/ @arcdev1 -/types/shallow-equals/ @rsolomon /types/shallowequal/ @seansfkelley /types/shapefile/ @DenisCarriere /types/sharedworker/ @nakakura diff --git a/types/shallow-equals/index.d.ts b/types/shallow-equals/index.d.ts index 69e1a6c552..7d91b03923 100644 --- a/types/shallow-equals/index.d.ts +++ b/types/shallow-equals/index.d.ts @@ -8,7 +8,5 @@ export = shallow_equals; declare function shallow_equals( a?: A, b?: B, - compare?: (objA?: A, objB?: B) => boolean, + compare?: (objA: A, objB: B) => boolean, ): boolean; - -declare namespace shallow_equals {} diff --git a/types/shallow-equals/tsconfig.json b/types/shallow-equals/tsconfig.json index 74f59acd72..83137182f4 100644 --- a/types/shallow-equals/tsconfig.json +++ b/types/shallow-equals/tsconfig.json @@ -4,7 +4,7 @@ "lib": ["es6"], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": ["../"], From a2fe5554f7700458284d4a53bcf4b0be6b253659 Mon Sep 17 00:00:00 2001 From: Kyle Roach Date: Tue, 14 Aug 2018 23:21:10 -0400 Subject: [PATCH 25/32] [react-native] Add hardwareAccelerated to Modal --- types/react-native/index.d.ts | 45 ++++++++++++++++++------------- types/react-native/test/index.tsx | 5 ++++ 2 files changed, 31 insertions(+), 19 deletions(-) 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 = () => ( + +) From 78d9f40cf499277c1da6606c39622695c886be54 Mon Sep 17 00:00:00 2001 From: Franklin Tse Date: Wed, 15 Aug 2018 18:25:56 +0800 Subject: [PATCH 26/32] EntryFunc may return Entry --- types/webpack/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 9bd8c2e8840c7fb9a35718f26e57ec7e967f8ec7 Mon Sep 17 00:00:00 2001 From: Franklin Tse Date: Wed, 15 Aug 2018 18:30:19 +0800 Subject: [PATCH 27/32] Add test cases --- types/webpack/webpack-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index 2f75d11b31..d8a36fd6db 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 // From b5097f8c646d19d3de2b8d7a4981472ee8c10736 Mon Sep 17 00:00:00 2001 From: Franklin Tse Date: Wed, 15 Aug 2018 21:54:36 +0800 Subject: [PATCH 28/32] Fix test case --- types/webpack/webpack-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index d8a36fd6db..16234d422a 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -56,11 +56,11 @@ configuration = { }; configuration = { - entry: () => { + entry: () => ({ p1: "./page1", p2: "./page2", p3: "./page3" - } + }) }; configuration = { From d42a3e4e16e57ff1fe5a18c300f568b6be4eb608 Mon Sep 17 00:00:00 2001 From: Thomas den Hollander Date: Wed, 15 Aug 2018 17:25:20 +0200 Subject: [PATCH 29/32] [node] Allow SharedArrayBuffer in Buffer.from (#27933) * Move from namespace to static attributes * Allow SharedArrayBuffer in Buffer.from * Address comments * Add SharedArrayBuffer to byteLength * Fix tests --- types/node/index.d.ts | 14 +++++++++----- types/node/node-tests.ts | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) 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]]) From 24973f21e7035ab79b6a11435c2d1b5267069534 Mon Sep 17 00:00:00 2001 From: denisname Date: Wed, 15 Aug 2018 17:48:04 +0200 Subject: [PATCH 30/32] JQuery: HTMLSelectElement and arrays (#27810) * Change to work better with arrays and HTMLSelectElement See pull request description * document.body and document.documentElement are possibly null in TypeScript@next * Select2 fix test * Change according to review comments * Fix JQuery in TS 2.3 * CI failed, force to run again * document.body is not null anymore * Rename params * Add a comment above the `tslint:disable`s * Wrong line :/ I went too fast --- types/jquery/index.d.ts | 18 +++++++++++++++--- types/jquery/jquery-tests.ts | 6 ++++++ types/select2/select2-tests.ts | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) 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/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); From f4982fb3fcd46ed0a9ddd111559650da84461cbc Mon Sep 17 00:00:00 2001 From: Luke Ivanchenko-Cooney Date: Thu, 16 Aug 2018 03:46:54 +1000 Subject: [PATCH 31/32] Add decoding attribute to img tag (#28126) --- types/react/index.d.ts | 1 + 1 file changed, 1 insertion(+) 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; From 7c108482f443f8139ae0c19d0862c0342fb933d1 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 15 Aug 2018 13:45:34 -0700 Subject: [PATCH 32/32] Puppeteer: Fix tests (#28147) --- types/puppeteer/puppeteer-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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(); })();