Added typing for abs-svg-path (#43807)

* Implemented abs-svg-path typings

* Fixed abs path test

* Fixed ExpectType
This commit is contained in:
Liam Martens 2020-04-11 05:26:27 +02:00 committed by GitHub
parent 6ec9e84831
commit 539042117c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,2 @@
import abs = require('abs-svg-path');
const absolutized = abs([['M', 10, 10], ['l', 100, 100]]); // $ExpectType AbsAnyCommand[]

43
types/abs-svg-path/index.d.ts vendored Normal file
View File

@ -0,0 +1,43 @@
// Type definitions for abs-svg-path 0.1
// Project: https://github.com/jkroso/abs-svg-path
// Definitions by: Liam Martens <https://github.com/LiamMartens>
// 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;

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }