Skip to content

Commit

Permalink
Update to TypeScript 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 1, 2020
1 parent b4f2158 commit 4b4d2fa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PQueue from './source';
const suite = new Benchmark.Suite();

// Benchmark typings aren't up to date, let's help out manually
type Resolvable = Deferred & {resolve(): void};
type Resolvable = Deferred & {resolve: () => void};

suite
.add('baseline', {
Expand Down Expand Up @@ -54,15 +54,15 @@ suite
}

await queue.onEmpty();
// @ts-ignore benchmark typings incorrect
// @ts-expect-error benchmark typings incorrect
deferred.resolve();
}
})
.on('cycle', (event: Event) => {
console.log(String(event.target));
})
.on('complete', function () {
// @ts-ignore benchmark typings incorrect
// @ts-expect-error benchmark typings incorrect
console.log(`Fastest is ${(this as Benchmark.Suite).filter('fastest').map('name') as string}`);
})
.run({
Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"p-timeout": "^3.1.0"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^0.6.0",
"@sindresorhus/tsconfig": "^0.7.0",
"@types/benchmark": "^1.0.31",
"@types/node": "^12.12.7",
"@types/node": "^14.0.14",
"ava": "^2.0.0",
"benchmark": "^2.1.4",
"codecov": "^3.3.0",
Expand All @@ -59,8 +59,8 @@
"random-int": "^2.0.0",
"time-span": "^4.0.0",
"ts-node": "^8.3.0",
"typescript": "3.8.3",
"xo": "^0.28.1"
"typescript": "^3.9.5",
"xo": "^0.32.0"
},
"ava": {
"babel": false,
Expand All @@ -79,7 +79,10 @@
"rules": {
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"node/no-unsupported-features/es-syntax": "off"
"node/no-unsupported-features/es-syntax": "off",
"@typescript-eslint/no-floating-promises": "off",
"import/no-named-default": "off",
"@typescript-eslint/no-invalid-void-type": "off"
}
},
"nyc": {
Expand Down
1 change: 1 addition & 0 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
For example, this can be used to find the number of items remaining in the queue with a specific priority level.
*/
sizeBy(options: Readonly<Partial<EnqueueOptionsType>>): number {
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
return this._queue.filter(options).length;
}

Expand Down
6 changes: 3 additions & 3 deletions source/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export type RunFunction = () => Promise<unknown>;

export interface Queue<Element, Options> {
size: number;
filter(options: Partial<Options>): Element[];
dequeue(): Element | undefined;
enqueue(run: Element, options?: Partial<Options>): void;
filter: (options: Partial<Options>) => Element[];
dequeue: () => Element | undefined;
enqueue: (run: Element, options?: Partial<Options>) => void;
}
3 changes: 2 additions & 1 deletion test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test('.add() - concurrency: 1', async t => {
return value;
});

// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
t.deepEqual(await Promise.all(input.map(mapper)), [10, 20, 30]);
t.true(inRange(end(), {start: 590, end: 650}));
});
Expand Down Expand Up @@ -296,7 +297,7 @@ test('enforce number in queue.concurrency', t => {

t.throws(
() => {
// @ts-ignore
// @ts-expect-error
(new PQueue()).concurrency = undefined;
},
TypeError
Expand Down

0 comments on commit 4b4d2fa

Please sign in to comment.