From 1f95827a0ddbffff8a369b7b110c752157eaae98 Mon Sep 17 00:00:00 2001 From: evelijn Date: Sun, 15 Jul 2018 21:31:28 +0200 Subject: [PATCH] Add types for barbellweights module (#27302) * Add types for barbellweights * Add types for barbellweights --- types/barbellweights/barbellweights-tests.ts | 33 ++++++++++++++++++++ types/barbellweights/index.d.ts | 22 +++++++++++++ types/barbellweights/tsconfig.json | 23 ++++++++++++++ types/barbellweights/tslint.json | 1 + 4 files changed, 79 insertions(+) create mode 100644 types/barbellweights/barbellweights-tests.ts create mode 100644 types/barbellweights/index.d.ts create mode 100644 types/barbellweights/tsconfig.json create mode 100644 types/barbellweights/tslint.json diff --git a/types/barbellweights/barbellweights-tests.ts b/types/barbellweights/barbellweights-tests.ts new file mode 100644 index 0000000000..7652728824 --- /dev/null +++ b/types/barbellweights/barbellweights-tests.ts @@ -0,0 +1,33 @@ +import { BarbellWeight } from "barbellweights"; + +let calculator: BarbellWeight; +let results: any; + +calculator = new BarbellWeight(200, "bench press"); +results = calculator.getResults(); + +calculator = new BarbellWeight(500, "deadlift"); +results = calculator.getResults(); + +calculator = new BarbellWeight(400, "squat"); +results = calculator.getResults(); + +calculator = new BarbellWeight(400, "deadlift", { program: "QUARTER" }); +results = calculator.getResults(); + +calculator = new BarbellWeight(400, "deadlift", { bar: 45 }); +results = calculator.getResults(); + +calculator = new BarbellWeight(400, "deadlift", { plates: [45, 10, 5] }); +results = calculator.getResults(); + +calculator = new BarbellWeight(400, "deadlift", { warmup_round_to: 5 }); +results = calculator.getResults(); + +calculator = new BarbellWeight(300, "squat", { + program: "STARTING_STRENGTH", + bar: 45, + plates: [45, 25, 10, 5], + warmup_round_to: 5 +}); +results = calculator.getResults(); diff --git a/types/barbellweights/index.d.ts b/types/barbellweights/index.d.ts new file mode 100644 index 0000000000..069f016f8e --- /dev/null +++ b/types/barbellweights/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for barbellweights 0.4 +// Project: https://github.com/toddhibbs/barbellweight#readme +// Definitions by: evelijn +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface options { + program?: string; + bar?: number; + plates?: number[]; + warmup_round_to?: number; +} + +export class BarbellWeight { + constructor(workingWeight: number, lift: string, options?: options); + getResults(): any; +} + +export namespace BarbellWeight { + namespace BarbellWeight { + function getResults(): void; + } +} diff --git a/types/barbellweights/tsconfig.json b/types/barbellweights/tsconfig.json new file mode 100644 index 0000000000..1acdbe017b --- /dev/null +++ b/types/barbellweights/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "barbellweights-tests.ts" + ] +} diff --git a/types/barbellweights/tslint.json b/types/barbellweights/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/barbellweights/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }