From 4b4d2faf265ee7c1625f62c51b2fd5cf6fa6a9af Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 1 Jul 2020 15:33:02 +0800 Subject: [PATCH] Update to TypeScript 3.9 --- bench.ts | 6 +++--- package.json | 13 ++++++++----- source/index.ts | 1 + source/queue.ts | 6 +++--- test/test.ts | 3 ++- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/bench.ts b/bench.ts index ef1acaf..c2d6de8 100644 --- a/bench.ts +++ b/bench.ts @@ -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', { @@ -54,7 +54,7 @@ suite } await queue.onEmpty(); - // @ts-ignore benchmark typings incorrect + // @ts-expect-error benchmark typings incorrect deferred.resolve(); } }) @@ -62,7 +62,7 @@ suite 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({ diff --git a/package.json b/package.json index f787627..75c0c05 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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, @@ -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": { diff --git a/source/index.ts b/source/index.ts index cc039d7..fc3e2f5 100644 --- a/source/index.ts +++ b/source/index.ts @@ -351,6 +351,7 @@ export default class PQueue>): number { + // eslint-disable-next-line unicorn/no-fn-reference-in-iterator return this._queue.filter(options).length; } diff --git a/source/queue.ts b/source/queue.ts index d191838..07dc1ae 100644 --- a/source/queue.ts +++ b/source/queue.ts @@ -2,7 +2,7 @@ export type RunFunction = () => Promise; export interface Queue { size: number; - filter(options: Partial): Element[]; - dequeue(): Element | undefined; - enqueue(run: Element, options?: Partial): void; + filter: (options: Partial) => Element[]; + dequeue: () => Element | undefined; + enqueue: (run: Element, options?: Partial) => void; } diff --git a/test/test.ts b/test/test.ts index 06c2157..55718fd 100644 --- a/test/test.ts +++ b/test/test.ts @@ -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})); }); @@ -296,7 +297,7 @@ test('enforce number in queue.concurrency', t => { t.throws( () => { - // @ts-ignore + // @ts-expect-error (new PQueue()).concurrency = undefined; }, TypeError