From 0e62835aeacfe8262d1d985a8bfc8c45a1c617c1 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 1 Jan 2019 23:32:00 -0500 Subject: [PATCH 1/4] Add types for raf --- types/raf/index.d.ts | 12 ++++++++++++ types/raf/raf-tests.ts | 11 +++++++++++ types/raf/tsconfig.json | 23 +++++++++++++++++++++++ types/raf/tslint.json | 3 +++ 4 files changed, 49 insertions(+) create mode 100644 types/raf/index.d.ts create mode 100644 types/raf/raf-tests.ts create mode 100644 types/raf/tsconfig.json create mode 100644 types/raf/tslint.json diff --git a/types/raf/index.d.ts b/types/raf/index.d.ts new file mode 100644 index 0000000000..ef7d214811 --- /dev/null +++ b/types/raf/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for raf 3.4.0 +// Project: https://github.com/chrisdickinson/raf#readme +// Definitions by: Ben Lorantfy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare const raf: { + (callback: (timestamp: number) => void): number; + cancel: (handle: number) => void; + polyfill: (globalObject?: any) => void; +} + +export default raf; diff --git a/types/raf/raf-tests.ts b/types/raf/raf-tests.ts new file mode 100644 index 0000000000..d57019913d --- /dev/null +++ b/types/raf/raf-tests.ts @@ -0,0 +1,11 @@ +import raf from "raf"; + +const handle = raf((timestamp) => { + timestamp; // $ExpectType number +}); + +handle; // $ExpectType number + +raf.cancel(handle); +raf.polyfill(); +raf.polyfill({}); diff --git a/types/raf/tsconfig.json b/types/raf/tsconfig.json new file mode 100644 index 0000000000..16b1eada34 --- /dev/null +++ b/types/raf/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", + "raf-tests.ts" + ] +} diff --git a/types/raf/tslint.json b/types/raf/tslint.json new file mode 100644 index 0000000000..a0051c9352 --- /dev/null +++ b/types/raf/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From ae1b82aa9e12ac047ffce1c4672b2c33ac9ecc9e Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 1 Jan 2019 23:39:02 -0500 Subject: [PATCH 2/4] fix tests --- types/raf/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/raf/index.d.ts b/types/raf/index.d.ts index ef7d214811..1cab1a2fc8 100644 --- a/types/raf/index.d.ts +++ b/types/raf/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for raf 3.4.0 +// Type definitions for raf 3.4 // Project: https://github.com/chrisdickinson/raf#readme // Definitions by: Ben Lorantfy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,6 +7,6 @@ declare const raf: { (callback: (timestamp: number) => void): number; cancel: (handle: number) => void; polyfill: (globalObject?: any) => void; -} +}; export default raf; From 1f023ca641b7e876e3f7ebcd0e623f3561f94f53 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 2 Jan 2019 19:57:52 -0500 Subject: [PATCH 3/4] change default export to export = --- types/raf/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/raf/index.d.ts b/types/raf/index.d.ts index 1cab1a2fc8..e954bc5540 100644 --- a/types/raf/index.d.ts +++ b/types/raf/index.d.ts @@ -7,6 +7,6 @@ declare const raf: { (callback: (timestamp: number) => void): number; cancel: (handle: number) => void; polyfill: (globalObject?: any) => void; -}; +} -export default raf; +export = raf; From 4ff739328c9acc3bbdf941cd3e38609350eecebe Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 2 Jan 2019 21:04:11 -0500 Subject: [PATCH 4/4] fix tests --- types/raf/index.d.ts | 2 +- types/raf/raf-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/raf/index.d.ts b/types/raf/index.d.ts index e954bc5540..d54b1c6e6c 100644 --- a/types/raf/index.d.ts +++ b/types/raf/index.d.ts @@ -7,6 +7,6 @@ declare const raf: { (callback: (timestamp: number) => void): number; cancel: (handle: number) => void; polyfill: (globalObject?: any) => void; -} +}; export = raf; diff --git a/types/raf/raf-tests.ts b/types/raf/raf-tests.ts index d57019913d..c3da3cbd01 100644 --- a/types/raf/raf-tests.ts +++ b/types/raf/raf-tests.ts @@ -1,4 +1,4 @@ -import raf from "raf"; +import * as raf from "raf"; const handle = raf((timestamp) => { timestamp; // $ExpectType number