Skip to content

Commit

Permalink
fix: tweak up test config, fix IPromise definition
Browse files Browse the repository at this point in the history
  • Loading branch information
oljekechoro authored and antongolub committed May 17, 2019
1 parent 2ec98c1 commit 098e9e7
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 28 deletions.
5 changes: 2 additions & 3 deletions packages/facade/src/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
},
"typeRoots": ["."]
},
"files": [
"index.d.ts",
"index.ts"
"include": [
"./*"
],
"exclude": [
"node_modules"
Expand Down
20 changes: 9 additions & 11 deletions packages/types/src/main/IPromise.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import * as Bluebird from 'bluebird'

export type IPromise<T> = Bluebird<T> | Promise<T>

export type TPromiseExecutor<TValue = any, TReason = any> = (resolve: (value: TValue) => void, reject: (reason: TReason) => void) => void

export interface IPromiseConstructor<TValue = any, TReason = any> {
new(executor: TPromiseExecutor<TValue>): IPromise<TValue, TReason>
all: (values: Array<IPromise<TValue, TReason>>) => IPromise<TValue[], TReason>
race: (values: Array<IPromise<TValue, TReason>>) => IPromise<TValue, TReason>
reject: (reason?: TReason) => IPromise<TValue, TReason>
resolve: (value?: TValue) => IPromise<TValue, TReason>
}

export interface IPromise<TValue = any, TReason = any> {
then: (onSuccess?: (value: TValue) => any, onReject?: (reason: TReason) => any) => IPromise
catch: (onReject: (reason: TReason) => any) => IPromise
finally?: (onFinally: () => any) => IPromise
new(executor: TPromiseExecutor<TValue>): IPromise<TValue>
all: (values: Array<IPromise<TValue>>) => IPromise<TValue[]>
race: (values: Array<IPromise<TValue>>) => IPromise<TValue>
reject: (reason?: TReason) => IPromise<TValue>
resolve: (value?: TValue) => IPromise<TValue>
}
2 changes: 1 addition & 1 deletion packages/types/src/test/ICloneable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ICloneable } from './index'
import { ICloneable } from './index';

const cloneable: ICloneable<string> = {
clone(): string { return 'clone'; }
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/test/ICurrency.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ICurrency } from './index'
import { ICurrency } from './index';

const brokenCurrency: ICurrency = 123; // $ExpectError
const brokenCurrency2: ICurrency = {}; // $ExpectError
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/test/IEventEmitter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IEventEmitter } from './index'
import { IEventEmitter } from './index';

const brokenEmitter: IEventEmitter = { // $ExpectError
on(event: string, handler: (...args: any[]) => void) { handler(event); }
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/test/ILogger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ILoggerMethod, ILogger, TLogLevel } from './index'
import { ILoggerMethod, ILogger, TLogLevel } from './index';

const brokenLogLevel: TLogLevel = 'info'; // $ExpectError
const traceLogLevel: TLogLevel = 5e3;
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/test/IMoney.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IMoney } from './index'
import { IMoney } from './index';

const brokenMoney: IMoney = {
value: 123,
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/test/IPromise.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IPromise, IPromiseConstructor, BluebirdPromise } from './index'
import { IPromise, IPromiseConstructor, BluebirdPromise } from './index';

const executor = (resolve: (value: number) => void, reject: (value: number) => void) => {
const value = Math.random();
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/test/IStorage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IStorage } from './index'
import { IStorage } from './index';

const storage: IStorage = {
get: (key: string): any => key,
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/test/IStringMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IStringMap } from './index'
import { IStringMap } from './index';

// IStringMap
const map: IStringMap = {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/test/IUtilEach.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TUtilEach, lodashEach, underscoreEach } from './index'
import { TUtilEach, lodashEach, underscoreEach } from './index';

const brokenUtilEach: TUtilEach = (collection: object, handler: (value: string, key: boolean, collection: object) => void) => { handler || collection; }; // $ExpectError
const utilEach: TUtilEach = (collection: object, handler: (value: string, key: number, collection: object) => void): object => {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/test/IUtilGet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TUtilGet, lodashGet } from './index'
import { TUtilGet, lodashGet } from './index';

const brokenUtilGet: TUtilGet = (obj: object, path: any[], defaultValue?: any) => { obj || path || defaultValue; }; // $ExpectError
const utilGet: TUtilGet = (obj: object, path: Array<string | number> | string, defaultValue?: any) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/test/IUtilMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TUtilMap, lodashMap, underscoreMap } from './index'
import { TUtilMap, lodashMap, underscoreMap } from './index';

const brokenUtilMap: TUtilMap = (collection: object, handler: (value: string, key: boolean, collection: object) => object): any[] => [handler(JSON.stringify(collection), false, collection)]; // $ExpectError
const utilMap: TUtilMap = (collection: object, handler: (value: string, key: string, collection: object) => object): any[] => [handler(JSON.stringify(collection), 'key', collection)];
Expand Down
5 changes: 2 additions & 3 deletions packages/types/src/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
},
"typeRoots": ["."]
},
"files": [
"index.d.ts",
"index.ts"
"include": [
"./*"
],
"exclude": [
"node_modules"
Expand Down

0 comments on commit 098e9e7

Please sign in to comment.