From 8a840a2003e0c9727d2807d2eb1896f08df6c7b3 Mon Sep 17 00:00:00 2001 From: Rong Shen Date: Thu, 2 Apr 2020 02:38:48 +0800 Subject: [PATCH] feat: add definition for looper (#43551) --- types/looper/index.d.ts | 13 +++++++++++++ types/looper/looper-tests.ts | 8 ++++++++ types/looper/tsconfig.json | 23 +++++++++++++++++++++++ types/looper/tslint.json | 1 + 4 files changed, 45 insertions(+) create mode 100644 types/looper/index.d.ts create mode 100644 types/looper/looper-tests.ts create mode 100644 types/looper/tsconfig.json create mode 100644 types/looper/tslint.json diff --git a/types/looper/index.d.ts b/types/looper/index.d.ts new file mode 100644 index 0000000000..0c83dd5f25 --- /dev/null +++ b/types/looper/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for looper 4.0 +// Project: https://github.com/dominictarr/looper +// Definitions by: Rong Shen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Loop with callbacks but don't RangeError. + */ + +type Fn = () => any; +declare function looper(fn: Fn): Fn; + +export = looper; diff --git a/types/looper/looper-tests.ts b/types/looper/looper-tests.ts new file mode 100644 index 0000000000..9655d7adf5 --- /dev/null +++ b/types/looper/looper-tests.ts @@ -0,0 +1,8 @@ +import looper = require('looper'); + +let l = 100000; +const next = looper(() => { + if (--l) next(); +}); + +next(); diff --git a/types/looper/tsconfig.json b/types/looper/tsconfig.json new file mode 100644 index 0000000000..de31fb7e8e --- /dev/null +++ b/types/looper/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "looper-tests.ts" + ] +} diff --git a/types/looper/tslint.json b/types/looper/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/looper/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }