Skip to content

Commit

Permalink
updating typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
lostfields committed Feb 6, 2020
1 parent d56cae7 commit 09a4f9e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 31 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"benchmark": "^2.1.4",
"istanbul": "^0.4.4",
"mocha": "^4.1.0",
"ts-node": "^4.1.0",
"typescript": "~2.9.1"
"ts-node": "^8.6.2",
"typescript": "^3.7.5"
}
}
25 changes: 0 additions & 25 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
// instead of having "lib: ["esnext.asynciterable"] in tsconfig.json
declare global {
interface SymbolConstructor {
/**
* A method that returns the default async iterator for an object. Called by the semantics of
* the for-await-of statement.
*/
readonly asyncIterator: symbol;
}

interface AsyncIterator<T> {
next(value?: any): Promise<IteratorResult<T>>;
return?(value?: any): Promise<IteratorResult<T>>;
throw?(e?: any): Promise<IteratorResult<T>>;
}

interface AsyncIterable<T> {
[Symbol.asyncIterator](): AsyncIterator<T>;
}

interface AsyncIterableIterator<T> extends AsyncIterator<T> {
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
}
}

if(!Symbol.asyncIterator)
(Symbol as any).asyncIterator = Symbol.asyncIterator || "__@@asyncIterator__";

Expand Down
8 changes: 4 additions & 4 deletions src/repository/db/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export abstract class Query<TEntity> implements PromiseLike<IRecordSet<TEntity>>
*/
protected abstract executeQuery(): Promise<IRecordSet<TEntity>>

private execute<U>(onFulfilled?: (value: IRecordSet<TEntity>) => U | PromiseLike<U>, onRejected?: (error: Error) => U | PromiseLike<U>): Promise<U> {
private execute<U, V>(onFulfilled?: (value: IRecordSet<TEntity>) => U | PromiseLike<U>, onRejected?: (error: Error) => V | PromiseLike<V>): Promise<U | V> {
var stamped = Date.now();

if (!this._promise) {
Expand All @@ -110,12 +110,12 @@ export abstract class Query<TEntity> implements PromiseLike<IRecordSet<TEntity>>
.then(onFulfilled, onRejected);
}

public then<U>(onFulfilled?: (value: IRecordSet<TEntity>) => U | PromiseLike<U>, onRejected?: (error: Error) => U | PromiseLike<U>): Promise<U> {
return this.execute<U>(onFulfilled, onRejected);
public then<U, V>(onFulfilled?: (value: IRecordSet<TEntity>) => U | PromiseLike<U>, onRejected?: (error: Error) => V | PromiseLike<V>): Promise<U | V> {
return this.execute<U, V>(onFulfilled, onRejected);
}

public catch<U>(onRejected?: (error: Error) => U | PromiseLike<U>): Promise<U> {
return this.execute<U>(undefined, onRejected);
return this.execute<never, U>(undefined, onRejected);
}
}

Expand Down
5 changes: 5 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
"compileOnSave": true,
"compilerOptions": {
"target": "ES2017",
"lib": [
"es2018",
"es2018.asynciterable"
],
"downlevelIteration": true,
//"types": ["node", "mocha"],
"module": "commonjs",
"skipLibCheck": true,
"declaration": true,
"newLine": "LF",
//"noImplicitAny": true,
Expand Down

0 comments on commit 09a4f9e

Please sign in to comment.