d3-polygon strict null check (#25538)

* d3-polygon strict null check

* Update tests
This commit is contained in:
denisname
2018-05-07 09:19:12 -07:00
committed by Andy
parent e8849415f2
commit 021d2ad272
4 changed files with 8 additions and 12 deletions
+2 -2
View File
@@ -17,7 +17,7 @@ let containsFlag: boolean;
let point: [number, number] = [15, 15];
const polygon: Array<[number, number]> = [[10, 10], [20, 20], [10, 30]];
const pointArray: Array<[number, number]> = [[10, 10], [20, 20], [10, 30], [15, 15]];
let hull: Array<[number, number]>;
let hullOrNothing: Array<[number, number]> | null;
// -----------------------------------------------------------------------------
// Tests
@@ -27,7 +27,7 @@ num = d3Polygon.polygonArea(polygon);
point = d3Polygon.polygonCentroid(polygon);
hull = d3Polygon.polygonHull(pointArray);
hullOrNothing = d3Polygon.polygonHull(pointArray);
containsFlag = d3Polygon.polygonContains(polygon, point);
+4 -4
View File
@@ -3,11 +3,11 @@
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 1.0.1
// Last module patch version validated against: 1.0.3
/**
* Returns the signed area of the specified polygon. If the vertices of the polygon are in counterclockwise order (
* assuming a coordinate system where the origin ⟨0,0⟩ is in the top-left corner), the returned area is positive;
* Returns the signed area of the specified polygon. If the vertices of the polygon are in counterclockwise order
* (assuming a coordinate system where the origin <0,0> is in the top-left corner), the returned area is positive;
* otherwise it is negative, or zero.
*
* @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
@@ -34,7 +34,7 @@ export function polygonHull(points: Array<[number, number]>): Array<[number, num
* Returns true if and only if the specified point is inside the specified polygon.
*
* @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
* @param point Coordinates of point <x, y>
* @param point Coordinates of point <x, y>.
*/
export function polygonContains(polygon: Array<[number, number]>, point: [number, number]): boolean;
+1 -1
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
+1 -5
View File
@@ -1,7 +1,3 @@
{
"extends": "dtslint/dt.json",
"rules": {
"unified-signatures": false,
"callable-types": false
}
"extends": "dtslint/dt.json"
}