diff --git a/types/elo-rank/elo-rank-tests.ts b/types/elo-rank/elo-rank-tests.ts new file mode 100644 index 0000000000..4032d46f0a --- /dev/null +++ b/types/elo-rank/elo-rank-tests.ts @@ -0,0 +1,7 @@ +import EloRank from "elo-rank"; + +const test = new EloRank(); + +test.getKFactor(); // $ExpectType number +test.getExpected(1200, 1500); // $ExpectType number +test.updateRating(test.getExpected(1200, 1500), 1300, 1500); // $ExpectType number diff --git a/types/elo-rank/index.d.ts b/types/elo-rank/index.d.ts new file mode 100644 index 0000000000..489be40fdc --- /dev/null +++ b/types/elo-rank/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for elo-rank 1.0 +// Project: https://github.com/dmamills/elo-rank#readme +// Definitions by: Antonio Pavlinovic +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.7 + +declare class EloRank { + constructor(kFactor?: number); + setKFactor(kFactor: number): void; + getKFactor(): number; + getExpected(a: number, b: number): number; + updateRating(expected: number, actual: number, current: number): number; +} + +export = EloRank; diff --git a/types/elo-rank/tsconfig.json b/types/elo-rank/tsconfig.json new file mode 100644 index 0000000000..21cf1d2f88 --- /dev/null +++ b/types/elo-rank/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "elo-rank-tests.ts" + ] +} diff --git a/types/elo-rank/tslint.json b/types/elo-rank/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/elo-rank/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }