From 4cb94970a1ea5b07a9f41fb0cba212abcad1d48e Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Tue, 29 May 2018 16:32:03 -0400 Subject: [PATCH] fix: type for async property --- src/index.ts | 10 +++++++--- tsconfig.json | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9ce6653..ed21518 100644 --- a/src/index.ts +++ b/src/index.ts @@ -123,7 +123,12 @@ function lazyAssLogic(condition) { } } -export const lazyAss = function lazyAss() { +interface LazyAss { + (): void; + async: () => void; +} + +export const lazyAss: LazyAss = function lazyAss() { var err = lazyAssLogic.apply(null, arguments); if (err) { throw err; @@ -139,7 +144,6 @@ export const lazyAssync = function lazyAssync() { } }; -// TODO how to add a property to a function? -// lazyAss.async = lazyAssync; +lazyAss.async = lazyAssync; export default lazyAss; diff --git a/tsconfig.json b/tsconfig.json index 68c27cc..bfe83a6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,7 +24,7 @@ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ "strictNullChecks": true, /* Enable strict null checks. */ "strictFunctionTypes": true, /* Enable strict checking of function types. */ - "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + "strictPropertyInitialization": false, /* Enable strict checking of property initialization in classes. */ "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */