Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlup committed Dec 1, 2021
1 parent 51a7221 commit 1c99beb
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expectType } from 'tsd';

import { PerformanceEntry } from 'perf_hooks';
import { expectType, expectError } from 'tsd';
import Fastify, { FastifyPluginCallback, FastifyPluginAsync } from 'fastify';
import Client from '@immobiliarelabs/dats';
import { Sampler } from '@dnlup/doc';
Expand All @@ -22,4 +22,20 @@ fastify.register(plugin).after((err) => {
expectType<(time: [number, number]) => number>(fastify.hrtime2ms);
expectType<Client>(fastify.stats);
expectType<Sampler | undefined>(fastify.doc);

// These should work
const onSend = (name: string, value: PerformanceEntry) =>
console.log(name, value);
let timerified = fastify.timerify('test', function test1() {});
expectType<() => void>(timerified);
fastify.timerify('test', function test2() {}, onSend);
fastify.timerify('test', function test3() {}, {});
fastify.timerify('test', function test4() {}, onSend, {});

// These should not
expectError(fastify.timerify());
expectError(fastify.timerify('test'));
expectError(fastify.timerify('test', {}));
expectError(fastify.timerify('test', function test5() {}, {}, {}));
expectError(fastify.timerify('test', function test6() {}, onSend, onSend));
});

0 comments on commit 1c99beb

Please sign in to comment.