Skip to content

Commit

Permalink
test: 🧪 test for any
Browse files Browse the repository at this point in the history
  • Loading branch information
damusix committed Aug 13, 2024
1 parent d2d29ad commit 9109151
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ import {

const { expect: check } = lab;

type IsAny<T> = (
unknown extends T
? [keyof T] extends [never] ? false : true
: false
);


declare module '../..' {
interface UserCredentials {
someId: string;
Expand All @@ -41,6 +48,8 @@ const genericRoute: ServerRoute = {

check.type<UserCredentials>(request.auth.credentials!.user!);

const y: IsAny<typeof request.auth.credentials> = false;

return 'hello!';
}
}
Expand Down Expand Up @@ -109,6 +118,9 @@ const route: ServerRoute<RequestDecorations> = {
check.type<string>(request.auth.artifacts.some);
check.type<number>(request.auth.artifacts.thing);

const y: IsAny<typeof request.auth.credentials> = false;
const z: IsAny<typeof request.auth.artifacts> = false;

return 'hello!'
}
};
Expand Down Expand Up @@ -171,4 +183,4 @@ server.method('test.add', (a: number, b: number) => a + b, {
segment: 'test-segment',
},
generateKey: (a: number, b: number) => `${a}${b}`
});
});

0 comments on commit 9109151

Please sign in to comment.