diff --git a/types/d3-interpolate-path/d3-interpolate-path-tests.ts b/types/d3-interpolate-path/d3-interpolate-path-tests.ts new file mode 100644 index 0000000000..f728cae7d8 --- /dev/null +++ b/types/d3-interpolate-path/d3-interpolate-path-tests.ts @@ -0,0 +1,14 @@ +import { interpolatePath } from 'd3-interpolate-path'; + +// $ExpectType (t: number) => string +const interpolate = interpolatePath('M0,0 L10,10', 'M10,10 L20,20 L30,30'); + +// $ExpectType string +interpolate(0.6); + +// $ExpectType string +interpolatePath( + 'M0,0 L10,10', + 'M10,10 L20,20 L30,30', + (a, b) => a.x === b.x && b.y === 30 && a.type === 'L' +)(0.3); diff --git a/types/d3-interpolate-path/index.d.ts b/types/d3-interpolate-path/index.d.ts new file mode 100644 index 0000000000..3633280117 --- /dev/null +++ b/types/d3-interpolate-path/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for d3-interpolate-path 2.0 +// Project: https://github.com/pbeshai/d3-interpolate-path +// Definitions by: Paweł Dąbrowski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface PathCommandObject { + type: string; + x: number; + y: number; +} + +export function interpolatePath( + a: string, + b: string, + excludeSegment?: (a: PathCommandObject, b: PathCommandObject) => boolean +): (t: number) => string; diff --git a/types/d3-interpolate-path/tsconfig.json b/types/d3-interpolate-path/tsconfig.json new file mode 100644 index 0000000000..d44db50576 --- /dev/null +++ b/types/d3-interpolate-path/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", + "d3-interpolate-path-tests.ts" + ] +} diff --git a/types/d3-interpolate-path/tslint.json b/types/d3-interpolate-path/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/d3-interpolate-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }