Merge pull request #28145 from seangenabe/round-to

Add typings for round-to
This commit is contained in:
Benjamin Lichtman
2018-08-16 21:15:49 -07:00
committed by GitHub
4 changed files with 62 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for round-to 3.0
// Project: https://github.com/sindresorhus/round-to#readme
// Definitions by: Sean Marvi Oliver Genabe <https://github.com/seangenabe>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace roundTo {
/**
* Round the decimals with `Math.ceil`.
* @param input Number to adjust.
* @param precision (Integer) number of decimal places.
*/
function up(input: number, precision: number): number;
/**
* Round the decimals with `Math.floor`.
* @param input Number to adjust.
* @param precision (Integer) number of decimal places.
*/
function down(input: number, precision: number): number;
}
/**
* Round the decimals with `Math.round`.
* @param input Number to adjust.
* @param precision (integer) Number of decimal places.
*/
declare function roundTo(input: number, precision: number): number;
export = roundTo;
+10
View File
@@ -0,0 +1,10 @@
import roundTo = require('round-to');
// $ExpectType number
roundTo(1.234, 2);
// $ExpectType number
roundTo.up(1.234, 2);
// $ExpectType number
roundTo.down(1.234, 2);
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"round-to-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }