diff --git a/types/round-to/index.d.ts b/types/round-to/index.d.ts new file mode 100644 index 0000000000..73622c5012 --- /dev/null +++ b/types/round-to/index.d.ts @@ -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 +// 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; diff --git a/types/round-to/round-to-tests.ts b/types/round-to/round-to-tests.ts new file mode 100644 index 0000000000..60d4c21538 --- /dev/null +++ b/types/round-to/round-to-tests.ts @@ -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); diff --git a/types/round-to/tsconfig.json b/types/round-to/tsconfig.json new file mode 100644 index 0000000000..633ed48869 --- /dev/null +++ b/types/round-to/tsconfig.json @@ -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" + ] +} diff --git a/types/round-to/tslint.json b/types/round-to/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/round-to/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }