Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
add some typescript tests (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
KATT authored Jan 20, 2022
1 parent ab5d008 commit b3e2372
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test
on: [push]
jobs:
test:
name: Build and test on Node ${{ matrix.node }} and ${{ matrix.os }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['14.x', '16.x']
os: [ubuntu-latest]

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1

- name: Test
run: yarn tsc --noEmit
4 changes: 4 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ async function main() {
const greeting = await client.query(queries.greeting, { hello: 'world' });
// you can CMD+click `post.all` below to get to the definition
const posts = await client.query(queries['post.all']);

console.log({ greeting, posts });
}

{
// we can also use string based path if we prefer that
// (but then you can't click your way to the backend)
const greeting = await client.query('greeting', { hello: 'string' });
const posts = await client.query('post.all');

console.log({ greeting, posts });
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/trpc/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function createClient<TRouter extends ProceduresByType<any>>() {
path: TProcedure,
...args: inferProcedureArgs<TProcedure>
): Promise<inferProcedure<TProcedure>['result']>;
function query(...args: any[]): any {
function query(..._args: any[]): any {
throw new Error('Unimplemented');
}
function mutation<
Expand All @@ -37,7 +37,7 @@ export function createClient<TRouter extends ProceduresByType<any>>() {
path: TProcedure,
...args: inferProcedureArgs<TProcedure>
): Promise<inferProcedure<TProcedure>['result']>;
function mutation(...args: any[]): any {
function mutation(..._args: any[]): any {
throw new Error('Unimplemented');
}

Expand Down
2 changes: 1 addition & 1 deletion src/trpc/server/procedure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function pipedResolver<TContext>() {
MW2Params,
ExcludeMiddlewareResult<TResult | MW1Result | MW2Result>
>;
function middlewares(...args: any): any {
function middlewares(..._args: any): any {
throw new Error('Unimplemented');
}

Expand Down

0 comments on commit b3e2372

Please sign in to comment.