From 71dee338436b04be499554642ca67b87c300d536 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 25 Sep 2018 17:10:18 +0100 Subject: [PATCH] Add recharts-scale (#29186) * Add recharts-scale * Use path mapping to import * file should end with new line --- types/recharts-scale/index.d.ts | 29 ++++++++++++++++++++ types/recharts-scale/recharts-scale-tests.ts | 9 ++++++ types/recharts-scale/tsconfig.json | 25 +++++++++++++++++ types/recharts-scale/tslint.json | 7 +++++ types/recharts/index.d.ts | 1 + 5 files changed, 71 insertions(+) create mode 100644 types/recharts-scale/index.d.ts create mode 100644 types/recharts-scale/recharts-scale-tests.ts create mode 100644 types/recharts-scale/tsconfig.json create mode 100644 types/recharts-scale/tslint.json diff --git a/types/recharts-scale/index.d.ts b/types/recharts-scale/index.d.ts new file mode 100644 index 0000000000..76a47726b5 --- /dev/null +++ b/types/recharts-scale/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for Recharts 1.0 +// Project: https://github.com/recharts/recharts-scale +// Definitions by: John Reilly +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +/** + * Calculate the ticks of an interval + * @param [minAndMax] min: The minimum value, max: The maximum value + * @param tickCount The count of ticks + * @param allowDecimals Allow the ticks to be decimals or not - defaults to true + */ +export function getTickValues(domain: [number, number], tickCount?: number, allowDecimals?: boolean): number[]; + +/** + * Calculate the ticks of an interval + * @param [minAndMax] min: The minimum value, max: The maximum value + * @param tickCount The count of ticks + * @param allowDecimals Allow the ticks to be decimals or not - defaults to true + */ +export function getNiceTickValues(domain: [number, number], tickCount?: number, allowDecimals?: boolean): number[]; + +/** + * Calculate the ticks of an interval + * @param [minAndMax] min: The minimum value, max: The maximum value + * @param tickCount The count of ticks + * @param allowDecimals Allow the ticks to be decimals or not - defaults to true + */ +export function getTickValuesFixedDomain(domain: [number, number], tickCount?: number, allowDecimals?: boolean): number[]; diff --git a/types/recharts-scale/recharts-scale-tests.ts b/types/recharts-scale/recharts-scale-tests.ts new file mode 100644 index 0000000000..2cbd09edd4 --- /dev/null +++ b/types/recharts-scale/recharts-scale-tests.ts @@ -0,0 +1,9 @@ +import { + getTickValues, + getNiceTickValues, + getTickValuesFixedDomain +} from 'recharts-scale'; + +getTickValues([1, 10], 6, false); +getNiceTickValues([1, 10], 6, false); +getTickValuesFixedDomain([1, 10], 6, false); diff --git a/types/recharts-scale/tsconfig.json b/types/recharts-scale/tsconfig.json new file mode 100644 index 0000000000..154d9079cf --- /dev/null +++ b/types/recharts-scale/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "recharts-scale-tests.ts" + ] +} diff --git a/types/recharts-scale/tslint.json b/types/recharts-scale/tslint.json new file mode 100644 index 0000000000..2a04bed38c --- /dev/null +++ b/types/recharts-scale/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // TODO + "no-any-union": false + } +} diff --git a/types/recharts/index.d.ts b/types/recharts/index.d.ts index 7307da69d2..c334f977d5 100644 --- a/types/recharts/index.d.ts +++ b/types/recharts/index.d.ts @@ -15,6 +15,7 @@ // TypeScript Version: 2.8 import * as React from 'react'; +import { getTickValues, getNiceTickValues, getTickValuesFixedDomain } from 'recharts-scale'; import { CurveFactory } from 'd3-shape'; export type Percentage = string;