From 539042117cd697da07daf93092bdf16bc14922d8 Mon Sep 17 00:00:00 2001 From: Liam Martens Date: Sat, 11 Apr 2020 05:26:27 +0200 Subject: [PATCH] Added typing for abs-svg-path (#43807) * Implemented abs-svg-path typings * Fixed abs path test * Fixed ExpectType --- types/abs-svg-path/abs-svg-path-tests.ts | 2 ++ types/abs-svg-path/index.d.ts | 43 ++++++++++++++++++++++++ types/abs-svg-path/tsconfig.json | 23 +++++++++++++ types/abs-svg-path/tslint.json | 1 + 4 files changed, 69 insertions(+) create mode 100644 types/abs-svg-path/abs-svg-path-tests.ts create mode 100644 types/abs-svg-path/index.d.ts create mode 100644 types/abs-svg-path/tsconfig.json create mode 100644 types/abs-svg-path/tslint.json diff --git a/types/abs-svg-path/abs-svg-path-tests.ts b/types/abs-svg-path/abs-svg-path-tests.ts new file mode 100644 index 0000000000..5a9b9ebca5 --- /dev/null +++ b/types/abs-svg-path/abs-svg-path-tests.ts @@ -0,0 +1,2 @@ +import abs = require('abs-svg-path'); +const absolutized = abs([['M', 10, 10], ['l', 100, 100]]); // $ExpectType AbsAnyCommand[] diff --git a/types/abs-svg-path/index.d.ts b/types/abs-svg-path/index.d.ts new file mode 100644 index 0000000000..a842f70748 --- /dev/null +++ b/types/abs-svg-path/index.d.ts @@ -0,0 +1,43 @@ +// Type definitions for abs-svg-path 0.1 +// Project: https://github.com/jkroso/abs-svg-path +// Definitions by: Liam Martens +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type RelMoveCommand = ['m', number, number]; +type AbsMoveCommand = ['M', number, number]; +type MoveCommand = RelMoveCommand | AbsMoveCommand; +type RelLineCommand = ['l', number, number]; +type AbsLineCommand = ['L', number, number]; +type LineCommand = RelLineCommand | AbsLineCommand; +type RelHorizontalCommand = ['h', number]; +type AbsHorizontalCommand = ['H', number]; +type HorizontalCommand = RelHorizontalCommand | AbsHorizontalCommand; +type RelVerticalCommand = ['v', number]; +type AbsVerticalCommand = ['V', number]; +type VerticalCommand = RelVerticalCommand | AbsVerticalCommand; +type RelClosePathCommand = ['z']; +type AbsClosePathCommand = ['Z']; +type ClosePathCommand = RelClosePathCommand | AbsClosePathCommand; +type RelBezierCurveCommand = ['c', number, number, number, number, number, number]; +type AbsBezierCurveCommand = ['C', number, number, number, number, number, number]; +type BezierCurveCommand = RelBezierCurveCommand | AbsBezierCurveCommand; +type RelFollowingBezierCurveCommand = ['s', number, number, number, number]; +type AbsFollowingBezierCurveCommand = ['S', number, number, number, number]; +type FollowingBezierCurveCommand = RelFollowingBezierCurveCommand | AbsFollowingBezierCurveCommand; +type RelQuadraticCurveCommand = ['q', number, number, number, number]; +type AbsQuadraticCurveCommand = ['Q', number, number, number, number]; +type QuadraticCurveCommand = RelQuadraticCurveCommand | AbsQuadraticCurveCommand; +type RelFollowingQuadraticCurveCommand = ['t', number, number]; +type AbsFollowingQuadraticCurveCommand = ['T', number, number]; +type FollowingQuadraticCurveCommand = RelFollowingQuadraticCurveCommand | AbsFollowingQuadraticCurveCommand; +type RelArcCommand = ['a', number, number, number, number, number, number, number]; +type AbsArcCommand = ['A', number, number, number, number, number, number, number]; +type ArcCommand = RelArcCommand | AbsArcCommand; +type AnyCommand = MoveCommand | LineCommand | HorizontalCommand | VerticalCommand | + ClosePathCommand | BezierCurveCommand | FollowingBezierCurveCommand | + QuadraticCurveCommand | FollowingQuadraticCurveCommand | ArcCommand; +type AbsAnyCommand = AbsMoveCommand | AbsLineCommand | AbsHorizontalCommand | AbsVerticalCommand | + AbsClosePathCommand | AbsBezierCurveCommand | AbsFollowingBezierCurveCommand | + AbsQuadraticCurveCommand | AbsFollowingQuadraticCurveCommand | AbsArcCommand; +declare function absolutize(path: AnyCommand[]): AbsAnyCommand[]; +export = absolutize; diff --git a/types/abs-svg-path/tsconfig.json b/types/abs-svg-path/tsconfig.json new file mode 100644 index 0000000000..7247dffcd9 --- /dev/null +++ b/types/abs-svg-path/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "abs-svg-path-tests.ts" + ] +} diff --git a/types/abs-svg-path/tslint.json b/types/abs-svg-path/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/abs-svg-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }