From 2389b4b6b1febd0dc46882d3c7b31a96631a4b57 Mon Sep 17 00:00:00 2001 From: donaldFord Date: Wed, 15 Aug 2018 15:58:57 -0600 Subject: [PATCH 01/59] updated version --- types/react-daterange-picker/index.d.ts | 9 +++--- .../react-daterange-picker-tests.tsx | 30 +++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/types/react-daterange-picker/index.d.ts b/types/react-daterange-picker/index.d.ts index 86ada23508..4b6f5eef45 100644 --- a/types/react-daterange-picker/index.d.ts +++ b/types/react-daterange-picker/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for React Daterange Picker 1.1 +// Type definitions for React Daterange Picker 2.0 // Project: https://github.com/onefinestay/react-daterange-picker // Definitions by: UNCOVER TRUTH Inc. // MartynasZilinskas +// Donald Ford // Definitions: https://github.com/borisyankov/DefinitelyTyped // TypeScript Version: 2.8 @@ -33,7 +34,7 @@ export interface Props extends React.Props { onHighlightRange?(date: Date): void; onSelect?(value: Props): void; onSelectStart?(value: momentRange.MomentRangeExtends): void; - paginationArrowComponent?: PaginationArrow; + paginationArrowComponent?: React.ComponentClass | React.SFC; selectedLabel?: string; selectionType?: 'single' | 'range'; singleDateRange?: boolean; @@ -57,10 +58,8 @@ export interface StateDefinition { selectable?: boolean; } -export interface PaginationArrowProps extends React.Props { +export interface PaginationArrowProps extends React.Props { disabled?: boolean; onTrigger?(): void; direction?: 'next' | 'previous'; } - -export class PaginationArrow extends React.Component { } diff --git a/types/react-daterange-picker/react-daterange-picker-tests.tsx b/types/react-daterange-picker/react-daterange-picker-tests.tsx index b891f6a589..446c4206d9 100644 --- a/types/react-daterange-picker/react-daterange-picker-tests.tsx +++ b/types/react-daterange-picker/react-daterange-picker-tests.tsx @@ -11,6 +11,24 @@ const moment = MomentRange.extendMoment(Moment); type AppProps = ReactDateRangePicker.Props; +const CustomSFCPaginationArrow: React.SFC = (props) => { + return ( +
+ { (props.direction === 'next') ? '<' : '>' } +
+ ); +}; + +class CustomComponentClassPaginationArrow extends React.Component { + render() { + return ( +
+ { (this.props.direction === 'next') ? '<' : '>' } +
+ ); + } +} + class App extends React.Component { handleSelect(value: AppProps, states: any): void { this.setState({ value, states }); @@ -151,6 +169,18 @@ export class Main extends React.Component { minimumDate={new Date()} /> +
+

Single with custom SFC paginationArrowComponent

+ +
+
+

Single with custom ComponentClass paginationArrowComponent

+ +
); From e04f78e6eaa1fbde89b6fc910e795c79ab9de4e8 Mon Sep 17 00:00:00 2001 From: donaldFord Date: Wed, 15 Aug 2018 16:01:32 -0600 Subject: [PATCH 02/59] improved test name --- types/react-daterange-picker/react-daterange-picker-tests.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-daterange-picker/react-daterange-picker-tests.tsx b/types/react-daterange-picker/react-daterange-picker-tests.tsx index 446c4206d9..4e79aa1c7a 100644 --- a/types/react-daterange-picker/react-daterange-picker-tests.tsx +++ b/types/react-daterange-picker/react-daterange-picker-tests.tsx @@ -170,13 +170,13 @@ export class Main extends React.Component { />
-

Single with custom SFC paginationArrowComponent

+

With custom SFC paginationArrowComponent

-

Single with custom ComponentClass paginationArrowComponent

+

With custom ComponentClass paginationArrowComponent

From 5dccc6dcddec42c68a1d227428ecfc03743e30d6 Mon Sep 17 00:00:00 2001 From: Guillaume AMAT Date: Mon, 20 Aug 2018 10:53:22 +0200 Subject: [PATCH 03/59] Update the react-native-snap-carousel types * Arguments of the `slideInterpolatedStyle` function --- types/react-native-snap-carousel/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/react-native-snap-carousel/index.d.ts b/types/react-native-snap-carousel/index.d.ts index 3c630bc094..5785717814 100644 --- a/types/react-native-snap-carousel/index.d.ts +++ b/types/react-native-snap-carousel/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for react-native-snap-carousel 3.6 +// Type definitions for react-native-snap-carousel 3.7 // Project: https://github.com/archriss/react-native-snap-carousel // Definitions by: jnbt // Jacob Froman // Nikolay Polukhin +// Guillaume Amat // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -220,7 +221,7 @@ export interface CarouselProps extends React.Props { /** * Used to define custom interpolations */ - slideInterpolatedStyle?(animatedValue: number, carouselProps: CarouselProps): StyleProp; + slideInterpolatedStyle?(index: number, animatedValue: Animated.AnimatedValue, carouselProps: CarouselProps): StyleProp; /** * Optional style for each item's container (the one whose scale and opacity are animated) */ From 4b54dc69538025feef4ebe09101b6af4f498af08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20J=C3=A4kel?= Date: Mon, 20 Aug 2018 11:27:33 +0200 Subject: [PATCH 04/59] Interface CleaveOptions at extra options updated I updated the interface CleaveOptions at the extra options with the onValueChange, which is a public method at the JavaScript API of cleave.js. Best regards, Leon --- types/cleave.js/options/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/cleave.js/options/index.d.ts b/types/cleave.js/options/index.d.ts index 65d87d79e1..b1dc95920b 100644 --- a/types/cleave.js/options/index.d.ts +++ b/types/cleave.js/options/index.d.ts @@ -51,4 +51,5 @@ export interface CleaveOptions { noImmediatePrefix?: boolean; rawValueTrimPrefix?: boolean; uppercase?: boolean; + onValueChanged?(event: any): void; } From 4107371bdf1aa0f77ec66cfea87c816162267a12 Mon Sep 17 00:00:00 2001 From: Denys Date: Mon, 20 Aug 2018 16:26:58 +0300 Subject: [PATCH 05/59] Add removeAll for FieldArray removeAll is not present. See doc here https://redux-form.com/7.4.2/docs/api/fieldarray.md/#-code-fields-removeall-function-code-. --- types/redux-form/lib/FieldArray.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/redux-form/lib/FieldArray.d.ts b/types/redux-form/lib/FieldArray.d.ts index d800452a3e..f321164b84 100644 --- a/types/redux-form/lib/FieldArray.d.ts +++ b/types/redux-form/lib/FieldArray.d.ts @@ -34,6 +34,7 @@ interface FieldsProps { forEach(callback: FieldIterate): void; get(index: number): FieldValue; getAll(): FieldValue[]; + removeAll(): void; insert(index: number, value: FieldValue): void; length: number; map(callback: FieldIterate): R[]; From 4cd58dee4076f8f8522acbdcc34f0971cdc62cfa Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Mon, 20 Aug 2018 14:43:34 +0100 Subject: [PATCH 06/59] [page] export a default --- types/page/index.d.ts | 6 +++--- types/page/page-tests.ts | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/types/page/index.d.ts b/types/page/index.d.ts index ef56afdc9b..afd42e0f43 100644 --- a/types/page/index.d.ts +++ b/types/page/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for page v1.5.0 +// Type definitions for page v1.8.6 // Project: http://visionmedia.github.io/page.js/ // Definitions by: Alan Norbauer // James Garbutt @@ -285,8 +285,8 @@ declare namespace PageJS { } declare module "page" { - var page: PageJS.Static; - export = page; + const page: PageJS.Static; + export default page; } declare var page: PageJS.Static; diff --git a/types/page/page-tests.ts b/types/page/page-tests.ts index 5d5b421d7e..cf22ecfc64 100644 --- a/types/page/page-tests.ts +++ b/types/page/page-tests.ts @@ -1,6 +1,4 @@ - - -import page = require("page"); +import page from 'page'; //*********************************************************************** // Basic Example From 7cc9fb1a9dd35b015e08f44d213c8ecb098b372b Mon Sep 17 00:00:00 2001 From: Joe MacMahon Date: Wed, 22 Aug 2018 12:07:39 +0100 Subject: [PATCH 07/59] random-js: make engine optional for uuid4() --- types/random-js/index.d.ts | 2 +- types/random-js/random-js-tests.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/random-js/index.d.ts b/types/random-js/index.d.ts index ff1417b681..86926b9beb 100644 --- a/types/random-js/index.d.ts +++ b/types/random-js/index.d.ts @@ -27,7 +27,7 @@ interface Random { sample(population: T[], sampleSize: number): T[]; die(sideCount: number): number; dice(sideCount: number, dieCount: number): number[]; - uuid4(engine: Random.Engine): string; + uuid4(engine?: Random.Engine): string; string(engine: Random.Engine, length: number): string; string(length?: number, pool?: string): string; hex(length?: number, upperCase?: boolean): string; diff --git a/types/random-js/random-js-tests.ts b/types/random-js/random-js-tests.ts index ef438e18c5..936a2a4693 100644 --- a/types/random-js/random-js-tests.ts +++ b/types/random-js/random-js-tests.ts @@ -86,7 +86,8 @@ sampled = random.sample(customTypeArray, 2); numeric = random.die(5); dieValues = random.dice(5, 2); -uuid = Random.uuid4(engine); +uuid = random.uuid4(engine); +uuid = random.uuid4(); str = random.string(); str = random.string(10); From 6a187fd181916e7a5dd0e19e79474c7fb47ff0c9 Mon Sep 17 00:00:00 2001 From: Hoishin Date: Sat, 25 Aug 2018 23:34:33 +0900 Subject: [PATCH 08/59] add delay to not-needed --- notNeededPackages.json | 6 +++++ types/delay/delay-tests.ts | 47 -------------------------------------- types/delay/index.d.ts | 30 ------------------------ types/delay/tsconfig.json | 23 ------------------- types/delay/tslint.json | 8 ------- 5 files changed, 6 insertions(+), 108 deletions(-) delete mode 100644 types/delay/delay-tests.ts delete mode 100644 types/delay/index.d.ts delete mode 100644 types/delay/tsconfig.json delete mode 100644 types/delay/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 4e66976014..f3f09c0f7b 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -390,6 +390,12 @@ "sourceRepoURL": "https://github.com/MikeMcl/decimal.js", "asOfVersion": "7.4.0" }, + { + "libraryName": "delay", + "typingsPackageName": "delay", + "sourceRepoURL": "https://github.com/sindresorhus/delay", + "asOfVersion": "3.1.0" + }, { "libraryName": "DevExtreme", "typingsPackageName": "devextreme", diff --git a/types/delay/delay-tests.ts b/types/delay/delay-tests.ts deleted file mode 100644 index 9714bfd86d..0000000000 --- a/types/delay/delay-tests.ts +++ /dev/null @@ -1,47 +0,0 @@ -import delay = require('delay'); - -delay(200) - .then(() => { - }); - -let str: string; -let num: number; -Promise.resolve(delay(100)) - .then(() => { - }); - -Promise.resolve("foo") - .then(delay(100)) - .then(result => { - str = result; - }); - -Promise.resolve('foo') - .then(delay(100, 10)) - .then(result => { - num = result; - }); - -Promise.resolve('foo') - .then(delay.reject(100)) - .then(x => 10) - .catch(err => { - }); - -Promise.resolve('foo') - .then(delay.reject(100, 'bar')) - .then(x => 10) - .catch(err => { - }); - -(async () => { - const delaying = delay(1000); - delaying.cancel(); - try { - await delaying; - } catch (err) { - // `err` is an instance of `delay.CancelError` - } -})(); - -throw new delay.CancelError('bar'); diff --git a/types/delay/index.d.ts b/types/delay/index.d.ts deleted file mode 100644 index 0ec894f1e1..0000000000 --- a/types/delay/index.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Type definitions for delay 2.0 -// Project: https://github.com/sindresorhus/delay#readme -// Definitions by: BendingBender -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -export = delay; - -declare function delay(ms: number): delay.PDelayedPassThroughThunk; -declare function delay(ms: number, value: T): delay.PDelayedThunk; - -declare namespace delay { - function reject(ms: number, rejectionValue?: any): PDelayedThunk; - - class CancelError extends Error { - readonly name: 'CancelError'; - constructor(message?: string); - } - - type PDelayedThunk = ((value: any) => DelayedPromiseLike) & DelayedPromiseLike; - - type PDelayedPassThroughThunk = ((value: TValue) => DelayedPromiseLike) & DelayedPromiseLike; - - interface DelayedPromiseLike { - then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | null, - onrejected?: ((reason: any) => TResult2 | PromiseLike) | null): Promise; - catch(onrejected?: ((reason: any) => TResult | PromiseLike) | null): Promise; - cancel(): void; - } -} diff --git a/types/delay/tsconfig.json b/types/delay/tsconfig.json deleted file mode 100644 index cb0da53652..0000000000 --- a/types/delay/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "delay-tests.ts" - ] -} \ No newline at end of file diff --git a/types/delay/tslint.json b/types/delay/tslint.json deleted file mode 100644 index bf610ae17f..0000000000 --- a/types/delay/tslint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - // TODO - "await-promise": false, - "no-unnecessary-generics": false - } -} From af2acebec6452c8ff1009d1bdc20ff49a9e1c059 Mon Sep 17 00:00:00 2001 From: Claas Ahlrichs Date: Mon, 27 Aug 2018 08:25:06 +0200 Subject: [PATCH 09/59] updated types for react-select/lib/components --- types/react-select/lib/animated/index.d.ts | 4 +-- types/react-select/lib/components/Menu.d.ts | 4 +-- types/react-select/lib/components/index.d.ts | 36 +++----------------- 3 files changed, 9 insertions(+), 35 deletions(-) diff --git a/types/react-select/lib/animated/index.d.ts b/types/react-select/lib/animated/index.d.ts index 6760d55e81..c5180398b8 100644 --- a/types/react-select/lib/animated/index.d.ts +++ b/types/react-select/lib/animated/index.d.ts @@ -1,12 +1,12 @@ import { ComponentType } from 'react'; -import { SelectComponents, defaultComponents } from '../components/index'; +import { SelectComponents, SelectComponentsConfig } from '../components/index'; import { default as AnimatedInput, AnimatedInputProps } from './Input'; import { default as AnimatedMultiValue, AnimatedMultiValueProps } from './MultiValue'; import { default as AnimatedPlaceholder, AnimatedPlaceholderProps } from './Placeholder'; import { default as AnimatedSingleValue, AnimatedSingleValueProps } from './SingleValue'; import { default as AnimatedValueContainer, AnimatedValueContainerProps } from './ValueContainer'; -export function makeAnimated(externalComponents?: SelectComponents): SelectComponents; +export function makeAnimated(externalComponents?: SelectComponentsConfig): SelectComponents; export const Input: ComponentType; export const MultiValue: ComponentType>; diff --git a/types/react-select/lib/components/Menu.d.ts b/types/react-select/lib/components/Menu.d.ts index 0af2bf16c1..387b538882 100644 --- a/types/react-select/lib/components/Menu.d.ts +++ b/types/react-select/lib/components/Menu.d.ts @@ -30,8 +30,8 @@ import { // Get Menu Placement // ------------------------------ -interface MenuState { placement: 'bottom' | 'top' | null; maxHeight: number; } -interface PlacementArgs { +export interface MenuState { placement: 'bottom' | 'top' | null; maxHeight: number; } +export interface PlacementArgs { maxHeight: number; menuEl: ElementRef; minHeight: number; diff --git a/types/react-select/lib/components/index.d.ts b/types/react-select/lib/components/index.d.ts index d9d505b119..1436336d26 100644 --- a/types/react-select/lib/components/index.d.ts +++ b/types/react-select/lib/components/index.d.ts @@ -81,36 +81,10 @@ export interface SelectComponents { export type SelectComponentsConfig = Partial>; -export namespace components { - const ClearIndicator: IndicatorComponentType | null; - const Control: ComponentType>; - const DropdownIndicator: IndicatorComponentType | null; - const DownChevron: ComponentType; - const CrossIcon: ComponentType; - const Group: ComponentType>; - const GroupHeading: ComponentType; - const IndicatorsContainer: ComponentType>; - const IndicatorSeparator: IndicatorComponentType | null; - const Input: ComponentType; - const LoadingIndicator: ComponentType> | null; - const Menu: ComponentType>; - const MenuList: ComponentType>; - const MenuPortal: ComponentType>; - const LoadingMessage: ComponentType>; - const NoOptionsMessage: ComponentType>; - const MultiValue: ComponentType>; - const MultiValueContainer: ComponentType; - const MultiValueLabel: ComponentType; - const MultiValueRemove: ComponentType; - const Option: ComponentType>; - const Placeholder: ComponentType>; - const SelectContainer: ComponentType>; - const SingleValue: ComponentType>; - const ValueContainer: ComponentType>; +export const components: Required>; + +export interface Props { + components: SelectComponentsConfig; } -export interface Props { - components: SelectComponentsConfig; -} - -export function defaultComponents(props: Props): SelectComponentsConfig; +export function defaultComponents(props: Props): SelectComponents; From 8679aea1f0ed0cad7330414f9b6deb83aa118c6b Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 27 Aug 2018 11:27:39 -0400 Subject: [PATCH 10/59] Added sentiment analysis to query result payload --- types/dialogflow/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/dialogflow/index.d.ts b/types/dialogflow/index.d.ts index 6a3faa8618..aad2c34c7c 100644 --- a/types/dialogflow/index.d.ts +++ b/types/dialogflow/index.d.ts @@ -562,6 +562,12 @@ export interface QueryResult { outputContexts: Context[]; intent: Intent; intentDetectionConfidence: number; + sentimentAnalysisResult?: { + queryTextSentiment: { + magnitude: number; + score: number + } + } diagnosticInfo: any; } From 01d7bb97142cab3a40e97966a6d7c6a1782b38c8 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 27 Aug 2018 11:35:21 -0400 Subject: [PATCH 11/59] Bumped the version number to 0.6.3 --- types/dialogflow/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/dialogflow/index.d.ts b/types/dialogflow/index.d.ts index aad2c34c7c..7775d75a47 100644 --- a/types/dialogflow/index.d.ts +++ b/types/dialogflow/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for dialogflow 0.6 +// Type definitions for dialogflow 0.6.3 // Project: https://github.com/dialogflow/dialogflow-nodejs-client-v2#readme // Definitions by: Daniel Dyla // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From e198b200715b87b25ad4c6e83aa575cf3e8d5269 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 27 Aug 2018 13:12:33 -0400 Subject: [PATCH 12/59] Fixed linting issues --- types/dialogflow/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/dialogflow/index.d.ts b/types/dialogflow/index.d.ts index 7775d75a47..6673648371 100644 --- a/types/dialogflow/index.d.ts +++ b/types/dialogflow/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for dialogflow 0.6.3 +// Type definitions for dialogflow 0.7 // Project: https://github.com/dialogflow/dialogflow-nodejs-client-v2#readme // Definitions by: Daniel Dyla // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -565,9 +565,9 @@ export interface QueryResult { sentimentAnalysisResult?: { queryTextSentiment: { magnitude: number; - score: number - } - } + score: number; + }; + }; diagnosticInfo: any; } From b2631c0d964c96d1fd4320d78feb1ca60779eac3 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 27 Aug 2018 15:08:13 -0400 Subject: [PATCH 13/59] Dropped the Dialogflow version back to 6 --- types/dialogflow/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/dialogflow/index.d.ts b/types/dialogflow/index.d.ts index 6673648371..c421c47f68 100644 --- a/types/dialogflow/index.d.ts +++ b/types/dialogflow/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for dialogflow 0.7 +// Type definitions for dialogflow 0.6 // Project: https://github.com/dialogflow/dialogflow-nodejs-client-v2#readme // Definitions by: Daniel Dyla // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From c8a0139cb19bd6f5dbdc1f72bd1a71c5e4a4e017 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Mon, 27 Aug 2018 09:42:15 -0700 Subject: [PATCH 14/59] adds typings for the 'level-codec' package --- types/level-codec/index.d.ts | 32 ++++++++++++++++++++++++++ types/level-codec/level-codec-tests.ts | 12 ++++++++++ types/level-codec/tsconfig.json | 23 ++++++++++++++++++ types/level-codec/tslint.json | 1 + 4 files changed, 68 insertions(+) create mode 100644 types/level-codec/index.d.ts create mode 100644 types/level-codec/level-codec-tests.ts create mode 100644 types/level-codec/tsconfig.json create mode 100644 types/level-codec/tslint.json diff --git a/types/level-codec/index.d.ts b/types/level-codec/index.d.ts new file mode 100644 index 0000000000..a106350215 --- /dev/null +++ b/types/level-codec/index.d.ts @@ -0,0 +1,32 @@ +// Type definitions for level-codec 9.0 +// Project: https://github.com/Level/codec +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface CodecEncoder { + encode: (val: any) => any; + decode: (val: any) => any; + buffer: boolean; + type: string; +} +export interface CodecOptions { + keyEncoding?: string | CodecEncoder; + valueEncoding?: string | CodecEncoder; +} +export interface Codec { + encodeKey(key: any, opts?: CodecOptions, batchOpts?: CodecOptions): any; + encodeValue(value: any, opts?: CodecOptions, batchOpts?: CodecOptions): any; + decodeKey(key: any, opts?: CodecOptions): any; + decodeValue(value: any, opts?: CodecOptions): any; + encodeBatch(ops: any, opts?: CodecOptions): any; + encodeLtgt(ltgt: any): any; + createStreamDecoder(opts: CodecOptions): any; + keyAsBuffer(opts?: CodecOptions): any; + valueAsBuffer(opts?: CodecOptions): any; +} +export interface CodecConstructor { + new (options?: CodecOptions): Codec; + (options?: CodecOptions): Codec; +} + +export const Codec: CodecConstructor; diff --git a/types/level-codec/level-codec-tests.ts b/types/level-codec/level-codec-tests.ts new file mode 100644 index 0000000000..371966844f --- /dev/null +++ b/types/level-codec/level-codec-tests.ts @@ -0,0 +1,12 @@ +import { Codec } from "level-codec"; + +const test = (codec: Codec) => { + return codec.keyAsBuffer(); +}; + +test(new Codec({ keyEncoding: "hex" })); +test(new Codec()); + +// new not needed +test(Codec({ keyEncoding: "hex" })); +test(Codec()); diff --git a/types/level-codec/tsconfig.json b/types/level-codec/tsconfig.json new file mode 100644 index 0000000000..0381e4eb12 --- /dev/null +++ b/types/level-codec/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", + "level-codec-tests.ts" + ] +} diff --git a/types/level-codec/tslint.json b/types/level-codec/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/level-codec/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 9440fd14094e78c2db7345583a3aba9b36f0eefb Mon Sep 17 00:00:00 2001 From: Netanel Gilad Date: Tue, 28 Aug 2018 13:37:33 +0300 Subject: [PATCH 15/59] add HOC props inference to v4 of react-i18next --- types/react-i18next/v4/index.d.ts | 3 ++- types/react-i18next/v4/translate.d.ts | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/types/react-i18next/v4/index.d.ts b/types/react-i18next/v4/index.d.ts index 14676aba7e..758a00edef 100644 --- a/types/react-i18next/v4/index.d.ts +++ b/types/react-i18next/v4/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for react-i18next 4.6 // Project: https://github.com/i18next/react-i18next // Definitions by: Giedrius Grabauskas +// Netanel Gilad // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -31,7 +32,7 @@ export { * interface MyComponentProps extends ReactI18next.InjectedTranslateProps {} */ export interface InjectedTranslateProps { - t?: TranslationFunction; + t: TranslationFunction; } export as namespace reactI18Next; diff --git a/types/react-i18next/v4/translate.d.ts b/types/react-i18next/v4/translate.d.ts index d41b4dc00a..ff715036c4 100644 --- a/types/react-i18next/v4/translate.d.ts +++ b/types/react-i18next/v4/translate.d.ts @@ -1,5 +1,6 @@ import * as React from "react"; import { i18n } from "i18next"; +import { InjectedTranslateProps } from "react-i18next"; export interface TranslateOptions { withRef?: boolean; @@ -11,5 +12,14 @@ export interface TranslateOptions { i18n?: i18n; } +// Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 +type Omit = Pick; + +// Injects props and removes them from the prop requirements. +// Adds the new properties t (or whatever the translation function is called) and i18n if needed. +export type InferableComponentEnhancerWithProps = +

(component: React.ComponentClass

| React.StatelessComponent

) => + React.ComponentClass>; + // tslint:disable-next-line:ban-types -export default function translate(namespaces?: TKey[] | TKey, options?: TranslateOptions): (WrappedComponent: C) => C; +export default function translate(namespaces?: TKey[] | TKey, options?: TranslateOptions): InferableComponentEnhancerWithProps<"t">; From 8de0e983663143df793f01cc80b6330946059fef Mon Sep 17 00:00:00 2001 From: Netanel Gilad Date: Tue, 28 Aug 2018 14:18:56 +0300 Subject: [PATCH 16/59] fix react-i18next-tests --- types/react-i18next/v4/react-i18next-tests.tsx | 15 +++++++++------ types/react-i18next/v4/translate.d.ts | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/types/react-i18next/v4/react-i18next-tests.tsx b/types/react-i18next/v4/react-i18next-tests.tsx index 6105ccf921..3e57dd091b 100644 --- a/types/react-i18next/v4/react-i18next-tests.tsx +++ b/types/react-i18next/v4/react-i18next-tests.tsx @@ -17,17 +17,16 @@ const AnotherComponent = translate('view', { wait: true, translateFuncName: '_' class InnerYetAnotherComponent extends React.Component { render() { - const t = this.props.t!; + const t = this.props.t; return

{t('usingDefaultNS', { /* options t options */ })}

; } } const YetAnotherComponent = translate()(InnerYetAnotherComponent); -@translate(['view', 'nav'], { wait: true }) class TranslatableView extends React.Component { render() { - const t = this.props.t!; + const t = this.props.t; const interpolateComponent = "a interpolated component"; return ( @@ -55,12 +54,14 @@ class TranslatableView extends React.Component { } } +const WrappedTranslatableView = translate(['view', 'nav'], { wait: true })(TranslatableView); + class App extends React.Component { render() { return (
- +
); @@ -81,12 +82,14 @@ loadNamespaces({ components: [App], i18n }).then(() => { }).catch(error => { }); type Key = "view" | "nav"; -@translate(['view', 'nav']) class GenericsTest extends React.Component { render() { return null; } } -@translate('view') +translate(['view', 'nav'])(GenericsTest); + class GenericsTest2 extends React.Component { render() { return null; } } + +translate('view')(GenericsTest2); diff --git a/types/react-i18next/v4/translate.d.ts b/types/react-i18next/v4/translate.d.ts index ff715036c4..9a4fb6ddc2 100644 --- a/types/react-i18next/v4/translate.d.ts +++ b/types/react-i18next/v4/translate.d.ts @@ -13,7 +13,7 @@ export interface TranslateOptions { } // Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 -type Omit = Pick; +export type Omit = Pick; // Injects props and removes them from the prop requirements. // Adds the new properties t (or whatever the translation function is called) and i18n if needed. From 903a62f15dbfeb1555e0b950091c662bae74d473 Mon Sep 17 00:00:00 2001 From: Allen Gammel Date: Tue, 28 Aug 2018 17:34:05 -0500 Subject: [PATCH 17/59] adding node-localstorage typings --- types/node-localstorage/index.d.ts | 63 +++++++++++++++++++ .../node-localstorage-tests.ts | 36 +++++++++++ types/node-localstorage/tsconfig.json | 23 +++++++ types/node-localstorage/tslint.json | 3 + 4 files changed, 125 insertions(+) create mode 100644 types/node-localstorage/index.d.ts create mode 100644 types/node-localstorage/node-localstorage-tests.ts create mode 100644 types/node-localstorage/tsconfig.json create mode 100644 types/node-localstorage/tslint.json diff --git a/types/node-localstorage/index.d.ts b/types/node-localstorage/index.d.ts new file mode 100644 index 0000000000..ffc9bb5dc7 --- /dev/null +++ b/types/node-localstorage/index.d.ts @@ -0,0 +1,63 @@ +// Type definitions for node-localstorage 1.3 +// Project: https://github.com/lmaccherone/node-localstorage +// Definitions by: Allen Gammel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export class LocalStorage { + /** + * Creates a new LocalStorage instance + * @param location The location in which the local storage resides + * @param quota The partitioned size of the local storage + */ + constructor(location: string, quota?: number); + /** + * The number of keys in the local storage. + */ + length: number; + /** + * Clears the local storage + */ + clear(): void; + /** + * Gets the value of the given [key] + * @param key The key whose value you want to retrieve. + */ + getItem(key: string): string | null; + /** + * Retrieves the value of the key at the [index]. + * @param index The index of the key in which you want to return the value of. + */ + key(index: number): string; + /** + * Removes the specified [key] from local storage. + * @param key The key you want to remove. + */ + removeItem(key: string): void; + /** + * + * @param key Unique identifier for the new local storage item + * @param value The value of the item + */ + setItem(key: string, value: string): void; +} +export class JSONStorage extends LocalStorage { + /** + * Creates a new LocalStorage instance + * @param location The location in which the local storage resides + * @param quota The partitioned size of the local storage + */ + constructor(location: string, quota?: number); + /** + * Gets the value of the given [key] + * @param key The key whose value you want to retrieve. + * @returns `Array of Objects` or an `Object`. This `getItem` method performs a `JSON.parse` on the value before returning it. + */ + getItem(key: string): any | null; + /** + * + * @param key Unique identifier for the new local storage item + * @param value The value associated with the `key`. This `setItem` method performs a `JSON.stringify` on the value before storing it. The `value` *must* be a valid `JSON` object. + */ + setItem(key: string, value: string | [] | object): void; +} diff --git a/types/node-localstorage/node-localstorage-tests.ts b/types/node-localstorage/node-localstorage-tests.ts new file mode 100644 index 0000000000..5874e08135 --- /dev/null +++ b/types/node-localstorage/node-localstorage-tests.ts @@ -0,0 +1,36 @@ +import { LocalStorage, JSONStorage } from 'node-localstorage'; + +const jsonStore = new JSONStorage('./jsonStore'); +const textStore = new LocalStorage('./textStore'); + +const mjkModel = { + firstName: 'Maynard', + middleName: 'James', + familyName: 'Keenan', +}; + +textStore.clear(); +jsonStore.clear(); + +textStore.setItem('tool', '46&2'); + +if (textStore.getItem('tool') !== '46&2') { + throw new Error('.setItem method is not working!'); +} + +jsonStore.setItem('mjk', mjkModel); + +const mjkTest = jsonStore.getItem('mjk'); + +if (mjkTest === null || mjkTest.firstName !== mjkModel.firstName || mjkTest.middleName !== mjkModel.middleName || mjkTest.familyName !== mjkModel.familyName) { + throw new Error('.setJson method is not working!'); +} + +const keyCheck = textStore.key(0); + +if (keyCheck && keyCheck !== 'tool') { + throw new Error('.key method has failed.'); +} + +textStore.clear(); +jsonStore.clear(); diff --git a/types/node-localstorage/tsconfig.json b/types/node-localstorage/tsconfig.json new file mode 100644 index 0000000000..9411b285e2 --- /dev/null +++ b/types/node-localstorage/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", + "node-localstorage-tests.ts" + ] +} \ No newline at end of file diff --git a/types/node-localstorage/tslint.json b/types/node-localstorage/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/node-localstorage/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file From 2a7b68be59890d08c3c1022c36b28741853c7150 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Tue, 28 Aug 2018 18:00:15 -0700 Subject: [PATCH 18/59] adds typings for the 'stream-throttle' package --- types/stream-throttle/index.d.ts | 22 +++++++++++++++++++ .../stream-throttle/stream-throttle-tests.ts | 7 ++++++ types/stream-throttle/tsconfig.json | 19 ++++++++++++++++ types/stream-throttle/tslint.json | 3 +++ 4 files changed, 51 insertions(+) create mode 100644 types/stream-throttle/index.d.ts create mode 100644 types/stream-throttle/stream-throttle-tests.ts create mode 100644 types/stream-throttle/tsconfig.json create mode 100644 types/stream-throttle/tslint.json diff --git a/types/stream-throttle/index.d.ts b/types/stream-throttle/index.d.ts new file mode 100644 index 0000000000..30ba038907 --- /dev/null +++ b/types/stream-throttle/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for stream-throttle 0.1 +// Project: https://github.com/tjgq/node-stream-throttle +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Transform } from 'stream'; + +export interface ThrottleOptions { + readonly rate: number; + readonly chunksize?: number; +} + +export class Throttle extends Transform { + constructor(options: ThrottleOptions); +} + +export class ThrottleGroup { + constructor(options: ThrottleOptions); + throttle(options: ThrottleOptions): Throttle; +} diff --git a/types/stream-throttle/stream-throttle-tests.ts b/types/stream-throttle/stream-throttle-tests.ts new file mode 100644 index 0000000000..bbd8f8ce86 --- /dev/null +++ b/types/stream-throttle/stream-throttle-tests.ts @@ -0,0 +1,7 @@ +import { Throttle, ThrottleGroup } from 'stream-throttle'; + +const throttle = new Throttle({rate: 1}); +const throttleGroup = new ThrottleGroup({rate: 1}); + +// $ExpectType Throttle +throttleGroup.throttle({rate: 1}); diff --git a/types/stream-throttle/tsconfig.json b/types/stream-throttle/tsconfig.json new file mode 100644 index 0000000000..b9e4185c58 --- /dev/null +++ b/types/stream-throttle/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "stream-throttle-tests.ts" + ] +} diff --git a/types/stream-throttle/tslint.json b/types/stream-throttle/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/stream-throttle/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 7833915696107059071fd67d8f68a0b9d5db0591 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Tue, 28 Aug 2018 18:31:02 -0700 Subject: [PATCH 19/59] adds typings for the 'scrypt-js' package --- types/scrypt-js/index.d.ts | 22 ++++++++++++++++++++++ types/scrypt-js/scrypt-js-tests.ts | 7 +++++++ types/scrypt-js/tsconfig.json | 19 +++++++++++++++++++ types/scrypt-js/tslint.json | 3 +++ 4 files changed, 51 insertions(+) create mode 100644 types/scrypt-js/index.d.ts create mode 100644 types/scrypt-js/scrypt-js-tests.ts create mode 100644 types/scrypt-js/tsconfig.json create mode 100644 types/scrypt-js/tslint.json diff --git a/types/scrypt-js/index.d.ts b/types/scrypt-js/index.d.ts new file mode 100644 index 0000000000..fde3c0a444 --- /dev/null +++ b/types/scrypt-js/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for scrypt-js 2.0 +// Project: https://github.com/ricmoo/scrypt-js +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function scrypt( + password: Buffer, + salt: Buffer, + N: number, + r: number, + p: number, + dklen: number, + callback: ( + error: Error | undefined | null, + progress: number, + key?: ReadonlyArray, + ) => void +): void; + +export = scrypt; diff --git a/types/scrypt-js/scrypt-js-tests.ts b/types/scrypt-js/scrypt-js-tests.ts new file mode 100644 index 0000000000..21c77fb16c --- /dev/null +++ b/types/scrypt-js/scrypt-js-tests.ts @@ -0,0 +1,7 @@ +import scrypt = require('scrypt-js'); + +const testBuffer = Buffer.from('test'); +const testCB = (err: Error | undefined | null, progress: number) => {}; + +// $ExpectType void +scrypt(testBuffer, testBuffer, 1, 1, 1, 1, testCB); diff --git a/types/scrypt-js/tsconfig.json b/types/scrypt-js/tsconfig.json new file mode 100644 index 0000000000..8c6c60e736 --- /dev/null +++ b/types/scrypt-js/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "scrypt-js-tests.ts" + ] +} diff --git a/types/scrypt-js/tslint.json b/types/scrypt-js/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/scrypt-js/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 8e7644b910e05325f2912e301b1950a4b3576437 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Tue, 28 Aug 2018 18:59:48 -0700 Subject: [PATCH 20/59] adds typings for the 'prometheus-gc-stats' package --- types/prometheus-gc-stats/index.d.ts | 9 +++++++++ .../prometheus-gc-stats-tests.ts | 5 +++++ types/prometheus-gc-stats/tsconfig.json | 19 +++++++++++++++++++ types/prometheus-gc-stats/tslint.json | 3 +++ 4 files changed, 36 insertions(+) create mode 100644 types/prometheus-gc-stats/index.d.ts create mode 100644 types/prometheus-gc-stats/prometheus-gc-stats-tests.ts create mode 100644 types/prometheus-gc-stats/tsconfig.json create mode 100644 types/prometheus-gc-stats/tslint.json diff --git a/types/prometheus-gc-stats/index.d.ts b/types/prometheus-gc-stats/index.d.ts new file mode 100644 index 0000000000..007cf28bed --- /dev/null +++ b/types/prometheus-gc-stats/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for prometheus-gc-stats 0.6 +// Project: https://github.com/SimenB/node-prometheus-gc-stats +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// register is typeof require('prom-client').Registry which has its own .d.ts +declare function gcStats(register: any): () => void; + +export = gcStats; diff --git a/types/prometheus-gc-stats/prometheus-gc-stats-tests.ts b/types/prometheus-gc-stats/prometheus-gc-stats-tests.ts new file mode 100644 index 0000000000..abc7542aa0 --- /dev/null +++ b/types/prometheus-gc-stats/prometheus-gc-stats-tests.ts @@ -0,0 +1,5 @@ +import gcStats = require('prometheus-gc-stats'); + +const testFunc = gcStats('something'); +// $ExpectType void +testFunc(); diff --git a/types/prometheus-gc-stats/tsconfig.json b/types/prometheus-gc-stats/tsconfig.json new file mode 100644 index 0000000000..1fcdb90ce8 --- /dev/null +++ b/types/prometheus-gc-stats/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "prometheus-gc-stats-tests.ts" + ] +} diff --git a/types/prometheus-gc-stats/tslint.json b/types/prometheus-gc-stats/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/prometheus-gc-stats/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 6d8196db5108ecf3d89fcf942c516fbb61a59b42 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Tue, 28 Aug 2018 20:08:48 -0700 Subject: [PATCH 21/59] adds typings for the 'buffer-xor' package --- types/buffer-xor/buffer-xor-tests.ts | 4 ++++ types/buffer-xor/index.d.ts | 10 ++++++++++ types/buffer-xor/tsconfig.json | 19 +++++++++++++++++++ types/buffer-xor/tslint.json | 3 +++ 4 files changed, 36 insertions(+) create mode 100644 types/buffer-xor/buffer-xor-tests.ts create mode 100644 types/buffer-xor/index.d.ts create mode 100644 types/buffer-xor/tsconfig.json create mode 100644 types/buffer-xor/tslint.json diff --git a/types/buffer-xor/buffer-xor-tests.ts b/types/buffer-xor/buffer-xor-tests.ts new file mode 100644 index 0000000000..7c55514eaa --- /dev/null +++ b/types/buffer-xor/buffer-xor-tests.ts @@ -0,0 +1,4 @@ +import xor = require('buffer-xor'); + +// $ExpectType Buffer +xor(Buffer.from('a'), Buffer.from('b')); diff --git a/types/buffer-xor/index.d.ts b/types/buffer-xor/index.d.ts new file mode 100644 index 0000000000..5e98793266 --- /dev/null +++ b/types/buffer-xor/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for buffer-xor 2.0 +// Project: https://github.com/crypto-browserify/buffer-xor +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function xor(a: Buffer, b: Buffer): Buffer; + +export = xor; diff --git a/types/buffer-xor/tsconfig.json b/types/buffer-xor/tsconfig.json new file mode 100644 index 0000000000..adbeaec3b7 --- /dev/null +++ b/types/buffer-xor/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "buffer-xor-tests.ts" + ] +} diff --git a/types/buffer-xor/tslint.json b/types/buffer-xor/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/buffer-xor/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 53a84ac83c39c25bad7d97f728a9865f28517b40 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Tue, 28 Aug 2018 20:35:50 -0700 Subject: [PATCH 22/59] adds typings for the 'grpc-error' package --- types/grpc-error/grpc-error-tests.ts | 7 +++++++ types/grpc-error/index.d.ts | 16 ++++++++++++++++ types/grpc-error/tsconfig.json | 19 +++++++++++++++++++ types/grpc-error/tslint.json | 3 +++ 4 files changed, 45 insertions(+) create mode 100644 types/grpc-error/grpc-error-tests.ts create mode 100644 types/grpc-error/index.d.ts create mode 100644 types/grpc-error/tsconfig.json create mode 100644 types/grpc-error/tslint.json diff --git a/types/grpc-error/grpc-error-tests.ts b/types/grpc-error/grpc-error-tests.ts new file mode 100644 index 0000000000..f8f309cb65 --- /dev/null +++ b/types/grpc-error/grpc-error-tests.ts @@ -0,0 +1,7 @@ +import GRPCError = require('grpc-error'); + +const error1 = new GRPCError('test'); +const error2 = new GRPCError({status_code: 'invalid'}); +const error3 = new GRPCError('test', 12); +const error4 = new GRPCError('test', {status_code: 'invalid'}); +const error5 = new GRPCError('test', 12, {status_code: 'invalid'}); diff --git a/types/grpc-error/index.d.ts b/types/grpc-error/index.d.ts new file mode 100644 index 0000000000..6f76d288db --- /dev/null +++ b/types/grpc-error/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for grpc-error 1.0 +// Project: https://github.com/bojand/grpc-error +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +declare class GRPCError extends Error { + constructor(value: string | object); + constructor(message: string, value: number | object); + constructor(message: string, code: number, metadata: object); + + code: number; + metadata: object; +} + +export = GRPCError; diff --git a/types/grpc-error/tsconfig.json b/types/grpc-error/tsconfig.json new file mode 100644 index 0000000000..51388578e0 --- /dev/null +++ b/types/grpc-error/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "grpc-error-tests.ts" + ] +} diff --git a/types/grpc-error/tslint.json b/types/grpc-error/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/grpc-error/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 4416b164dc6319caef2bfdc24ffbbeb074bcf549 Mon Sep 17 00:00:00 2001 From: Daniel Montesinos Date: Wed, 29 Aug 2018 12:50:15 +0200 Subject: [PATCH 23/59] added begin function --- types/xmlbuilder/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/xmlbuilder/index.d.ts b/types/xmlbuilder/index.d.ts index 2115d30754..ec7c0bf83e 100644 --- a/types/xmlbuilder/index.d.ts +++ b/types/xmlbuilder/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: Wallymathieu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - export = xmlbuilder; declare namespace xmlbuilder { @@ -87,5 +86,6 @@ declare namespace xmlbuilder { u(): XMLElementOrXMLNode; } - function create(nameOrObjSpec: string | { [name:string]: Object }, xmldec?: Object, doctype?: any, options?: Object): XMLElementOrXMLNode; -} + function create(nameOrObjSpec: string | { [name: string]: Object }, xmldec?: Object, doctype?: any, options?: Object): XMLElementOrXMLNode; + function begin(): XMLElementOrXMLNode; +} \ No newline at end of file From e6e15c752b6157c023c0ab45ea85a1a16b9a528c Mon Sep 17 00:00:00 2001 From: Daniel Montesinos Date: Wed, 29 Aug 2018 13:11:28 +0200 Subject: [PATCH 24/59] added test --- types/xmlbuilder/index.d.ts | 2 +- types/xmlbuilder/xmlbuilder-tests.ts | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/xmlbuilder/index.d.ts b/types/xmlbuilder/index.d.ts index ec7c0bf83e..acaeddca11 100644 --- a/types/xmlbuilder/index.d.ts +++ b/types/xmlbuilder/index.d.ts @@ -88,4 +88,4 @@ declare namespace xmlbuilder { function create(nameOrObjSpec: string | { [name: string]: Object }, xmldec?: Object, doctype?: any, options?: Object): XMLElementOrXMLNode; function begin(): XMLElementOrXMLNode; -} \ No newline at end of file +} diff --git a/types/xmlbuilder/xmlbuilder-tests.ts b/types/xmlbuilder/xmlbuilder-tests.ts index 8be8f780f9..0364d6fed8 100644 --- a/types/xmlbuilder/xmlbuilder-tests.ts +++ b/types/xmlbuilder/xmlbuilder-tests.ts @@ -1,6 +1,7 @@ import xmlbuilder = require('xmlbuilder'); var xml = xmlbuilder.create; +var doc = xmlbuilder.begin; // https://github.com/oozcitak/xmlbuilder-js/blob/master/test/comment.coffee xml('comment', {}, {}, { headless: true }).comment('<>\'"&\t\n\r').end(); @@ -42,9 +43,12 @@ xml('root') .ele('atttest', 'text') .end(); +// https://github.com/oozcitak/xmlbuilder-js/blob/master/test/basic/begin.coffee +doc().ele('root', { att: 'val' }).ele('test').end(); + xml({ - displayNotification: { - level: 'error', - message: 'an error occurred' - } + displayNotification: { + level: 'error', + message: 'an error occurred' + } }); \ No newline at end of file From 65c05b99360e0660e41f2fa2101d7c7438c822b2 Mon Sep 17 00:00:00 2001 From: Viktor Zolin Date: Wed, 29 Aug 2018 14:34:38 +0100 Subject: [PATCH 25/59] Add the missing onDrag event handler --- types/google-map-react/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/google-map-react/index.d.ts b/types/google-map-react/index.d.ts index ffd8cb90c2..b77c481dd9 100644 --- a/types/google-map-react/index.d.ts +++ b/types/google-map-react/index.d.ts @@ -131,6 +131,7 @@ export interface Props { onChildClick?(hoverKey: any, childProps: any): void; onChildMouseEnter?(hoverKey: any, childProps: any): void; onChildMouseLeave?(hoverKey: any, childProps: any): void; + onDrag?(args: any): void; onZoomAnimationStart?(args: any): void; onZoomAnimationEnd?(args: any): void; onMapTypeIdChange?(args: any): void; From b667364d2958f1bbe36e68402af2935917df5062 Mon Sep 17 00:00:00 2001 From: Ian Copp Date: Wed, 29 Aug 2018 10:15:36 -0700 Subject: [PATCH 26/59] Add the package p-progress --- types/p-progress/index.d.ts | 175 +++++++++++++++++++++++++++ types/p-progress/p-progress-tests.ts | 31 +++++ types/p-progress/tsconfig.json | 23 ++++ types/p-progress/tslint.json | 1 + 4 files changed, 230 insertions(+) create mode 100644 types/p-progress/index.d.ts create mode 100644 types/p-progress/p-progress-tests.ts create mode 100644 types/p-progress/tsconfig.json create mode 100644 types/p-progress/tslint.json diff --git a/types/p-progress/index.d.ts b/types/p-progress/index.d.ts new file mode 100644 index 0000000000..8eb745683c --- /dev/null +++ b/types/p-progress/index.d.ts @@ -0,0 +1,175 @@ +// Type definitions for p-progress 0.2 +// Project: https://github.com/sindresorhus/p-progress#readme +// Definitions by: icopp +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +declare namespace pProgress { + interface Options { + /** + * Number of concurrently pending promises. + * + * To run the promises in series, set it to 1. + * + * When this option is set, the first argument must be an array of + * promise-returning functions. + * + * Minimum 1. + * + * @default {Infinity} + */ + concurrency?: number; + } +} + +type PromiseFactory = () => Promise | PromiseLike; + +declare class PProgress extends Promise { + /** + * The current progress percentage of the promise as a number between 0 and + * 1. + */ + progress: number; + + /** + * Convenience method to run multiple promises and get a total progress of + * all of them. It counts normal promises with progress `0` when pending and + * progress `1` when resolved. For PProgress type promises, it listens to + * their onProgress() method for more fine grained progress reporting. You + * can mix and match normal promises and PProgress promises. + * + * @param promises Array of promises or promise-returning functions. + * @throws {TypeError} + */ + static all( + promises: [ + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory + ], + options?: pProgress.Options + ): PProgress<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + static all( + promises: [ + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory + ], + options?: pProgress.Options + ): PProgress<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + static all( + promises: [ + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory + ], + options?: pProgress.Options + ): PProgress<[T1, T2, T3, T4, T5, T6, T7, T8]>; + static all( + promises: [ + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory + ], + options?: pProgress.Options + ): PProgress<[T1, T2, T3, T4, T5, T6, T7]>; + static all( + promises: [ + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory + ], + options?: pProgress.Options + ): PProgress<[T1, T2, T3, T4, T5, T6]>; + static all( + promises: [ + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory + ], + options?: pProgress.Options + ): PProgress<[T1, T2, T3, T4, T5]>; + static all( + promises: [ + PromiseFactory, + PromiseFactory, + PromiseFactory, + PromiseFactory + ], + options?: pProgress.Options + ): PProgress<[T1, T2, T3, T4]>; + static all( + promises: [PromiseFactory, PromiseFactory, PromiseFactory], + options?: pProgress.Options + ): PProgress<[T1, T2, T3]>; + static all( + promises: [PromiseFactory, PromiseFactory], + options?: pProgress.Options + ): PProgress<[T1, T2]>; + static all( + promises: [PromiseFactory], + options?: pProgress.Options + ): PProgress<[T1]>; + static all( + promises: Array>, + options?: pProgress.Options + ): PProgress; + + /** + * Same as the Promise constructor, but with an appended `progress` + * parameter in `executor`. + * + * @param progress + * Call this with progress updates. It expects a number between 0 and 1. + * + * Multiple calls with the same number will result in only one + * `onProgress()` event. + * + * Progress percentage `1` is reported for you when the promise resolves. + * If you set it yourself, it will simply be ignored. + */ + constructor( + executor: ( + resolve: (value?: T | PromiseLike) => void, + reject: (reason?: any) => void, + progress: (progress: number) => void + ) => void + ); + + /** + * Accepts a function that gets `instance.progress` as an argument and is + * called for every progress event. + * + * @throws {TypeError} + */ + onProgress(cb: (progress: number) => void): void; +} + +export = PProgress; diff --git a/types/p-progress/p-progress-tests.ts b/types/p-progress/p-progress-tests.ts new file mode 100644 index 0000000000..eb70dec355 --- /dev/null +++ b/types/p-progress/p-progress-tests.ts @@ -0,0 +1,31 @@ +import PProgress = require("p-progress"); + +new PProgress(async (resolve, reject, progress) => { + try { + await Promise.resolve("sindresorhus.com"); + progress(0.5); + + await Promise.resolve("ava.li"); + progress(1); + + resolve(); + } catch (e) { + reject(e); + } +}).onProgress(progress => { + progress; +}); + +PProgress.all( + [ + () => Promise.resolve("sindresorhus.com"), + () => Promise.resolve("ava.li"), + () => Promise.resolve(), + () => Promise.resolve(1) + ], + { concurrency: 2 } +).then(result => { + const str: string = result[0]; + const str2: string = result[1]; + const num: number = result[3]; +}); diff --git a/types/p-progress/tsconfig.json b/types/p-progress/tsconfig.json new file mode 100644 index 0000000000..1cd7ff1976 --- /dev/null +++ b/types/p-progress/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", + "p-progress-tests.ts" + ] +} diff --git a/types/p-progress/tslint.json b/types/p-progress/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/p-progress/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 2575007d084f3c23955120d9764f6238dfb3b192 Mon Sep 17 00:00:00 2001 From: Allen Gammel Date: Wed, 29 Aug 2018 13:35:04 -0500 Subject: [PATCH 27/59] Added support fot the custom EventEmitter. Added jsdoc comments. --- types/node-localstorage/index.d.ts | 95 +++++++++++++++---- .../node-localstorage-tests.ts | 32 ++++++- 2 files changed, 106 insertions(+), 21 deletions(-) diff --git a/types/node-localstorage/index.d.ts b/types/node-localstorage/index.d.ts index ffc9bb5dc7..960d40f1da 100644 --- a/types/node-localstorage/index.d.ts +++ b/types/node-localstorage/index.d.ts @@ -4,13 +4,14 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -export class LocalStorage { - /** - * Creates a new LocalStorage instance - * @param location The location in which the local storage resides - * @param quota The partitioned size of the local storage - */ - constructor(location: string, quota?: number); +import { EventEmitter } from 'events'; + +/** + * A drop-in substitute for the browser native localStorage API that runs on node.js. + * Copyright (c) 2012, Lawrence S. Maccherone, Jr. -- https://github.com/lmaccherone/node-localstorage + * (MIT License) + */ +export class LocalStorage extends EventEmitter { /** * The number of keys in the local storage. */ @@ -35,29 +36,91 @@ export class LocalStorage { */ removeItem(key: string): void; /** - * + * Stores a `key` and it's `value` in to the local store. * @param key Unique identifier for the new local storage item * @param value The value of the item */ setItem(key: string, value: string): void; -} -export class JSONStorage extends LocalStorage { + /** + * Internal event `storage` is fired on the `removeItem`, `setItem` and `clear` methods, if subscribed. + * @param eventName The only `eventName` that is supported is `storage`. + * @param callback The call back type is of `StorageEvent`. + */ + on(eventName: 'storage', callback: (event: StorageEvent) => void): this; /** * Creates a new LocalStorage instance * @param location The location in which the local storage resides * @param quota The partitioned size of the local storage */ constructor(location: string, quota?: number); +} +export class JSONStorage extends LocalStorage { /** - * Gets the value of the given [key] + * Gets the value of the given `key`. This method performs a `JSON.parse` on the `value` before returning it. * @param key The key whose value you want to retrieve. - * @returns `Array of Objects` or an `Object`. This `getItem` method performs a `JSON.parse` on the value before returning it. + * @returns `Array of Objects` or an `Object`. This `getItem` method performs a `JSON.parse` on the `value` before returning it. */ - getItem(key: string): any | null; + getItem(key: string): any; /** - * + * Stores a `key` and it's `value` in to the local store. The given `value` will have `JSON.stringify` performed on it prior to storing. * @param key Unique identifier for the new local storage item - * @param value The value associated with the `key`. This `setItem` method performs a `JSON.stringify` on the value before storing it. The `value` *must* be a valid `JSON` object. + * @param value The value associated with the `key`. This `setItem` method performs a `JSON.stringify` on the value before storage. The `value` *must* be a valid `JSON` object. */ - setItem(key: string, value: string | [] | object): void; + setItem(key: string, value: any): void; + /** + * Creates a new LocalStorage instance + * @param location The location in which the local storage resides + * @param quota The partitioned size of the local storage + */ + constructor(location: string, quota?: number); +} + +/** + * Contains information regarding a `storage` event. + */ +export class StorageEvent { + /** + * Affected `key`. + */ + key: string; + /** + * Previous `value` associated with the `key`. + */ + oldValue: string; + /** + * Current `value` associated with the `key`. + */ + newValue: string; + /** + * The current `process.pid` for the calling process. + */ + url: string; + /** + * The location of the storage area. Defaults to `localStorage`. + */ + storageArea: string; + /** + * Creates an object containing information regarding a `storage` event. + * @param key Affected `key`. + * @param oldValue Previous `value` associated with the `key`. + * @param newValue Current `value` associated with the `key`. + * @param url The current `process.pid` for the calling process. + * @param storageArea The location of the storage area. Defaults to `localStorage`. + */ + constructor(key: string, oldValue: string, newValue: string, url: string, storageArea: string); +} + +/** + * Provides a specific `Error` object for **Quota Exceeded Errors**. + */ +export class QUOTA_EXCEEDED_ERR extends Error { + /** + * Message explaining the error. + */ + message: string; + /** + * Creates a specific `Error` object for **Quota Exceeded Errors**. + * @param message Message explaining the error. + */ + constructor(message: string); } diff --git a/types/node-localstorage/node-localstorage-tests.ts b/types/node-localstorage/node-localstorage-tests.ts index 5874e08135..25c27e622c 100644 --- a/types/node-localstorage/node-localstorage-tests.ts +++ b/types/node-localstorage/node-localstorage-tests.ts @@ -3,8 +3,14 @@ import { LocalStorage, JSONStorage } from 'node-localstorage'; const jsonStore = new JSONStorage('./jsonStore'); const textStore = new LocalStorage('./textStore'); -const mjkModel = { - firstName: 'Maynard', +interface Person { + givenName: string; + middleName: string; + familyName: string; +} + +const mjkModel: Person = { + givenName: 'Maynard', middleName: 'James', familyName: 'Keenan', }; @@ -12,6 +18,18 @@ const mjkModel = { textStore.clear(); jsonStore.clear(); +textStore.on('storage', (event) => { + if (textStore.getItem(event.key) !== event.newValue) { + throw new Error('textStore: An error occurred with the event handler.'); + } +}); + +jsonStore.on('storage', (event) => { + if (jsonStore.getItem(event.key) !== event.newValue) { + throw new Error('jsonStore: An error occurred with the event handler.'); + } +}); + textStore.setItem('tool', '46&2'); if (textStore.getItem('tool') !== '46&2') { @@ -20,10 +38,14 @@ if (textStore.getItem('tool') !== '46&2') { jsonStore.setItem('mjk', mjkModel); -const mjkTest = jsonStore.getItem('mjk'); +if (jsonStore.getItem('mjk') === null) { + throw new Error('.getItem failed.'); +} -if (mjkTest === null || mjkTest.firstName !== mjkModel.firstName || mjkTest.middleName !== mjkModel.middleName || mjkTest.familyName !== mjkModel.familyName) { - throw new Error('.setJson method is not working!'); +const mjkTest: Person = jsonStore.getItem('mjk'); + +if (mjkTest === null || mjkTest.givenName !== mjkModel.givenName || mjkTest.middleName !== mjkModel.middleName || mjkTest.familyName !== mjkModel.familyName) { + throw new Error('.setItem method is not working!'); } const keyCheck = textStore.key(0); From 84e1f287bd076c9c9cb203f4d28ba14e61516888 Mon Sep 17 00:00:00 2001 From: Denis Malinochkin Date: Tue, 28 Aug 2018 20:15:21 +0300 Subject: [PATCH 28/59] =?UTF-8?q?feat(types):=20Add=20types=20for=20the=20?= =?UTF-8?q?=C2=ABcompute-quantile=C2=BB=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compute-quantile-tests.ts | 13 +++++++++++ types/compute-quantile/index.d.ts | 23 +++++++++++++++++++ types/compute-quantile/tsconfig.json | 23 +++++++++++++++++++ types/compute-quantile/tslint.json | 1 + 4 files changed, 60 insertions(+) create mode 100644 types/compute-quantile/compute-quantile-tests.ts create mode 100644 types/compute-quantile/index.d.ts create mode 100644 types/compute-quantile/tsconfig.json create mode 100644 types/compute-quantile/tslint.json diff --git a/types/compute-quantile/compute-quantile-tests.ts b/types/compute-quantile/compute-quantile-tests.ts new file mode 100644 index 0000000000..8a4c51ea3d --- /dev/null +++ b/types/compute-quantile/compute-quantile-tests.ts @@ -0,0 +1,13 @@ +import quantile = require('compute-quantile'); + +// $ExpectType number +quantile([1, 2, 3], 0.5); + +// $ExpectType number +quantile([1, 2, 3], 0.5, undefined); + +// $ExpectType number +quantile([1, 2, 3], 0.5, {}); + +// $ExpectType number +quantile([1, 2, 3], 0.5, { sorted: true }); diff --git a/types/compute-quantile/index.d.ts b/types/compute-quantile/index.d.ts new file mode 100644 index 0000000000..05d83b65f4 --- /dev/null +++ b/types/compute-quantile/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for compute-quantile 1.0 +// Project: https://github.com/compute-io/quantile +// Definitions by: mrmlnc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Computes a quantile for a numeric array. + */ +declare function quantile(array: ArrayLike, quantile: number, options?: quantile.Options): number; + +declare namespace quantile { + interface Options { + /** + * If the input `array` is already sorted in `__ascending__` order, you can set the `sorted` option to `true`. + * + * @default + * false + */ + sorted?: boolean; + } +} + +export = quantile; diff --git a/types/compute-quantile/tsconfig.json b/types/compute-quantile/tsconfig.json new file mode 100644 index 0000000000..29d10580e3 --- /dev/null +++ b/types/compute-quantile/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", + "compute-quantile-tests.ts" + ] +} diff --git a/types/compute-quantile/tslint.json b/types/compute-quantile/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/compute-quantile/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 8e2d67eceeb0529feddf403f08f967bf7dbff628 Mon Sep 17 00:00:00 2001 From: Eduardo Henke Date: Wed, 29 Aug 2018 16:53:48 -0300 Subject: [PATCH 29/59] Add tiny-secp256k1 library typing --- types/tiny-secp256k1/index.d.ts | 94 ++++++++++++++++++++ types/tiny-secp256k1/tiny-secp256k1-tests.ts | 11 +++ types/tiny-secp256k1/tsconfig.json | 22 +++++ types/tiny-secp256k1/tslint.json | 1 + 4 files changed, 128 insertions(+) create mode 100644 types/tiny-secp256k1/index.d.ts create mode 100644 types/tiny-secp256k1/tiny-secp256k1-tests.ts create mode 100644 types/tiny-secp256k1/tsconfig.json create mode 100644 types/tiny-secp256k1/tslint.json diff --git a/types/tiny-secp256k1/index.d.ts b/types/tiny-secp256k1/index.d.ts new file mode 100644 index 0000000000..35cd73400b --- /dev/null +++ b/types/tiny-secp256k1/index.d.ts @@ -0,0 +1,94 @@ +// Type definitions for tiny-secp256k1 v1.0.0 +// Project: https://github.com/bitcoinjs/tiny-secp256k1 +// Definitions by: Eduardo Henke +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +/** + * Checks if A is a point in the curve + * @param A should be: + * encoded with a sequence tag of 0x02, 0x03 or 0x04 + * A.x is within [1...p - 1] + * A.y is within [1...p - 1] + */ +export function isPoint(A: Buffer): boolean; + +/** + * Returns false if the point is not compressed. + */ +export function isPointCompressed(A: Buffer): boolean; + +/** + * Checks if point is private key + * @param d should be: + * 256-bit + * within [1...order - 1] + */ +export function isPrivate(d: Buffer): boolean; + +/** + * Returns null if result is at infinity. + * @param A isPoint(A) should be true + * @param B isPoint(B) should be true + * @param compressed optional, if true compresses the resulting point + */ +export function pointAdd(A: Buffer, B: Buffer, compressed?: boolean): Buffer | null; + +/** + * Returns null if result is at infinity. + * @param A isPoint(A) should be true + * @param tweak should be within [1...order - 1] + * @param compressed optional, if true compresses the resulting point + */ +export function pointAddScalar(A: Buffer, tweak: Buffer, compressed?: boolean): Buffer | null; + +/** + * Compresses point A. + * @param A isPoint(A) should be true + * @param compressed if true compresses A + */ +export function pointCompress(A: Buffer, compressed: boolean): Buffer; + +/** + * Returns null if result is at infinity. + * @param d isPrivate(d) should be true + * @param compressed optional, if true compresses the resulting point + */ +export function pointFromScalar(d: Buffer, compressed?: boolean): Buffer | null; + +/** + * Returns null if result is at infinity. + * @param A isPoint(A) should be true + * @param tweak should be within [1...order - 1] + * @param compressed optional, if true compresses the resulting point + */ +export function pointMultiply(A: Buffer, tweak: Buffer, compressed?: boolean): Buffer | null; + +/** + * Returns null if result is equal to 0. + * @param d isPrivate(d) should be true + * @param tweak should be within [1...order - 1] + */ +export function privateAdd(d: Buffer, tweak: Buffer): Buffer | null; + +/** + * Returns null if result is equal to 0. + * @param d isPrivate(d) should be true + * @param tweak should be within [1...order - 1] + */ +export function privateSub(d: Buffer, tweak: Buffer): Buffer | null; + +/** + * Returns normalized signatures, each of (r, s) values are guaranteed to less than order / 2. Uses RFC6979. + * @param message should be 256-bit + * @param privateKey isPrivate(privateKey) should be true + */ +export function sign(message: Buffer, privateKey: Buffer): Buffer; + +/** + * Returns false if any of (r, s) values are equal to 0, or if the signature is rejected. + * @param message should be 256-bit + * @param publicKey isPoint(publicKey) should be true + * @param signature signature should have all (r, s) values within range [0...order - 1] + */ +export function verify(message: Buffer, publicKey: Buffer, signature: Buffer): boolean; diff --git a/types/tiny-secp256k1/tiny-secp256k1-tests.ts b/types/tiny-secp256k1/tiny-secp256k1-tests.ts new file mode 100644 index 0000000000..1203f3fed1 --- /dev/null +++ b/types/tiny-secp256k1/tiny-secp256k1-tests.ts @@ -0,0 +1,11 @@ +import { pointFromScalar, sign, verify } from 'tiny-secp256k1'; + +const d = Buffer.from('5272e811987e04833abf88c2cdbb43eddfefd7b4afa50e87bfcd3a2b297f0a93'); +const Q = pointFromScalar(d); + +const message = new Buffer(new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64])); +const signature = sign(message, d); + +if (Q !== null) { + verify(message, Q, signature); +} diff --git a/types/tiny-secp256k1/tsconfig.json b/types/tiny-secp256k1/tsconfig.json new file mode 100644 index 0000000000..b189f55e66 --- /dev/null +++ b/types/tiny-secp256k1/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es5" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "tiny-secp256k1-tests.ts" + ] +} diff --git a/types/tiny-secp256k1/tslint.json b/types/tiny-secp256k1/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/tiny-secp256k1/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 238df04ce8e6d254fa16d59129f5663d4e9c4a70 Mon Sep 17 00:00:00 2001 From: Eduardo Henke Date: Wed, 29 Aug 2018 17:08:35 -0300 Subject: [PATCH 30/59] Fix lint errors --- types/tiny-secp256k1/index.d.ts | 4 ++-- types/tiny-secp256k1/tsconfig.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/types/tiny-secp256k1/index.d.ts b/types/tiny-secp256k1/index.d.ts index 35cd73400b..7c71cab5cc 100644 --- a/types/tiny-secp256k1/index.d.ts +++ b/types/tiny-secp256k1/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for tiny-secp256k1 v1.0.0 +// Type definitions for tiny-secp256k1 1.0 // Project: https://github.com/bitcoinjs/tiny-secp256k1 -// Definitions by: Eduardo Henke +// Definitions by: Eduardo Henke // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/types/tiny-secp256k1/tsconfig.json b/types/tiny-secp256k1/tsconfig.json index b189f55e66..377e6d639c 100644 --- a/types/tiny-secp256k1/tsconfig.json +++ b/types/tiny-secp256k1/tsconfig.json @@ -13,7 +13,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true }, "files": [ "index.d.ts", From 713ad0f55f5db2689f75423c19dc2b05e630a490 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Wed, 29 Aug 2018 12:33:09 -0700 Subject: [PATCH 31/59] adds typings for the 'bitwise' package --- types/bitwise/bits/and.d.ts | 4 ++ types/bitwise/bits/index.d.ts | 33 +++++++++++++++ types/bitwise/bits/nand.d.ts | 4 ++ types/bitwise/bits/nor.d.ts | 4 ++ types/bitwise/bits/not.d.ts | 4 ++ types/bitwise/bits/or.d.ts | 4 ++ types/bitwise/bits/reduce-and.d.ts | 1 + types/bitwise/bits/reduce-nand.d.ts | 1 + types/bitwise/bits/reduce-nor.d.ts | 1 + types/bitwise/bits/reduce-or.d.ts | 1 + types/bitwise/bits/reduce-xnor.d.ts | 1 + types/bitwise/bits/reduce-xor.d.ts | 1 + types/bitwise/bits/to-boolean.d.ts | 3 ++ types/bitwise/bits/to-string.d.ts | 5 +++ types/bitwise/bits/xnor.d.ts | 4 ++ types/bitwise/bits/xor.d.ts | 4 ++ types/bitwise/bitwise-tests.ts | 56 +++++++++++++++++++++++++ types/bitwise/buffer/and.d.ts | 7 ++++ types/bitwise/buffer/create.d.ts | 3 ++ types/bitwise/buffer/index.d.ts | 31 ++++++++++++++ types/bitwise/buffer/modify.d.ts | 7 ++++ types/bitwise/buffer/nand.d.ts | 7 ++++ types/bitwise/buffer/nor.d.ts | 7 ++++ types/bitwise/buffer/not.d.ts | 3 ++ types/bitwise/buffer/or.d.ts | 7 ++++ types/bitwise/buffer/read-c-int.d.ts | 7 ++++ types/bitwise/buffer/read-int.d.ts | 7 ++++ types/bitwise/buffer/read-u-int.d.ts | 7 ++++ types/bitwise/buffer/read.d.ts | 7 ++++ types/bitwise/buffer/xnor.d.ts | 7 ++++ types/bitwise/buffer/xor.d.ts | 7 ++++ types/bitwise/byte/index.d.ts | 9 ++++ types/bitwise/byte/read.d.ts | 1 + types/bitwise/byte/write.d.ts | 1 + types/bitwise/index.d.ts | 22 ++++++++++ types/bitwise/integer/get-bit.d.ts | 1 + types/bitwise/integer/index.d.ts | 11 +++++ types/bitwise/integer/set-bit.d.ts | 5 +++ types/bitwise/integer/toggle-bit.d.ts | 4 ++ types/bitwise/nibble/index.d.ts | 9 ++++ types/bitwise/nibble/read.d.ts | 1 + types/bitwise/nibble/write.d.ts | 1 + types/bitwise/string/index.d.ts | 7 ++++ types/bitwise/string/to-bits.d.ts | 1 + types/bitwise/tsconfig.json | 60 +++++++++++++++++++++++++++ types/bitwise/tslint.json | 3 ++ 46 files changed, 381 insertions(+) create mode 100644 types/bitwise/bits/and.d.ts create mode 100644 types/bitwise/bits/index.d.ts create mode 100644 types/bitwise/bits/nand.d.ts create mode 100644 types/bitwise/bits/nor.d.ts create mode 100644 types/bitwise/bits/not.d.ts create mode 100644 types/bitwise/bits/or.d.ts create mode 100644 types/bitwise/bits/reduce-and.d.ts create mode 100644 types/bitwise/bits/reduce-nand.d.ts create mode 100644 types/bitwise/bits/reduce-nor.d.ts create mode 100644 types/bitwise/bits/reduce-or.d.ts create mode 100644 types/bitwise/bits/reduce-xnor.d.ts create mode 100644 types/bitwise/bits/reduce-xor.d.ts create mode 100644 types/bitwise/bits/to-boolean.d.ts create mode 100644 types/bitwise/bits/to-string.d.ts create mode 100644 types/bitwise/bits/xnor.d.ts create mode 100644 types/bitwise/bits/xor.d.ts create mode 100644 types/bitwise/bitwise-tests.ts create mode 100644 types/bitwise/buffer/and.d.ts create mode 100644 types/bitwise/buffer/create.d.ts create mode 100644 types/bitwise/buffer/index.d.ts create mode 100644 types/bitwise/buffer/modify.d.ts create mode 100644 types/bitwise/buffer/nand.d.ts create mode 100644 types/bitwise/buffer/nor.d.ts create mode 100644 types/bitwise/buffer/not.d.ts create mode 100644 types/bitwise/buffer/or.d.ts create mode 100644 types/bitwise/buffer/read-c-int.d.ts create mode 100644 types/bitwise/buffer/read-int.d.ts create mode 100644 types/bitwise/buffer/read-u-int.d.ts create mode 100644 types/bitwise/buffer/read.d.ts create mode 100644 types/bitwise/buffer/xnor.d.ts create mode 100644 types/bitwise/buffer/xor.d.ts create mode 100644 types/bitwise/byte/index.d.ts create mode 100644 types/bitwise/byte/read.d.ts create mode 100644 types/bitwise/byte/write.d.ts create mode 100644 types/bitwise/index.d.ts create mode 100644 types/bitwise/integer/get-bit.d.ts create mode 100644 types/bitwise/integer/index.d.ts create mode 100644 types/bitwise/integer/set-bit.d.ts create mode 100644 types/bitwise/integer/toggle-bit.d.ts create mode 100644 types/bitwise/nibble/index.d.ts create mode 100644 types/bitwise/nibble/read.d.ts create mode 100644 types/bitwise/nibble/write.d.ts create mode 100644 types/bitwise/string/index.d.ts create mode 100644 types/bitwise/string/to-bits.d.ts create mode 100644 types/bitwise/tsconfig.json create mode 100644 types/bitwise/tslint.json diff --git a/types/bitwise/bits/and.d.ts b/types/bitwise/bits/and.d.ts new file mode 100644 index 0000000000..52696eee01 --- /dev/null +++ b/types/bitwise/bits/and.d.ts @@ -0,0 +1,4 @@ +export default function and( + bits1: ReadonlyArray, + bits2: ReadonlyArray +): ReadonlyArray; diff --git a/types/bitwise/bits/index.d.ts b/types/bitwise/bits/index.d.ts new file mode 100644 index 0000000000..8bc86d20af --- /dev/null +++ b/types/bitwise/bits/index.d.ts @@ -0,0 +1,33 @@ +import bitsAnd from './and'; +import bitsNor from './nor'; +import bitsNot from './not'; +import bitsOr from './or'; +import bitsReduceAnd from './reduce-and'; +import bitsReduceNand from './reduce-nand'; +import bitsReduceNor from './reduce-nor'; +import bitsReduceOr from './reduce-or'; +import bitsReduceXnor from './reduce-xnor'; +import bitsReduceXor from './reduce-xor'; +import bitsToBoolean from './to-boolean'; +import bitsToString from './to-string'; +import bitsXnor from './xnor'; +import bitsXor from './xor'; + +declare namespace bits { + const and: typeof bitsAnd; + const nor: typeof bitsNor; + const not: typeof bitsNot; + const or: typeof bitsOr; + const reduceAnd: typeof bitsReduceAnd; + const reduceNand: typeof bitsReduceNand; + const reduceNor: typeof bitsReduceNor; + const reduceOr: typeof bitsReduceOr; + const reduceXnor: typeof bitsReduceXnor; + const reduceXor: typeof bitsReduceXor; + const toBoolean: typeof bitsToBoolean; + const toString: typeof bitsToString; + const xnor: typeof bitsXnor; + const xor: typeof bitsXor; +} + +export default bits; diff --git a/types/bitwise/bits/nand.d.ts b/types/bitwise/bits/nand.d.ts new file mode 100644 index 0000000000..53338816b8 --- /dev/null +++ b/types/bitwise/bits/nand.d.ts @@ -0,0 +1,4 @@ +export default function nand( + bits1: ReadonlyArray, + bits2: ReadonlyArray +): ReadonlyArray; diff --git a/types/bitwise/bits/nor.d.ts b/types/bitwise/bits/nor.d.ts new file mode 100644 index 0000000000..cda86e1a7c --- /dev/null +++ b/types/bitwise/bits/nor.d.ts @@ -0,0 +1,4 @@ +export default function nor( + bits1: ReadonlyArray, + bits2: ReadonlyArray +): ReadonlyArray; diff --git a/types/bitwise/bits/not.d.ts b/types/bitwise/bits/not.d.ts new file mode 100644 index 0000000000..7be251c891 --- /dev/null +++ b/types/bitwise/bits/not.d.ts @@ -0,0 +1,4 @@ +export default function not( + bits1: ReadonlyArray, + bits2: ReadonlyArray +): ReadonlyArray; diff --git a/types/bitwise/bits/or.d.ts b/types/bitwise/bits/or.d.ts new file mode 100644 index 0000000000..953a50d4c2 --- /dev/null +++ b/types/bitwise/bits/or.d.ts @@ -0,0 +1,4 @@ +export default function or( + bits1: ReadonlyArray, + bits2: ReadonlyArray +): ReadonlyArray; diff --git a/types/bitwise/bits/reduce-and.d.ts b/types/bitwise/bits/reduce-and.d.ts new file mode 100644 index 0000000000..b45c023eb0 --- /dev/null +++ b/types/bitwise/bits/reduce-and.d.ts @@ -0,0 +1 @@ +export default function reduceAnd(bits: ReadonlyArray): number; diff --git a/types/bitwise/bits/reduce-nand.d.ts b/types/bitwise/bits/reduce-nand.d.ts new file mode 100644 index 0000000000..7fd8b8f6b4 --- /dev/null +++ b/types/bitwise/bits/reduce-nand.d.ts @@ -0,0 +1 @@ +export default function reduceNand(bits: ReadonlyArray): number; diff --git a/types/bitwise/bits/reduce-nor.d.ts b/types/bitwise/bits/reduce-nor.d.ts new file mode 100644 index 0000000000..9d8a64f729 --- /dev/null +++ b/types/bitwise/bits/reduce-nor.d.ts @@ -0,0 +1 @@ +export default function reduceNor(bits: ReadonlyArray): number; diff --git a/types/bitwise/bits/reduce-or.d.ts b/types/bitwise/bits/reduce-or.d.ts new file mode 100644 index 0000000000..676e4ff347 --- /dev/null +++ b/types/bitwise/bits/reduce-or.d.ts @@ -0,0 +1 @@ +export default function reduceOr(bits: ReadonlyArray): number; diff --git a/types/bitwise/bits/reduce-xnor.d.ts b/types/bitwise/bits/reduce-xnor.d.ts new file mode 100644 index 0000000000..be64ebaaa3 --- /dev/null +++ b/types/bitwise/bits/reduce-xnor.d.ts @@ -0,0 +1 @@ +export default function reduceXnor(bits: ReadonlyArray): number; diff --git a/types/bitwise/bits/reduce-xor.d.ts b/types/bitwise/bits/reduce-xor.d.ts new file mode 100644 index 0000000000..9a2107237a --- /dev/null +++ b/types/bitwise/bits/reduce-xor.d.ts @@ -0,0 +1 @@ +export default function reduceXor(bits: ReadonlyArray): number; diff --git a/types/bitwise/bits/to-boolean.d.ts b/types/bitwise/bits/to-boolean.d.ts new file mode 100644 index 0000000000..50bd8f4bc8 --- /dev/null +++ b/types/bitwise/bits/to-boolean.d.ts @@ -0,0 +1,3 @@ +export default function toBoolean( + bits: ReadonlyArray +): ReadonlyArray; diff --git a/types/bitwise/bits/to-string.d.ts b/types/bitwise/bits/to-string.d.ts new file mode 100644 index 0000000000..1fee89675d --- /dev/null +++ b/types/bitwise/bits/to-string.d.ts @@ -0,0 +1,5 @@ +export default function toString( + bit: ReadonlyArray, + spacing?: number, + spacer?: string +): string; diff --git a/types/bitwise/bits/xnor.d.ts b/types/bitwise/bits/xnor.d.ts new file mode 100644 index 0000000000..b6e11fcdf1 --- /dev/null +++ b/types/bitwise/bits/xnor.d.ts @@ -0,0 +1,4 @@ +export default function xnor( + bits1: ReadonlyArray, + bits2: ReadonlyArray +): ReadonlyArray; diff --git a/types/bitwise/bits/xor.d.ts b/types/bitwise/bits/xor.d.ts new file mode 100644 index 0000000000..a8b7816408 --- /dev/null +++ b/types/bitwise/bits/xor.d.ts @@ -0,0 +1,4 @@ +export default function xor( + bits1: ReadonlyArray, + bits2: ReadonlyArray +): ReadonlyArray; diff --git a/types/bitwise/bitwise-tests.ts b/types/bitwise/bitwise-tests.ts new file mode 100644 index 0000000000..6975cb3591 --- /dev/null +++ b/types/bitwise/bitwise-tests.ts @@ -0,0 +1,56 @@ +// Demonstrating cherry-picking +import bitwise from 'bitwise'; + +import bits from 'bitwise/bits'; +import toBoolean from 'bitwise/bits/to-boolean'; + +import buffer from 'bitwise/buffer'; +import create from 'bitwise/buffer/create'; + +import byte from 'bitwise/byte'; +import read from 'bitwise/byte/read'; + +import integer from 'bitwise/integer'; +import setBit from 'bitwise/integer/set-bit'; + +import nibble from 'bitwise/nibble'; +import nibbleRead from 'bitwise/nibble/read'; + +import string from 'bitwise/string'; +import toBits from 'bitwise/string/to-bits'; + +// Testing basic functions +const testBits = [0, 1, 1, 0, 1]; + +// $ExpectType string +bitwise.bits.toString(testBits); + +// $ExpectType ReadonlyArray +bits.toBoolean(testBits); +// $ExpectType ReadonlyArray +toBoolean(testBits); + +// $ExpectType ReadonlyArray +byte.read(12); +// $ExpectType ReadonlyArray +read(12); + +// $ExpectType Buffer +buffer.create(testBits); +// $ExpectType Buffer +create(testBits); + +// $ExpectType ReadonlyArray +integer.setBit(12, 1, 0); +// $ExpectType ReadonlyArray +setBit(12, 1, 0); + +// $ExpectType ReadonlyArray +nibble.read(15); +// $ExpectType ReadonlyArray +nibbleRead(15); + +// $ExpectType ReadonlyArray +string.toBits('10 10 12$%_.0'); +// $ExpectType ReadonlyArray +toBits('10 10 12$%_.0'); diff --git a/types/bitwise/buffer/and.d.ts b/types/bitwise/buffer/and.d.ts new file mode 100644 index 0000000000..c4789600c3 --- /dev/null +++ b/types/bitwise/buffer/and.d.ts @@ -0,0 +1,7 @@ +/// + +export default function and( + buffer1: Buffer, + buffer2: Buffer, + isLooping?: boolean +): Buffer; diff --git a/types/bitwise/buffer/create.d.ts b/types/bitwise/buffer/create.d.ts new file mode 100644 index 0000000000..3c67301d97 --- /dev/null +++ b/types/bitwise/buffer/create.d.ts @@ -0,0 +1,3 @@ +/// + +export default function create(bits: ReadonlyArray): Buffer; diff --git a/types/bitwise/buffer/index.d.ts b/types/bitwise/buffer/index.d.ts new file mode 100644 index 0000000000..a109aecb73 --- /dev/null +++ b/types/bitwise/buffer/index.d.ts @@ -0,0 +1,31 @@ +import bufferAnd from './and'; +import bufferCreate from './create'; +import bufferModify from './modify'; +import bufferNand from './nand'; +import bufferNor from './nor'; +import bufferNot from './not'; +import bufferOr from './or'; +import bufferRead from './read'; +import bufferReadCInt from './read-c-int'; +import bufferReadInt from './read-int'; +import bufferReadUInt from './read-u-int'; +import bufferXnor from './xnor'; +import bufferXor from './xor'; + +declare namespace buffer { + const and: typeof bufferAnd; + const create: typeof bufferCreate; + const modify: typeof bufferModify; + const nand: typeof bufferNand; + const nor: typeof bufferNor; + const not: typeof bufferNot; + const or: typeof bufferOr; + const read: typeof bufferRead; + const readCInt: typeof bufferReadCInt; + const readInt: typeof bufferReadInt; + const readUInt: typeof bufferReadUInt; + const xnor: typeof bufferXnor; + const xor: typeof bufferXor; +} + +export default buffer; diff --git a/types/bitwise/buffer/modify.d.ts b/types/bitwise/buffer/modify.d.ts new file mode 100644 index 0000000000..1d242cfd79 --- /dev/null +++ b/types/bitwise/buffer/modify.d.ts @@ -0,0 +1,7 @@ +/// + +export default function modify( + buffer: Buffer, + newBits: ReadonlyArray, + bitOffset?: number +): void; diff --git a/types/bitwise/buffer/nand.d.ts b/types/bitwise/buffer/nand.d.ts new file mode 100644 index 0000000000..f887d7f82a --- /dev/null +++ b/types/bitwise/buffer/nand.d.ts @@ -0,0 +1,7 @@ +/// + +export default function nand( + buffer1: Buffer, + buffer2: Buffer, + isLooping?: boolean +): Buffer; diff --git a/types/bitwise/buffer/nor.d.ts b/types/bitwise/buffer/nor.d.ts new file mode 100644 index 0000000000..7d285abce0 --- /dev/null +++ b/types/bitwise/buffer/nor.d.ts @@ -0,0 +1,7 @@ +/// + +export default function nor( + buffer1: Buffer, + buffer2: Buffer, + isLooping: boolean +): Buffer; diff --git a/types/bitwise/buffer/not.d.ts b/types/bitwise/buffer/not.d.ts new file mode 100644 index 0000000000..8dd6e56434 --- /dev/null +++ b/types/bitwise/buffer/not.d.ts @@ -0,0 +1,3 @@ +/// + +export default function not(buffer: Buffer): Buffer; diff --git a/types/bitwise/buffer/or.d.ts b/types/bitwise/buffer/or.d.ts new file mode 100644 index 0000000000..1f06097215 --- /dev/null +++ b/types/bitwise/buffer/or.d.ts @@ -0,0 +1,7 @@ +/// + +export default function or( + buffer1: Buffer, + buffer2: Buffer, + isLooping?: boolean +): Buffer; diff --git a/types/bitwise/buffer/read-c-int.d.ts b/types/bitwise/buffer/read-c-int.d.ts new file mode 100644 index 0000000000..d3d1caca3c --- /dev/null +++ b/types/bitwise/buffer/read-c-int.d.ts @@ -0,0 +1,7 @@ +/// + +export default function readCInt( + buffer: Buffer, + bitOffset?: number, + bitLength?: number +): number; diff --git a/types/bitwise/buffer/read-int.d.ts b/types/bitwise/buffer/read-int.d.ts new file mode 100644 index 0000000000..3bb3f65a58 --- /dev/null +++ b/types/bitwise/buffer/read-int.d.ts @@ -0,0 +1,7 @@ +/// + +export default function readInt( + buffer: Buffer, + bitOffset?: number, + bitLength?: number +): number; diff --git a/types/bitwise/buffer/read-u-int.d.ts b/types/bitwise/buffer/read-u-int.d.ts new file mode 100644 index 0000000000..5e5eec4b07 --- /dev/null +++ b/types/bitwise/buffer/read-u-int.d.ts @@ -0,0 +1,7 @@ +/// + +export default function readUInt( + buffer: Buffer, + bitOffset?: number, + bitLength?: number +): number; diff --git a/types/bitwise/buffer/read.d.ts b/types/bitwise/buffer/read.d.ts new file mode 100644 index 0000000000..b5e5f18f58 --- /dev/null +++ b/types/bitwise/buffer/read.d.ts @@ -0,0 +1,7 @@ +/// + +export default function read( + buffer: Buffer, + bitOffset?: number, + bitLength?: number +): ReadonlyArray; diff --git a/types/bitwise/buffer/xnor.d.ts b/types/bitwise/buffer/xnor.d.ts new file mode 100644 index 0000000000..4cfd64dc88 --- /dev/null +++ b/types/bitwise/buffer/xnor.d.ts @@ -0,0 +1,7 @@ +/// + +export default function xnor( + buffer1: Buffer, + buffer2: Buffer, + isLooping?: boolean +): Buffer; diff --git a/types/bitwise/buffer/xor.d.ts b/types/bitwise/buffer/xor.d.ts new file mode 100644 index 0000000000..61ce88f10a --- /dev/null +++ b/types/bitwise/buffer/xor.d.ts @@ -0,0 +1,7 @@ +/// + +export default function xor( + buffer1: Buffer, + buffer2: Buffer, + isLooping?: boolean +): Buffer; diff --git a/types/bitwise/byte/index.d.ts b/types/bitwise/byte/index.d.ts new file mode 100644 index 0000000000..f2e3c21d42 --- /dev/null +++ b/types/bitwise/byte/index.d.ts @@ -0,0 +1,9 @@ +import byteRead from './read'; +import byteWrite from './write'; + +declare namespace byte { + const read: typeof byteRead; + const write: typeof byteWrite; +} + +export default byte; diff --git a/types/bitwise/byte/read.d.ts b/types/bitwise/byte/read.d.ts new file mode 100644 index 0000000000..10fc79106e --- /dev/null +++ b/types/bitwise/byte/read.d.ts @@ -0,0 +1 @@ +export default function read(byte: number): ReadonlyArray; diff --git a/types/bitwise/byte/write.d.ts b/types/bitwise/byte/write.d.ts new file mode 100644 index 0000000000..be485032da --- /dev/null +++ b/types/bitwise/byte/write.d.ts @@ -0,0 +1 @@ +export default function write(bits: ReadonlyArray): number; diff --git a/types/bitwise/index.d.ts b/types/bitwise/index.d.ts new file mode 100644 index 0000000000..4e1ae86896 --- /dev/null +++ b/types/bitwise/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for bitwise 1.5 +// Project: https://github.com/dodekeract/bitwise +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import bitwiseBits from './bits'; +import bitwiseBuffer from './buffer'; +import bitwiseByte from './byte'; +import bitwiseInteger from './integer'; +import bitwiseNibble from './nibble'; +import bitwiseString from './string'; + +declare namespace bitwise { + const bits: typeof bitwiseBits; + const buffer: typeof bitwiseBuffer; + const byte: typeof bitwiseByte; + const integer: typeof bitwiseInteger; + const nibble: typeof bitwiseNibble; + const string: typeof bitwiseString; +} + +export default bitwise; diff --git a/types/bitwise/integer/get-bit.d.ts b/types/bitwise/integer/get-bit.d.ts new file mode 100644 index 0000000000..ced50ff35c --- /dev/null +++ b/types/bitwise/integer/get-bit.d.ts @@ -0,0 +1 @@ +export default function getBit(number: number, position: number): number; diff --git a/types/bitwise/integer/index.d.ts b/types/bitwise/integer/index.d.ts new file mode 100644 index 0000000000..965726728b --- /dev/null +++ b/types/bitwise/integer/index.d.ts @@ -0,0 +1,11 @@ +import integerGetBit from './get-bit'; +import integerSetBit from './set-bit'; +import integerToggleBit from './toggle-bit'; + +declare namespace integer { + const getBit: typeof integerGetBit; + const setBit: typeof integerSetBit; + const toggleBit: typeof integerToggleBit; +} + +export default integer; diff --git a/types/bitwise/integer/set-bit.d.ts b/types/bitwise/integer/set-bit.d.ts new file mode 100644 index 0000000000..a6524c4079 --- /dev/null +++ b/types/bitwise/integer/set-bit.d.ts @@ -0,0 +1,5 @@ +export default function setBit( + number: number, + position: number, + value: number +): ReadonlyArray; diff --git a/types/bitwise/integer/toggle-bit.d.ts b/types/bitwise/integer/toggle-bit.d.ts new file mode 100644 index 0000000000..a3ea04da80 --- /dev/null +++ b/types/bitwise/integer/toggle-bit.d.ts @@ -0,0 +1,4 @@ +export default function toggleBit( + number: number, + position: number +): ReadonlyArray; diff --git a/types/bitwise/nibble/index.d.ts b/types/bitwise/nibble/index.d.ts new file mode 100644 index 0000000000..a18ed9ef6f --- /dev/null +++ b/types/bitwise/nibble/index.d.ts @@ -0,0 +1,9 @@ +import nibbleRead from './read'; +import nibbleWrite from './write'; + +declare namespace nibble { + const read: typeof nibbleRead; + const write: typeof nibbleWrite; +} + +export default nibble; diff --git a/types/bitwise/nibble/read.d.ts b/types/bitwise/nibble/read.d.ts new file mode 100644 index 0000000000..a1182a72dd --- /dev/null +++ b/types/bitwise/nibble/read.d.ts @@ -0,0 +1 @@ +export default function read(nibble: number): ReadonlyArray; diff --git a/types/bitwise/nibble/write.d.ts b/types/bitwise/nibble/write.d.ts new file mode 100644 index 0000000000..4e79f88571 --- /dev/null +++ b/types/bitwise/nibble/write.d.ts @@ -0,0 +1 @@ +export default function write(nibble: ReadonlyArray): number; diff --git a/types/bitwise/string/index.d.ts b/types/bitwise/string/index.d.ts new file mode 100644 index 0000000000..9100d0050b --- /dev/null +++ b/types/bitwise/string/index.d.ts @@ -0,0 +1,7 @@ +import stringToBits from './to-bits'; + +declare namespace string { + const toBits: typeof stringToBits; +} + +export default string; diff --git a/types/bitwise/string/to-bits.d.ts b/types/bitwise/string/to-bits.d.ts new file mode 100644 index 0000000000..4930f10f79 --- /dev/null +++ b/types/bitwise/string/to-bits.d.ts @@ -0,0 +1 @@ +export default function toBits(string: string): ReadonlyArray; diff --git a/types/bitwise/tsconfig.json b/types/bitwise/tsconfig.json new file mode 100644 index 0000000000..9956f50c76 --- /dev/null +++ b/types/bitwise/tsconfig.json @@ -0,0 +1,60 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bitwise-tests.ts", + "bits/and.d.ts", + "bits/index.d.ts", + "bits/nand.d.ts", + "bits/nor.d.ts", + "bits/not.d.ts", + "bits/or.d.ts", + "bits/reduce-and.d.ts", + "bits/reduce-nand.d.ts", + "bits/reduce-nor.d.ts", + "bits/reduce-or.d.ts", + "bits/reduce-xnor.d.ts", + "bits/reduce-xor.d.ts", + "bits/to-boolean.d.ts", + "bits/to-string.d.ts", + "bits/xnor.d.ts", + "bits/xor.d.ts", + "buffer/and.d.ts", + "buffer/create.d.ts", + "buffer/modify.d.ts", + "buffer/nand.d.ts", + "buffer/nor.d.ts", + "buffer/not.d.ts", + "buffer/or.d.ts", + "buffer/read-c-int.d.ts", + "buffer/read-int.d.ts", + "buffer/read-u-int.d.ts", + "buffer/read.d.ts", + "buffer/xnor.d.ts", + "buffer/xor.d.ts", + "byte/index.d.ts", + "byte/read.d.ts", + "byte/write.d.ts", + "integer/get-bit.d.ts", + "integer/index.d.ts", + "integer/set-bit.d.ts", + "integer/toggle-bit.d.ts", + "nibble/index.d.ts", + "nibble/read.d.ts", + "nibble/write.d.ts", + "string/index.d.ts", + "string/to-bits.d.ts" + ] +} diff --git a/types/bitwise/tslint.json b/types/bitwise/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/bitwise/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 96c9c7f10caeba27ccba8703c1832cb0fff9f0bc Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Wed, 29 Aug 2018 16:43:06 -0700 Subject: [PATCH 32/59] adds typings for the 'megajs' package --- types/megajs/index.d.ts | 116 +++++++++++++++++++++++++++++++++++ types/megajs/megajs-tests.ts | 9 +++ types/megajs/tsconfig.json | 19 ++++++ types/megajs/tslint.json | 3 + 4 files changed, 147 insertions(+) create mode 100644 types/megajs/index.d.ts create mode 100644 types/megajs/megajs-tests.ts create mode 100644 types/megajs/tsconfig.json create mode 100644 types/megajs/tslint.json diff --git a/types/megajs/index.d.ts b/types/megajs/index.d.ts new file mode 100644 index 0000000000..8162d6d648 --- /dev/null +++ b/types/megajs/index.d.ts @@ -0,0 +1,116 @@ +// Type definitions for megajs 0.14 +// Project: https://github.com/qgustavor/mega +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +import { Readable, Writable, Stream } from 'stream'; + +export interface AccountInfo { + type: string; + spaceUsed: number; + spaceTotal: number; + downloadBandwidthUsed: number; + downloadBandwidthTotal: number; + sharedBandwidthUsed: number; + sharedBandwidthLimit: number; +} + +export interface DownloadOptions { + maxConnections?: number; + initialChunkSize?: number; + chunkSizeIncrement?: number; + maxChunkSize?: number; + returnCiphertext?: boolean; + start?: any; + end?: any; +} + +export interface UploadOptions { + name: string; + attributes?: object; + size?: any; + thumbnailImage?: Buffer | Readable; + previewImage?: Buffer | Readable; +} + +export interface LinkOptions { + noKey?: boolean; + key?: string | Buffer; +} + +export interface MakeDirectoryOptions { + name: string; + attributes?: object; + key?: string | Buffer; +} + +export interface FileOptions { + downloadId: string; + key: string; + directory: boolean; +} + +export interface StorageOptions { + email: string; + password: string; + keepalive?: boolean; + autologin?: boolean; + autoload?: boolean; +} + +export class File { + constructor(options: FileOptions | string); + static fromURL(options: FileOptions | string): File; + static unpackAttributes(at: any): JSON; + name: string; + attributes: object; + size: number; + key: Buffer; + timestamp: number; + nodeId: string; + downloadId: string; + directory: boolean; + children: ReadonlyArray; + loadAttributes(cb?: any): Readable; + download(options?: DownloadOptions, cb?: any): Readable; +} + +export class Storage { + constructor(options: StorageOptions, callback?: any); + static fromJSON(json: JSON): Storage; + name: string; + key: Buffer; + sid: string; + files: {[id in string]: MutableFile}; + root: MutableFile; + trash: MutableFile; + inbox: MutableFile; + mounts: ReadonlyArray; + upload(options: UploadOptions | string, buffer?: Buffer, cb?: any): Writable; + mkdir(options: MakeDirectoryOptions | string, cb: (err: Error | undefined, file: MutableFile) => void): Readable; + reload(cb: any): Readable; + login(cb: any): Readable; + getAccountInfo(cb: any): AccountInfo; + toJSON(): JSON; +} + +export class MutableFile extends File { + constructor(options: FileOptions | string, storage: Storage); + upload(options: UploadOptions | string, buffer?: Buffer, cb?: any): Writable; + mkdir(options: MakeDirectoryOptions | string, cb?: any): Readable; + importFile(file: File | string, cb: (err: Error | undefined, file: MutableFile) => void): Readable; + link(options: LinkOptions | undefined, cb: (err: Error | undefined, url: string) => void): Readable; + shareFolder(options: LinkOptions | undefined, cb: (err: Error | undefined, url: string) => void): Readable; + delete(permanent: true | undefined, cb: (err: Error | undefined) => void): Readable; + moveTo(target: MutableFile | string, cb: (err: Error | undefined) => void): Readable; + setAttributes(attributes: object, cb: (err: Error | undefined) => void): Readable; + uploadAttribute(type: string | number, opt?: Buffer | Stream, cb?: any): Readable; + rename(newFileName: string, cb: (err: Error | undefined) => void): Readable; + setLabel(label: string, cb: (err: Error | undefined) => void): Readable; + setFavorite(isFavorite: boolean, cb: (err: Error | undefined) => void): Readable; +} + +export default function mega(options: StorageOptions, cb?: any): Storage; diff --git a/types/megajs/megajs-tests.ts b/types/megajs/megajs-tests.ts new file mode 100644 index 0000000000..862373c85a --- /dev/null +++ b/types/megajs/megajs-tests.ts @@ -0,0 +1,9 @@ +import mega from 'megajs'; + +// $ExpectType Storage +mega({email: 'test@test.net', password: '1234'}); + +// tslint:disable-next-line no-duplicate-imports +import { Storage } from 'megajs'; + +const storage = new Storage({email: 'test@test.net', password: '1234'}); diff --git a/types/megajs/tsconfig.json b/types/megajs/tsconfig.json new file mode 100644 index 0000000000..0e6bb53df1 --- /dev/null +++ b/types/megajs/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "megajs-tests.ts" + ] +} diff --git a/types/megajs/tslint.json b/types/megajs/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/megajs/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 255dceba29e0e1984ac6aaeb695a628d8be89934 Mon Sep 17 00:00:00 2001 From: "J.C" Date: Thu, 30 Aug 2018 14:26:49 +0800 Subject: [PATCH 33/59] 1, modify some arguments as optional, and changed argument/return type for onShareAppMessage API. 2, fix test case according API changes. --- types/wegame-api/index.d.ts | 37 ++++++++++++++++++---------- types/wegame-api/wegame-api-tests.ts | 10 +++++--- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/types/wegame-api/index.d.ts b/types/wegame-api/index.d.ts index fcddd82a32..18480ed2ea 100644 --- a/types/wegame-api/index.d.ts +++ b/types/wegame-api/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for wegame 1.1 +// Type definitions for wegame 2.2 // Project: https://developers.weixin.qq.com/minigame/dev/index.html // Definitions by: J.C // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -59,7 +59,7 @@ declare class Canvas { * @param contextType 上下文类型 * @param contextAttributes webgl 上下文属性,仅当 contextType 为 webgl 时有效 */ - getContext(contextType: "2d" | "webgl", contextAttributes: wx.types.RenderingContextConfig): WxRenderingContext | WxWebGLRenderingContext; + getContext(contextType: "2d" | "webgl", contextAttributes?: wx.types.RenderingContextConfig): WxRenderingContext | WxWebGLRenderingContext; /** * 把画布上的绘制内容以一个 data URI 的格式返回 */ @@ -404,7 +404,7 @@ declare class FeedbackButton extends CreatedButton { declare class OpenDataContext { /** - * 开放数据域和主域共享的 sharedCanvas + * 开放数据域和主域共享的 sharedCanvas,注意在开放数据域内时getContext只能使用2d模式 */ canvas: Canvas; /** @@ -1042,7 +1042,7 @@ declare namespace wx { complete?: () => void; } - type FileContentEncoding = "ascii" | "base64" | "binary" | "hex" | "ucs2/ucs-2/utf16le/utf-16le" | "utf-8/utf8" | "latin1"; + type FileContentEncoding = "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf-8" | "utf8" | "latin1"; interface ReadfileParams { filePath: string; @@ -1079,7 +1079,7 @@ declare namespace wx { zipFilePath: string; targetPath: string; success?: () => void; - fail?: () => void; + fail?: (e?: any) => void; complete?: () => void; } @@ -1153,6 +1153,7 @@ declare namespace wx { width: number; height: number; onload: () => void; + onerror: (e?: any) => void; } // --启动参数 @@ -1317,11 +1318,11 @@ declare namespace wx { interface DownfileParams { url: string; + filePath: string; /** * HTTP 请求的 Header,Header 中不能设置 Referer */ - header: { [key: string]: string }; - filePath: string; + header?: { [key: string]: string }; success?: (res: { tempFilePath: string, statusCode: number }) => void; fail?: () => void; complete?: () => void; @@ -1355,7 +1356,7 @@ declare namespace wx { /** * res.data usually can be string or ArrayBuffer */ - success?: (res: { data: any, statusCode: number, header: { [key: string]: string } }) => void; + success?: (res: { data: any, statusCode: number, header?: { [key: string]: string } }) => void; fail?: () => void; complete?: () => void; } @@ -1389,7 +1390,7 @@ declare namespace wx { complete?: () => void; } - type SocketOpenCallback = (res: { header: { [key: string]: string } }) => void; + type SocketOpenCallback = (res: { header?: { [key: string]: string } }) => void; type SocketMessageCallback = (res: { data: string | ArrayBuffer }) => void; type SocketErrorCallback = (res: { errMsg: string }) => void; @@ -1566,7 +1567,7 @@ declare namespace wx { */ imageUrl?: string; /** - * 查询字符串,必须是 key1=val1&key2=val2 的格式。从这条转发消息进入后,可通过 wx.onLaunch() 或 wx.onShow 获取启动参数中的 query。 + * 查询字符串,必须是 key1=val1&key2=val2 的格式。从这条转发消息进入后,可通过 wx.getLaunchOptionsSync() 或 wx.onShow 获取启动参数中的 query。 */ query?: string; } @@ -1802,6 +1803,16 @@ declare namespace wx { // --文件系统 function getFileSystemManager(): FileSystemManager; + /** + * 系统环境变量 + */ + const env: { + /** + * 用户下载数据根目录 + */ + USER_DATA_PATH: string + }; + // --位置 /** * 获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用;当用户点击“显示在聊天顶部”时,此接口可继续调用。 @@ -2208,15 +2219,15 @@ declare namespace wx { /** * 监听用户点击右上角菜单的“转发”按钮时触发的事件 */ - function onShareAppMessage(cb: (data: types.ShareOption) => void): void; + function onShareAppMessage(cb: () => types.ShareOption): void; /** * 取消监听用户点击右上角菜单的“转发”按钮时触发的事件 */ - function offShareAppMessage(cb: (data: types.ShareOption) => void): void; + function offShareAppMessage(cb: () => types.ShareOption): void; /** * 显示当前页面的转发按钮 */ - function showShareMenu(param: { + function showShareMenu(param?: { /** * 是否使用带 shareTicket 的转发 */ diff --git a/types/wegame-api/wegame-api-tests.ts b/types/wegame-api/wegame-api-tests.ts index 88ad8fe1c3..a52f78ec9b 100644 --- a/types/wegame-api/wegame-api-tests.ts +++ b/types/wegame-api/wegame-api-tests.ts @@ -404,10 +404,12 @@ wx.getShareInfo({ } }); wx.hideShareMenu(); -wx.onShareAppMessage(res => { - res.imageUrl != null; - res.query != null; - res.title != null; +wx.onShareAppMessage((): wx.types.ShareOption => { + return { + imageUrl: "test.png", + title: "test title", + query: "__shareQueryStr" + }; }); wx.showShareMenu({ withShareTicket: true From 30b5b642f9f8efeacee0b25ce812b6d4085fdc08 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Wed, 29 Aug 2018 21:11:25 +0300 Subject: [PATCH 34/59] [react-numeric-input] Fix up typing: * No longer inherit from deprecated React.Props * Derive from React.InputHTMLAttributes to avoid duplication * Fix min/max/precision/step props * Fix the type of the "numeric value" state; it can be `null` * Clean out `any`s * Expose the internal state (as used by function props) --- types/react-numeric-input/index.d.ts | 61 +++++++++++-------- .../react-numeric-input-tests.tsx | 12 +++- 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/types/react-numeric-input/index.d.ts b/types/react-numeric-input/index.d.ts index bc28d95825..9706d4f4aa 100644 --- a/types/react-numeric-input/index.d.ts +++ b/types/react-numeric-input/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for react-numeric-input 2.2 // Project: https://github.com/vlad-ignatov/react-numeric-input#readme // Definitions by: Heather Booker +// Aarni Koskela // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -9,38 +10,50 @@ import * as React from 'react'; export = NumericInput; declare namespace NumericInput { - interface NumericInputProps extends React.Props { + type BoundsFunctionProp = number | ((component: NumericInput) => number | undefined); + type Omit = Pick>; // via TS 2.8 manual + interface NumericInputProps extends Omit< + React.InputHTMLAttributes, + 'min' | 'max' | 'step' | 'onChange' | 'defaultValue' | 'onInvalid' | 'style' + > { addLabelText?: string; - className?: string; defaultValue?: number | string; - disabled?: boolean; - format?: ((s: string) => string); - max?: number | ((v: number) => number); - maxLength?: number; - min?: number | ((v: number) => number); - mobile?: boolean | 'auto' | ((this: NumericInput) => any); // TODO: fix `any` - noValidate?: boolean| string; + format?: ((value: number | null) => string); + max?: BoundsFunctionProp; + min?: BoundsFunctionProp; + mobile?: boolean | 'auto' | ((component: NumericInput) => boolean); + noValidate?: boolean | string; onBlur?: React.FocusEventHandler; - onChange?: ((v: number, s: string, i: JSX.Element) => void); + onChange?: ((value: number | null, stringValue: string, input: HTMLInputElement) => void); onFocus?: React.FocusEventHandler; - onInput?: ((...args: any[]) => void); - onInvalid?: ((err: string, v: number, s: string) => void); + onInput?: React.FormEventHandler; + onInvalid?: ((error: string, value: number | null, stringValue: string) => void); onKeyDown?: React.KeyboardEventHandler; - onSelect?: ((...args: any[]) => void); - onValid?: ((v: number, s: string) => void); - parse?: ((s: string) => number | string); - pattern?: string; - precision?: number | ((this: NumericInput) => void); - readOnly?: boolean; - required?: boolean; - size?: number | string; + onSelect?: React.ReactEventHandler; + onValid?: ((value: number | null, stringValue: string) => void); + parse?: ((stringValue: string) => number | null); + precision?: number | ((component: NumericInput) => number | null | undefined); snap?: boolean; - step?: number | object; // TODO: should be `number | ` + step?: number | ((component: NumericInput, direction: string) => number | undefined); strict?: boolean; - style?: { [key: string]: { [key: string]: string } } | boolean; - type?: string; + style?: {[key: string]: React.CSSProperties} | boolean; value?: number | string; } + // Exposed here for the function prop handlers that get the NumericInput instance as a parameter. + // Lifted directly from react-numeric-input@79874ccbe:/src/NumericInput.jsx#L63-L73 + interface NumericInputState { + btnDownActive?: boolean; + btnDownHover?: boolean; + btnUpActive?: boolean; + btnUpHover?: boolean; + selectionEnd?: number | null; + selectionStart?: number | null; + stringValue?: string; + value?: number | null; + } } -declare class NumericInput extends React.Component {} +declare class NumericInput extends React.Component { + static DIRECTION_UP: string; + static DIRECTION_DOWN: string; +} diff --git a/types/react-numeric-input/react-numeric-input-tests.tsx b/types/react-numeric-input/react-numeric-input-tests.tsx index 811b77a4c7..fc55835330 100644 --- a/types/react-numeric-input/react-numeric-input-tests.tsx +++ b/types/react-numeric-input/react-numeric-input-tests.tsx @@ -3,6 +3,16 @@ import NumericInput = require('react-numeric-input'); export class NumericInputTest extends Component { render() { - return(); + return ( + (comp.state.value || 1) + 1} + format={(x) => `EUR ${x}`} + parse={(s) => parseFloat(s.replace(/EUR /, ''))} + step={(comp, dir) => (dir === NumericInput.DIRECTION_UP ? 9 : 1)} + style={{wrap: {color: 'orange'}}} + className="hello" + /> + ); } } From 76f9898c2eba1169daf4bf89e5057c9c8cd70ec1 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 30 Aug 2018 12:22:18 +0300 Subject: [PATCH 35/59] [react-numeric-input] Bump to 2.2.3 features --- types/react-numeric-input/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/react-numeric-input/index.d.ts b/types/react-numeric-input/index.d.ts index 9706d4f4aa..8dc64f3ba3 100644 --- a/types/react-numeric-input/index.d.ts +++ b/types/react-numeric-input/index.d.ts @@ -17,11 +17,13 @@ declare namespace NumericInput { 'min' | 'max' | 'step' | 'onChange' | 'defaultValue' | 'onInvalid' | 'style' > { addLabelText?: string; + componentClass?: string; defaultValue?: number | string; format?: ((value: number | null) => string); max?: BoundsFunctionProp; min?: BoundsFunctionProp; mobile?: boolean | 'auto' | ((component: NumericInput) => boolean); + noStyle?: boolean; noValidate?: boolean | string; onBlur?: React.FocusEventHandler; onChange?: ((value: number | null, stringValue: string, input: HTMLInputElement) => void); From c8d12319ef57ea5c9148b0eaef14e18c1093a619 Mon Sep 17 00:00:00 2001 From: Will Duffy Date: Thu, 30 Aug 2018 07:23:11 -0400 Subject: [PATCH 36/59] [react-beautiful-dnd] Add ignoreContainerClipping to DroppableProps * This prop was added in https://github.com/atlassian/react-beautiful-dnd/pull/148 but was never updated here. --- types/react-beautiful-dnd/index.d.ts | 1 + types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/react-beautiful-dnd/index.d.ts b/types/react-beautiful-dnd/index.d.ts index 780a854751..40a2fb9e73 100644 --- a/types/react-beautiful-dnd/index.d.ts +++ b/types/react-beautiful-dnd/index.d.ts @@ -73,6 +73,7 @@ export interface DroppableStateSnapshot { export interface DroppableProps { droppableId: DroppableId; type?: TypeId; + ignoreContainerClipping?: boolean; isDropDisabled?: boolean; direction?: 'vertical' | 'horizontal'; children(provided: DroppableProvided, snapshot: DroppableStateSnapshot): React.ReactElement; diff --git a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx index 4aed203ea6..bfa5d8b8f5 100644 --- a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx +++ b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx @@ -73,7 +73,7 @@ class App extends React.Component<{}, AppState> { render() { return ( - + {(provided, snapshot) => (
{this.state.items.map((item, index) => ( From 4d97c870182d205981a7d346315d590b1253d606 Mon Sep 17 00:00:00 2001 From: Peter Keuter Date: Thu, 30 Aug 2018 19:30:02 +0200 Subject: [PATCH 37/59] Add sqlanywhere typings --- types/sqlanywhere/index.d.ts | 48 ++++++++++++++++++++++++++ types/sqlanywhere/sqlanywhere-tests.ts | 13 +++++++ types/sqlanywhere/tsconfig.json | 23 ++++++++++++ types/sqlanywhere/tslint.json | 4 +++ 4 files changed, 88 insertions(+) create mode 100644 types/sqlanywhere/index.d.ts create mode 100644 types/sqlanywhere/sqlanywhere-tests.ts create mode 100644 types/sqlanywhere/tsconfig.json create mode 100644 types/sqlanywhere/tslint.json diff --git a/types/sqlanywhere/index.d.ts b/types/sqlanywhere/index.d.ts new file mode 100644 index 0000000000..d56bfb7993 --- /dev/null +++ b/types/sqlanywhere/index.d.ts @@ -0,0 +1,48 @@ +// Type definitions for sqlanywhere 1.0 +// Project: https://github.com/sqlanywhere/node-sqlanywhere +// Definitions by: Peter Keuter +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export function createConnection(): SybaseConnection; + +export interface SybaseConnection { + connect( + params: ConnectionParameters, + cb: (err: Error | undefined) => void + ): void; + close(cb: (err?: Error) => void): void; + disconnect(cb: (err?: Error) => void): void; + connected(): boolean; + exec(query: string, cb: (err: Error | undefined, result: any) => void); + exec( + query: string, + placeholders: any[], + cb: (err: Error | undefined, result: any) => void + ); + prepare( + query: string, + cb: (err: Error | undefined, stmt: Statement) => void + ); + prepare(query: string): Statement; + commit(cb: (err: Error | undefined) => void): void; + rollback(cb: (err: Error | undefined) => void): void; +} + +export interface ConnectionParameters { + Server: string; + UserId: string; + DatabaseFile?: string; + AutoStart?: string; + Password: string; + Host?: string; +} + +export interface Statement { + exec(args: any[], cb: (err: Error | undefined, rows: any[]) => void); + exec(args: any[]): any[]; + getMoreResults(): any[]; + drop(cb: (err: Error | undefined) => void): void; +} +declare const _default: { + createConnection: typeof createConnection; +}; +export default _default; diff --git a/types/sqlanywhere/sqlanywhere-tests.ts b/types/sqlanywhere/sqlanywhere-tests.ts new file mode 100644 index 0000000000..b6151e77aa --- /dev/null +++ b/types/sqlanywhere/sqlanywhere-tests.ts @@ -0,0 +1,13 @@ +import sqlanywhere = require("sqlanywhere"); + +const connection: sqlanywhere.SybaseConnection = sqlanywhere.createConnection(); +connection.connect( + { + Host: "test", + UserId: "Test", + Password: "Test", + Server: "Test" + }, + err => err +); +connection.exec("SELECT * FROM TEST", (err, res) => res); diff --git a/types/sqlanywhere/tsconfig.json b/types/sqlanywhere/tsconfig.json new file mode 100644 index 0000000000..4270f0546c --- /dev/null +++ b/types/sqlanywhere/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitThis": true, + "noImplicitAny": false, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sqlanywhere-tests.ts" + ] +} diff --git a/types/sqlanywhere/tslint.json b/types/sqlanywhere/tslint.json new file mode 100644 index 0000000000..10d875b8db --- /dev/null +++ b/types/sqlanywhere/tslint.json @@ -0,0 +1,4 @@ +{ + "extends": "dtslint/dt.json", + "rules": {} +} From 9b2e22c6009853f941a2f69b3d2d1447cfe9c99d Mon Sep 17 00:00:00 2001 From: Rosana Ruiz Date: Thu, 30 Aug 2018 19:12:14 +0100 Subject: [PATCH 38/59] Rename subtotal => subtotalPrice --- types/shopify-buy/index.d.ts | 4 ++-- types/shopify-buy/shopify-buy-tests.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/shopify-buy/index.d.ts b/types/shopify-buy/index.d.ts index 7140f85515..11f15d9dfd 100644 --- a/types/shopify-buy/index.d.ts +++ b/types/shopify-buy/index.d.ts @@ -310,10 +310,10 @@ declare namespace ShopifyBuy { lineItems: LineItem[]; /** - * Get current subtotal price for all line items. + * Get current subtotal price for all line items, before shipping, taxes, and discounts. * Example: two items have been added to the cart that cost $1.25 then the subtotal will be 2.50 */ - subtotal: string; + subtotalPrice: string; } export interface LineItem extends GraphModel { diff --git a/types/shopify-buy/shopify-buy-tests.ts b/types/shopify-buy/shopify-buy-tests.ts index 0e65990121..2813dc4d5d 100644 --- a/types/shopify-buy/shopify-buy-tests.ts +++ b/types/shopify-buy/shopify-buy-tests.ts @@ -371,7 +371,7 @@ function renderCartItems() { /* Update Total Cart Pricing ============================================================ */ function updateTotalCartPricing() { - $('.cart .pricing').text(formatAsMoney(cart.subtotal)); + $('.cart .pricing').text(formatAsMoney(cart.subtotalPrice)); } /* Format amount as currency From ad66342e3b26726efc83aa21b593cfb4616a94d4 Mon Sep 17 00:00:00 2001 From: Sergey Shandar Date: Thu, 30 Aug 2018 11:18:11 -0700 Subject: [PATCH 39/59] Update index.d.ts --- types/commonmark/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/commonmark/index.d.ts b/types/commonmark/index.d.ts index 01b9541efa..96bb2774c5 100644 --- a/types/commonmark/index.d.ts +++ b/types/commonmark/index.d.ts @@ -64,7 +64,7 @@ export class Node { /** * either Bullet or Ordered (or undefined). */ - listType: 'Bullet' | 'Ordered'; + listType: 'bullet' | 'ordered'; /** * true if list is tight */ From 8d7f8d17f8d5a9d994a65a96781806c40ae94d9b Mon Sep 17 00:00:00 2001 From: Sergey Shandar Date: Thu, 30 Aug 2018 11:28:33 -0700 Subject: [PATCH 40/59] Update index.d.ts --- types/commonmark/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/commonmark/index.d.ts b/types/commonmark/index.d.ts index 96bb2774c5..0f962a00f0 100644 --- a/types/commonmark/index.d.ts +++ b/types/commonmark/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for commonmark.js 0.27 +// Type definitions for commonmark.js 0.28.1 // Project: https://github.com/jgm/commonmark.js // Definitions by: Nico Jansen // Leonard Thieu From 9a48a20253ee353acf3f5bac2d2eea7e9a7d7f4d Mon Sep 17 00:00:00 2001 From: Sergey Shandar Date: Thu, 30 Aug 2018 11:36:48 -0700 Subject: [PATCH 41/59] Update index.d.ts --- types/commonmark/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/commonmark/index.d.ts b/types/commonmark/index.d.ts index 0f962a00f0..aa00420819 100644 --- a/types/commonmark/index.d.ts +++ b/types/commonmark/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for commonmark.js 0.28.1 +// Type definitions for commonmark.js 0.28 // Project: https://github.com/jgm/commonmark.js // Definitions by: Nico Jansen // Leonard Thieu From ad019dc489e4c4d29c35e5fb570bf70777afefda Mon Sep 17 00:00:00 2001 From: Harrison Hunter Date: Thu, 30 Aug 2018 15:22:34 -0400 Subject: [PATCH 42/59] add types for additional methods in browser policy --- types/meteor/browser-policy-common.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/meteor/browser-policy-common.d.ts b/types/meteor/browser-policy-common.d.ts index 4aa3810f45..8926938976 100644 --- a/types/meteor/browser-policy-common.d.ts +++ b/types/meteor/browser-policy-common.d.ts @@ -19,10 +19,13 @@ declare module "meteor/browser-policy-common" { allowStyleOrigin(origin: string): void; allowScriptOrigin(origin: string): void; allowFrameOrigin(origin: string): void; + allowFrameAncestorsOrigin(origin: string): void; allowContentTypeSniffing(): void; allowAllContentOrigin(): void; allowAllContentDataUrl(): void; allowAllContentSameOrigin(): void; + allowConnectOrigin(origin: string): void; + allowObjectOrigin(origin: string): void; disallowAll(): void; disallowInlineStyles(): void; @@ -31,6 +34,7 @@ declare module "meteor/browser-policy-common" { disallowFont(): void; disallowObject(): void; disallowAllContent(): void; + disallowConnect(): void; }; } } From 95f267cba0e6723a5b4c7cc81db027c0fbf11e01 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Thu, 30 Aug 2018 15:19:58 -0500 Subject: [PATCH 43/59] add typings for elementtree package --- types/elementtree/elementtree-tests.ts | 56 ++++++++++++++++ types/elementtree/index.d.ts | 88 ++++++++++++++++++++++++++ types/elementtree/tsconfig.json | 23 +++++++ types/elementtree/tslint.json | 1 + 4 files changed, 168 insertions(+) create mode 100644 types/elementtree/elementtree-tests.ts create mode 100644 types/elementtree/index.d.ts create mode 100644 types/elementtree/tsconfig.json create mode 100644 types/elementtree/tslint.json diff --git a/types/elementtree/elementtree-tests.ts b/types/elementtree/elementtree-tests.ts new file mode 100644 index 0000000000..630a17f6c6 --- /dev/null +++ b/types/elementtree/elementtree-tests.ts @@ -0,0 +1,56 @@ +import * as et from 'elementtree'; + +// Example 1 +// https://github.com/racker/node-elementtree#example-1--creating-an-xml-document + +const XML = et.XML; +const ElementTree = et.ElementTree; +const element = et.Element; +const subElement = et.SubElement; + +const root = element('entry'); +root.set('xmlns', 'http://www.w3.org/2005/Atom'); + +const tenantId = subElement(root, 'TenantId'); +tenantId.text = '12345'; + +const serviceName = subElement(root, 'ServiceName'); +serviceName.text = 'MaaS'; + +const resourceId = subElement(root, 'ResourceID'); +resourceId.text = 'enAAAA'; + +const usageId = subElement(root, 'UsageID'); +usageId.text = '550e8400-e29b-41d4-a716-446655440000'; + +const eventType = subElement(root, 'EventType'); +eventType.text = 'create'; + +const category = subElement(root, 'category'); +category.set('term', 'monitoring.entity.create'); + +const dataCenter = subElement(root, 'DataCenter'); +dataCenter.text = 'global'; + +const region = subElement(root, 'Region'); +region.text = 'global'; + +const startTime = subElement(root, 'StartTime'); +startTime.text = new Date(); + +const resourceName = subElement(root, 'ResourceName'); +resourceName.text = 'entity'; + +const etree1 = new ElementTree(root); +const xml = etree1.write({ xml_declaration: false }); + +// Example 2 +// https://github.com/racker/node-elementtree#example-2--parsing-an-xml-document + +const data = ''; +const etree2 = et.parse(data); + +etree2.findall('./entry/TenantId').length; // 2 +etree2.findtext('./entry/ServiceName'); // MaaS +etree2.findall('./entry/category')[0].get('term'); // monitoring.entity.create +etree2.findall('*/category/[@term="monitoring.entity.update"]').length; // 1 diff --git a/types/elementtree/index.d.ts b/types/elementtree/index.d.ts new file mode 100644 index 0000000000..8019797b4a --- /dev/null +++ b/types/elementtree/index.d.ts @@ -0,0 +1,88 @@ +// Type definitions for elementtree 0.1 +// Project: https://github.com/racker/node-elementtree +// Definitions by: Daniel Imhoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface ElementTreeWriteOptions { + default_namespace?: string; + encoding?: string; // default is 'utf-8' + indent?: number; + method?: 'xml' | 'text'; // default is 'xml' + xml_declaration?: boolean; // on by default +} + +export class ElementTree { + constructor(element: Element); + + getroot(): Element; + _setroot(element: Element): void; + + parse(source: string): Element; + find(path: string): Element | null; + findtext(path: string): ElementText | undefined; + findall(path: string): Element[]; + write(options?: ElementTreeWriteOptions): string; +} + +export interface Attributes { + [key: string]: string | undefined; +} + +export type ElementTag = typeof Comment | typeof CData | typeof ProcessingInstruction | string; + +export type ElementText = { toString(): string; } | string; + +export interface Element { + tag: ElementTag; + attrib: Attributes; + text: ElementText | null; + tail: string | null; + + toString(): string; + makeelement(tag: ElementTag, attrib?: Attributes): Element; + len(): number; + + getItem(index: number): Element | undefined; + setItem(index: number, element: Element): void; + delItem(index: number): void; + getSlice(start: number, stop: number): Element[]; + setSlice(start: number, stop: number, elements: ReadonlyArray): void; + delSlice(start: number, stop: number): void; + + append(element: Element): void; + extend(elements: ReadonlyArray): void; + insert(index: number, element: Element): void; + remove(element: Element): void; + getchildren(): Element[]; + + find(path: string): Element | null; + findtext(path: string): ElementText | undefined; + findall(path: string): Element[]; + + clear(): void; + + get(k: string): string | undefined; + set(k: string, v?: string): string; + keys(): string[]; + items(): Array<[string, string]>; +} + +export class QName { + text: string; + + constructor(text_or_uri: string, tag?: string); + toString(): string; +} + +// special tags +export function CData(text?: ElementText): Element; +export function Comment(text?: ElementText): Element; +export function ProcessingInstruction(target: ElementText, text?: ElementText): Element; + +export function XML(data: string): Element; +export function Element(ElementTag: string, attrib?: Attributes): Element; +export function SubElement(parent: Element, ElementTag: string, attrib?: Attributes): Element; + +export function parse(source: string): ElementTree; +export function register_namespace(prefix: string, uri: string): void; +export function tostring(element: Element, options: ElementTreeWriteOptions): string; diff --git a/types/elementtree/tsconfig.json b/types/elementtree/tsconfig.json new file mode 100644 index 0000000000..9f9991fb4e --- /dev/null +++ b/types/elementtree/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", + "elementtree-tests.ts" + ] +} diff --git a/types/elementtree/tslint.json b/types/elementtree/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/elementtree/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 69416cfbc7af09389605592eadd87294d990a2d4 Mon Sep 17 00:00:00 2001 From: Sergey Shandar Date: Thu, 30 Aug 2018 13:53:58 -0700 Subject: [PATCH 44/59] Update index.d.ts --- types/commonmark/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/commonmark/index.d.ts b/types/commonmark/index.d.ts index aa00420819..96bb2774c5 100644 --- a/types/commonmark/index.d.ts +++ b/types/commonmark/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for commonmark.js 0.28 +// Type definitions for commonmark.js 0.27 // Project: https://github.com/jgm/commonmark.js // Definitions by: Nico Jansen // Leonard Thieu From c0bcf54c454e6c26f6d1b7b86dd05baf55aae03f Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Thu, 30 Aug 2018 16:36:17 -0700 Subject: [PATCH 45/59] adds typings for the 'mali' package --- types/mali/index.d.ts | 77 ++++++++++++++++++++++++++++++++++++++++ types/mali/mali-tests.ts | 16 +++++++++ types/mali/tsconfig.json | 19 ++++++++++ types/mali/tslint.json | 3 ++ 4 files changed, 115 insertions(+) create mode 100644 types/mali/index.d.ts create mode 100644 types/mali/mali-tests.ts create mode 100644 types/mali/tsconfig.json create mode 100644 types/mali/tslint.json diff --git a/types/mali/index.d.ts b/types/mali/index.d.ts new file mode 100644 index 0000000000..1c73b18c75 --- /dev/null +++ b/types/mali/index.d.ts @@ -0,0 +1,77 @@ +// Type definitions for mali 0.9 +// Project: https://github.com/malijs/mali +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +/// + +import { EventEmitter } from 'events'; +import { Stream } from 'stream'; + +declare class Mali extends EventEmitter { + constructor(path: any, name?: string | ReadonlyArray, options?: any); + name: string; + env: string; + ports: ReadonlyArray; // ? not sure which it is + silent: boolean; + + addService(path: any, name: string | ReadonlyArray, options?: any): void; + use(service?: any, name?: any, fns?: any): void; + start(port?: any, creds?: any, options?: any): any; // gnarly type asserting for these functions so Im just gonna let them handle it. + toJSON(): any; + close(): void; + inspect(): any; +} + +declare namespace Mali { + interface Context { + name: string; + fullName: string; + service: string; + package: string; + app: any; // ? app + call: any; + request: Request; + response: Response; + req: any; // ? + res: any; // ? + type: string; + metadata: string; + get(field: string): any; + set(field: any, val?: any): void; // do I need `?:` if its of type `any`? + sendMetadata(md: any): void; + getStatus(field: string): any; + setStatus(field: any, val?: any): void; // ^ + } + + class Request { + constructor(call: any, type: string); + call: any; + type: string; + metadata: any; + req: any; // ? + + getMetadata(): any; + get(field: string): any; + } + + class Response { + constructor(call: any, type: string); + call: any; + type: string; + metadata: any; + status: any; + res: any; // ? + set(field: any, val?: any): void; // is `val?:` necessary when its of type `any`? + get(field: string): any; + getMetadata(): any; + sendMetadata(md?: any): void; + getStatus(field: string): any; + setStatus(field: any, val?: any): void; // ^ same as above + } + + function exec(ctx: Context, handler: any, cb?: any): void; +} + +export = Mali; diff --git a/types/mali/mali-tests.ts b/types/mali/mali-tests.ts new file mode 100644 index 0000000000..d6d33a263f --- /dev/null +++ b/types/mali/mali-tests.ts @@ -0,0 +1,16 @@ +// example from https://github.com/malijs/mali#example + +import Mali = require('mali'); +import path = require('path'); + +const PROTO_PATH = path.resolve(__dirname, '../protos/helloworld.proto'); + +async function sayHello(ctx: Mali.Context) { + ctx.res = { message: 'Hello '.concat(ctx.req.name) }; +} + +const app = new Mali(PROTO_PATH); +// $ExpectType void +app.use({sayHello}); +// $ExpectType any +app.start('127.0.0.1:50051'); diff --git a/types/mali/tsconfig.json b/types/mali/tsconfig.json new file mode 100644 index 0000000000..1a4f86d02c --- /dev/null +++ b/types/mali/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mali-tests.ts" + ] +} diff --git a/types/mali/tslint.json b/types/mali/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/mali/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 1d20fc56d0f87291a8a6b2667db1b0849de57124 Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Fri, 31 Aug 2018 13:58:53 +0800 Subject: [PATCH 46/59] adding lifetimes --- types/weixin-app/index.d.ts | 82 ++++++++++++++++++++-------- types/weixin-app/weixin-app-tests.ts | 25 ++++++++- 2 files changed, 82 insertions(+), 25 deletions(-) diff --git a/types/weixin-app/index.d.ts b/types/weixin-app/index.d.ts index ecdbd1e486..4c331a4f5a 100644 --- a/types/weixin-app/index.d.ts +++ b/types/weixin-app/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for wx-app 1.9 +// Type definitions for wx-app 2.2 // Project: https://mp.weixin.qq.com/debug/wxadoc/dev/api/ // Definitions by: taoqf // AlexStacker @@ -3125,6 +3125,7 @@ declare namespace wx { } type TouchEventType = + | "tap" | "touchstart" | "touchmove" | "touchcancel" @@ -3204,6 +3205,10 @@ declare namespace wx { changedTouches: Touch[]; } + interface TapEvent extends TouchEvent<"tap"> { + // 手指触摸后马上离开 + } + interface TouchStartEvent extends TouchEvent<"touchstart"> { // 手指触摸动作开始 } @@ -3381,6 +3386,45 @@ interface ComponentRelation { /** 关系生命周期函数,当关系脱离页面节点树时触发,触发时机在组件detached生命周期之后 */ unlinked?: (target: Component) => void; } + +/** + * 组件所在页面的生命周期声明对象,目前仅支持页面的show和hide两个生命周期 + */ +interface PageLifetimes { + show(): void; + + hide(): void; +} + +/** + * 组件生命周期声明对象,组件的生命周期:created、attached、ready、moved、detached将收归到lifetimes字段内进行声明, + * 原有声明方式仍旧有效,如同时存在两种声明方式,则lifetimes字段内声明方式优先级最高 + */ +interface Lifetimes { + /** + * 组件生命周期函数,在组件实例进入页面节点树时执行 + * 注意此时不能调用 setData + */ + created(): void; + /** + * 组件生命周期函数,在组件实例进入页面节点树时执行 + */ + attached(): void; + /** + * 组件生命周期函数,在组件布局完成后执行,此时可以获取节点信息 + * 使用 [SelectorQuery](https://mp.weixin.qq.com/debug/wxadoc/dev/api/wxml-nodes-info.html) + */ + ready(): void; + /** + * 组件生命周期函数,在组件实例被移动到节点树另一个位置时执行 + */ + moved(): void; + /** + * 组件生命周期函数,在组件实例被从页面节点树移除时执行 + */ + detached(): void; +} + /** * Component组件参数 */ @@ -3390,58 +3434,48 @@ interface ComponentOptions< Methods = DefaultMethods, Options = object, Props = PropsDefinition -> { +> extends Partial { /** * 组件的对外属性,是属性名到属性设置的映射表 * 属性设置中可包含三个字段: * type 表示属性类型、 value 表示属性初始值、 observer 表示属性值被更改时的响应函数 */ properties?: Props; + /** * 组件的内部数据,和 properties 一同用于组件的模版渲染 */ data?: Data; + /** * 组件的方法,包括事件响应函数和任意的自定义方法 * 关于事件响应函数的使用 * 参见[组件事件](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/custom-component/events.html) */ methods?: Methods; + /** * 一些组件选项,请参见文档其他部分的说明 */ options?: Options; + /** * 类似于mixins和traits的组件间代码复用机制 * 参见 [behaviors](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/custom-component/behaviors.html) */ behaviors?: Array<(ComponentOptions>) | string>; + /** - * 组件生命周期函数,在组件实例进入页面节点树时执行 - * 注意此时不能调用 setData + * 组件生命周期声明对象,组件的生命周期:created、attached、ready、moved、detached将收归到lifetimes字段内进行声明, + * 原有声明方式仍旧有效,如同时存在两种声明方式,则lifetimes字段内声明方式优先级最高 */ - created?( - this: ThisType< - ComponentOptions> - > - ): void; + lifetimes?: Partial; + /** - * 组件生命周期函数,在组件实例进入页面节点树时执行 + * 组件所在页面的生命周期声明对象,目前仅支持页面的show和hide两个生命周期 */ - attached?(): void; - /** - * 组件生命周期函数,在组件布局完成后执行,此时可以获取节点信息 - * 使用 [SelectorQuery](https://mp.weixin.qq.com/debug/wxadoc/dev/api/wxml-nodes-info.html) - */ - ready?(): void; - /** - * 组件生命周期函数,在组件实例被移动到节点树另一个位置时执行 - */ - moved?(): void; - /** - * 组件生命周期函数,在组件实例被从页面节点树移除时执行 - */ - detached?(): void; + pageLifetimes?: Partial; + /** * 组件间关系定义,参见 [组件间关系](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/custom-component/relations.html) */ diff --git a/types/weixin-app/weixin-app-tests.ts b/types/weixin-app/weixin-app-tests.ts index 473e8a290d..f06ad07336 100644 --- a/types/weixin-app/weixin-app-tests.ts +++ b/types/weixin-app/weixin-app-tests.ts @@ -20,7 +20,9 @@ let behavior = Behavior({ }, attached() {}, methods: { - myBehaviorMethod() {} + myBehaviorMethod() { + const s: string = this.data.myBehaviorData; + } } }); @@ -46,6 +48,24 @@ Component({ anotherKey: "value" }, // 私有数据,可用于模版渲染 + lifetimes: { + attached() {}, + + detached() { + this.setData( + { + key: null + }, + () => {} + ); + } + }, + + pageLifetimes: { + show() {}, + hide() {} + }, + // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached() { this.setData( @@ -55,8 +75,11 @@ Component({ () => {} ); }, + moved() {}, + detached() {}, + methods: { readMyDataAndMyProps() { const stringValue1: string = this.data.myProperty; From 6d0e9e718ca7d254a6b2ad1ccb20bde79d7b169d Mon Sep 17 00:00:00 2001 From: Jiayu Liu Date: Fri, 31 Aug 2018 15:02:32 +0800 Subject: [PATCH 47/59] adding options --- types/weixin-app/index.d.ts | 62 +++++++++++++++------------- types/weixin-app/weixin-app-tests.ts | 5 +++ 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/types/weixin-app/index.d.ts b/types/weixin-app/index.d.ts index 4c331a4f5a..9f6fee5a55 100644 --- a/types/weixin-app/index.d.ts +++ b/types/weixin-app/index.d.ts @@ -3327,19 +3327,16 @@ type ExtendedComponent< Instance extends Component, Data, Methods, - Options, Props -> = CombinedInstance & - Component; +> = CombinedInstance & Component; // CombinedInstance models the `this`, i.e. instance type for (user defined) component type CombinedInstance< Instance extends Component, Data, Methods, - Options, Props -> = Methods & Options & Instance; +> = Methods & Instance; type Prop = (() => T) | { new (...args: any[]): T & object }; @@ -3368,11 +3365,10 @@ type ThisTypedComponentOptionsWithRecordProps< V extends Component, Data, Methods, - Options, Props > = object & - ComponentOptions Data), Methods, Options, Props> & - ThisType>>; + ComponentOptions Data), Methods, Props> & + ThisType>>; interface ComponentRelation { /** 目标组件的相对关系,可选的值为 parent 、 child 、 ancestor 、 descendant */ @@ -3432,7 +3428,6 @@ interface ComponentOptions< Instance extends Component, Data = DefaultData, Methods = DefaultMethods, - Options = object, Props = PropsDefinition > extends Partial { /** @@ -3457,7 +3452,30 @@ interface ComponentOptions< /** * 一些组件选项,请参见文档其他部分的说明 */ - options?: Options; + options?: Partial<{ + /** + * 使用外部样式类可以让组件使用指定的组件外样式类,如果希望组件外样式类能够完全影响组件内部, + * 可以将组件构造器中的options.addGlobalClass字段置为true。这个特性从小程序基础库版本 2.2.3 开始支持。 + * + * @version 2.2.3 + */ + addGlobalClass: boolean; + /** + * 在组件的wxml中可以包含 slot 节点,用于承载组件使用者提供的wxml结构。 + * 默认情况下,一个组件的wxml中只能有一个slot。需要使用多slot时,可以在组件js中声明启用。 + */ + multipleSlots: boolean; + }>; + + /** + * 组件接受的外部样式类,参见 外部样式类 + * + * 有时,组件希望接受外部传入的样式类(类似于 view 组件的 hover-class 属性)。 + * 此时可以在 Component 中用 externalClasses 定义段定义若干个外部样式类。这个特性从小程序基础库版本 1.9.90 开始支持。 + * + * @version 1.9.90 + */ + externalClasses?: string[]; /** * 类似于mixins和traits的组件间代码复用机制 @@ -3582,15 +3600,9 @@ interface Component { */ getRelationNodes(relationKey: string): ComponentRelation[]; } -declare function Component( - options?: ThisTypedComponentOptionsWithRecordProps< - Component, - D, - M, - O, - P - > -): ExtendedComponent, D, M, O, P>; +declare function Component( + options?: ThisTypedComponentOptionsWithRecordProps, D, M, P> +): ExtendedComponent, D, M, P>; /** * behaviors 是用于组件间代码共享的特性 * 类似于一些编程语言中的“mixins”或“traits” @@ -3599,15 +3611,9 @@ declare function Component( * 每个组件可以引用多个 behavior * behavior 也可以引用其他 behavior */ -declare function Behavior( - options?: ThisTypedComponentOptionsWithRecordProps< - Component, - D, - M, - O, - P - > -): ExtendedComponent, D, M, O, P>; +declare function Behavior( + options?: ThisTypedComponentOptionsWithRecordProps, D, M, P> +): ExtendedComponent, D, M, P>; // #endregion // #region Page interface PageShareAppMessageOptions { diff --git a/types/weixin-app/weixin-app-tests.ts b/types/weixin-app/weixin-app-tests.ts index f06ad07336..dea53308d0 100644 --- a/types/weixin-app/weixin-app-tests.ts +++ b/types/weixin-app/weixin-app-tests.ts @@ -29,6 +29,11 @@ let behavior = Behavior({ Component({ behaviors: [behavior, "wx://form-field"], + options: { + multipleSlots: false, + addGlobalClass: false + }, + properties: { myProperty: { // 属性名 From 7311120012d52e9a471ae4053d38b046dfdb355a Mon Sep 17 00:00:00 2001 From: David Kevork Date: Fri, 31 Aug 2018 17:16:10 +1000 Subject: [PATCH 48/59] Update react-infinite-scroll-component declaration --- types/react-infinite-scroll-component/index.d.ts | 10 ++++++++-- .../react-infinite-scroll-component-tests.tsx | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/types/react-infinite-scroll-component/index.d.ts b/types/react-infinite-scroll-component/index.d.ts index 768ad1831b..f43fc50e24 100644 --- a/types/react-infinite-scroll-component/index.d.ts +++ b/types/react-infinite-scroll-component/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/ankeetmaini/react-infinite-scroll-component#readme // Definitions by: Stephanie Roy // Bartosz Dotryw +// David Kevork // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -34,7 +35,7 @@ declare namespace InfiniteScroll { /** * You can send a loader component to show while the component waits for the next load of data. e.g.

Loading...

or any fancy loader element */ - loader?: React.ReactNode; + loader: React.ReactNode; /** * This function will be called, it should return the fresh data that you want to show the user @@ -59,7 +60,7 @@ declare namespace InfiniteScroll { /** * Any JSX that you want to show the user, default={

Release to refresh

} */ - releaseToRefreshContent?: boolean; + releaseToRefreshContent?: React.ReactNode; /** * A threshold value defining when InfiniteScroll will call next. Default value is 0.8. It means the next will be called when user comes below 80% of the total height. @@ -84,6 +85,11 @@ declare namespace InfiniteScroll { */ hasChildren?: boolean; + /** + * Children component which will be rendered + */ + children?: React.ReactNode; + /** * Set a scroll y position for the component to render with. */ diff --git a/types/react-infinite-scroll-component/react-infinite-scroll-component-tests.tsx b/types/react-infinite-scroll-component/react-infinite-scroll-component-tests.tsx index 2b5a01d4cc..6eb67569a0 100644 --- a/types/react-infinite-scroll-component/react-infinite-scroll-component-tests.tsx +++ b/types/react-infinite-scroll-component/react-infinite-scroll-component-tests.tsx @@ -10,6 +10,7 @@ const props: InfiniteScroll.InfiniteScrollProps = { dataLength: 4, hasMore: true, endMessage: 'The end.', + loader:

Loading...

, next: () => null, }; From d48b23ee20da9d1cc052a8fc81ab3e7d92b0380f Mon Sep 17 00:00:00 2001 From: Alex Brick Date: Fri, 31 Aug 2018 09:18:09 +0200 Subject: [PATCH 49/59] [express-winston] Adding support for express-winston v3 The interface to Winston has changed (Winston now has a Logger type). --- types/express-winston/express-winston-tests.ts | 6 ++++-- types/express-winston/index.d.ts | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/types/express-winston/express-winston-tests.ts b/types/express-winston/express-winston-tests.ts index 57b93c14f8..f370abdb5d 100644 --- a/types/express-winston/express-winston-tests.ts +++ b/types/express-winston/express-winston-tests.ts @@ -34,9 +34,11 @@ app.use(expressWinston.logger({ ], })); +const logger = winston.createLogger(); + // Logger with minimum options (winstonInstance) app.use(expressWinston.logger({ - winstonInstance: winston, + winstonInstance: logger, })); // Error Logger with all options @@ -62,7 +64,7 @@ app.use(expressWinston.errorLogger({ // Error Logger with min options (winstonInstance) app.use(expressWinston.errorLogger({ - winstonInstance: winston, + winstonInstance: logger, })); expressWinston.bodyBlacklist.push('potato'); diff --git a/types/express-winston/index.d.ts b/types/express-winston/index.d.ts index a691000dd8..462f3df1b3 100644 --- a/types/express-winston/index.d.ts +++ b/types/express-winston/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for express-winston 2.4 +// Type definitions for express-winston 3.0 // Project: https://github.com/bithavoc/express-winston#readme // Definitions by: Alex Brick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -44,7 +44,7 @@ export interface LoggerOptionsWithTransports extends BaseLoggerOptions { } export interface LoggerOptionsWithWinstonInstance extends BaseLoggerOptions { - winstonInstance: typeof winston; + winstonInstance: winston.Logger; } export type LoggerOptions = LoggerOptionsWithTransports | LoggerOptionsWithWinstonInstance; @@ -66,7 +66,7 @@ export interface ErrorLoggerOptionsWithTransports extends BaseErrorLoggerOptions } export interface ErrorLoggerOptionsWithWinstonInstance extends BaseErrorLoggerOptions { - winstonInstance: typeof winston; + winstonInstance: winston.Logger; } export type ErrorLoggerOptions = ErrorLoggerOptionsWithTransports | ErrorLoggerOptionsWithWinstonInstance; From 26c041f9a1a796a48a72768223ed909e20111276 Mon Sep 17 00:00:00 2001 From: Pine Mizune Date: Fri, 31 Aug 2018 16:39:07 +0900 Subject: [PATCH 50/59] Add `customLaunchers` --- types/karma/index.d.ts | 8 ++++++++ types/karma/karma-tests.ts | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/types/karma/index.d.ts b/types/karma/index.d.ts index cc4525566b..4b71c0a723 100644 --- a/types/karma/index.d.ts +++ b/types/karma/index.d.ts @@ -248,6 +248,7 @@ declare namespace karma { * you can specify how many browsers should be running at once at any given point in time. */ concurrency?: number; + customLaunchers?: { [key: string]: CustomLauncher }; /** * @default [] * @description List of files/patterns to exclude from loaded files. @@ -470,6 +471,13 @@ declare namespace karma { */ nocache?: boolean; } + + interface CustomLauncher { + base: string; + browserName?: string; + flags?: string[]; + platform?: string; + } } declare var karma: karma.Karma; diff --git a/types/karma/karma-tests.ts b/types/karma/karma-tests.ts index 6d9b8abd9f..a8adc36f45 100644 --- a/types/karma/karma-tests.ts +++ b/types/karma/karma-tests.ts @@ -106,6 +106,12 @@ module.exports = function(config: karma.Config) { 'Chrome', 'Firefox' ], + customLaunchers: { + ChromiumHeadless_without_security: { + base: 'ChromiumHeadless', + flags: ['--no-sandbox', '--disable-setuid-sandbox'], + }, + }, singleRun: true }); From 1c318c4569967bda540a19eee02ff1ba2ead9d9f Mon Sep 17 00:00:00 2001 From: Meykel Gruel Date: Fri, 31 Aug 2018 10:10:11 +0200 Subject: [PATCH 51/59] * Added `name` & `className` props to Fab * Added `name` prop to Button * Added `readOnly` & `defaultValue` props to Input * Added `defaultChecked`, `name` & `className` props to Radio * Added `name` & `className` props to Checkbox * Added `name` & `className` props to Select * Added `modifier` & `name` props to Switch --- types/react-onsenui/index.d.ts | 20 +++++++++++++++++--- types/react-onsenui/react-onsenui-tests.tsx | 5 +++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/types/react-onsenui/index.d.ts b/types/react-onsenui/index.d.ts index 1b90fb1c50..02f925fb56 100644 --- a/types/react-onsenui/index.d.ts +++ b/types/react-onsenui/index.d.ts @@ -291,12 +291,15 @@ export class Fab extends Component<{ position?: string, disabled?: boolean, onClick?(e?: React.MouseEvent): void, + name?: string, + className?: string }, any> {} export class Button extends Component<{ modifier?: string, disabled?: boolean, ripple?: boolean, + name?: string, className?: string, onClick?(e?: React.MouseEvent): void }, any> {} @@ -304,8 +307,10 @@ export class Button extends Component<{ export class Input extends Component<{ modifier?: string, disabled?: boolean, + readOnly?: boolean, onChange?: (e: React.ChangeEvent) => void, value?: string, + defaultValue?: string, checked?: boolean, placeholder?: string, type?: string, @@ -321,7 +326,10 @@ export class Radio extends Component<{ onChange?(e: Event): void, value?: string, checked?: boolean, - inputId?: string + defaultChecked?: boolean, + inputId?: string, + name?: string, + className?: string }, any> {} export class Checkbox extends Component<{ @@ -330,7 +338,9 @@ export class Checkbox extends Component<{ onChange?(e: Event): void, value?: string, checked?: boolean, - inputId?: string + inputId?: string, + name?: string, + className?: string }, any> {} export class Range extends Component<{ @@ -349,14 +359,18 @@ export class Select extends Component<{ autofocus?: boolean, required?: boolean, form?: string, - size?: string + size?: string, + name?: string, + className?: string }, any> {} export class Switch extends Component<{ + modifier?: string, onChange?(e: SwitchChangeEvent): void, checked?: boolean, disabled?: boolean, inputId?: string, + name?: string, className?: string }, any> {} diff --git a/types/react-onsenui/react-onsenui-tests.tsx b/types/react-onsenui/react-onsenui-tests.tsx index a2c2534914..477359b748 100644 --- a/types/react-onsenui/react-onsenui-tests.tsx +++ b/types/react-onsenui/react-onsenui-tests.tsx @@ -2,7 +2,7 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; import { SplitterSide, Splitter, SplitterContent, - Page, Input, Button, + Page, Input, Button, Radio, } from "react-onsenui"; class AppState { @@ -38,7 +38,8 @@ export class App extends React.Component { Test page - + +