Skip to content

Commit

Permalink
chore: pruned some never-used code
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Dec 26, 2022
1 parent f3a71c3 commit 5d942f5
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 74 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/lint-prune.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint - Prune

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint-prune:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: pnpm/action-setup@v2.2.4

- uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-all-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-all-
- name: Install deps (with cache)
run: pnpm install --child-concurrency 3

- name: Run ts-prune
run: pnpm lint-prune
4 changes: 4 additions & 0 deletions .ts-prunerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"error": true,
"ignore": ".d.ts|config.ts|examples|index.ts"
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"test-watch": "cd packages/tests && pnpm test-watch",
"lint": "eslint --ext \".js,.ts,.tsx\" --ignore-path .gitignore .",
"lint-fix": "pnpm lint --fix && manypkg fix",
"lint-prune": "! ts-prune | grep -v \"used in module\"",
"clean": "find . -name node_modules -o -name .turbo -o -name .next -o -name dist -type d -prune | xargs rm -rf",
"codegen:override-prisma": "tsx scripts/addPrismaOverrides.ts",
"codegen": "run-p codegen:*",
Expand Down Expand Up @@ -58,6 +59,7 @@
"rollup-plugin-node-externals": "^5.0.0",
"rollup-plugin-swc3": "^0.8.0",
"rollup-plugin-typescript2": "^0.32.1",
"ts-prune": "^0.10.3",
"tsx": "^3.9.0",
"turbo": "^1.6.1",
"typescript": "^4.8.3"
Expand Down
10 changes: 1 addition & 9 deletions packages/server/src/adapters/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@ import type {
import { AnyRouter } from '../core';
import { TRPCError } from '../error/TRPCError';
import { nodeHTTPRequestHandler } from './node-http';
import {
NodeHTTPCreateContextFnOptions,
NodeHTTPHandlerOptions,
} from './node-http';

export type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<
NextApiRequest,
NextApiResponse
>;
import { NodeHTTPHandlerOptions } from './node-http';

export function createNextApiHandler<TRouter extends AnyRouter>(
opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest, NextApiResponse>,
Expand Down
10 changes: 1 addition & 9 deletions packages/server/src/adapters/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import {
TRPCResponseMessage,
} from '../rpc';
import { CombinedDataTransformer } from '../transformer';
import {
NodeHTTPCreateContextFnOptions,
NodeHTTPCreateContextOption,
} from './node-http';
import { NodeHTTPCreateContextOption } from './node-http';

/* istanbul ignore next */
function assertIsObject(obj: unknown): asserts obj is Record<string, unknown> {
Expand Down Expand Up @@ -105,11 +102,6 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<
process?: NodeJS.Process;
} & NodeHTTPCreateContextOption<TRouter, IncomingMessage, ws>;

export type CreateWSSContextFnOptions = NodeHTTPCreateContextFnOptions<
IncomingMessage,
ws
>;

export function applyWSSHandler<TRouter extends AnyRouter>(
opts: WSSHandlerOptions<TRouter>,
) {
Expand Down
9 changes: 0 additions & 9 deletions packages/server/src/core/internals/prefixObjectKeys.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/server/src/core/internals/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,3 @@ export type PickFirstDefined<TType, TPick> = undefined extends TType
? never
: TPick
: TType;

export type EnsureRecord<TRecord> = TRecord extends Record<string, any>
? TRecord
: Record<string, never>;
7 changes: 0 additions & 7 deletions packages/server/src/core/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,6 @@ export interface Router<TDef extends AnyRouterDef> {
}): TDef['_config']['$types']['errorShape'];
}

/**
* @internal
*/
export type RouterBuildOptions<TConfig extends AnyRootConfig> = Partial<
Pick<AnyRouterDef<TConfig>, 'procedures'>
>;

export type AnyRouter = Router<AnyRouterDef>;

function isRouter(
Expand Down
35 changes: 0 additions & 35 deletions packages/server/src/deprecated/internals/callProcedure.ts

This file was deleted.

4 changes: 4 additions & 0 deletions packages/server/src/deprecated/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type ProcedureRecord<
* @public
* @deprecated
*/
// ts-prune-ignore-next
export type inferProcedureInput<
TProcedure extends Procedure<any, any, any, any, any, any, any>,
> = TProcedure extends Procedure<any, any, any, infer Input, any, any, any>
Expand Down Expand Up @@ -111,6 +112,7 @@ export type inferProcedureOutput<
* @beta
* @deprecated
*/
// ts-prune-ignore-next
export type inferSubscriptionOutput<
TRouter extends AnyRouter,
TPath extends keyof TRouter['_def']['subscriptions'],
Expand Down Expand Up @@ -159,6 +161,7 @@ export type inferRouterContext<TRouter extends AnyRouter> = Parameters<
/**
* @internal
*/
// ts-prune-ignore-next
export type inferRouterMeta<TRouter extends AnyRouter> = TRouter extends Router<
any,
any,
Expand Down Expand Up @@ -191,6 +194,7 @@ export type AnyRouter<TContext extends Record<string, any> = any> = Router<
* @internal
* @deprecated
*/
// ts-prune-ignore-next
export type inferRouterError<TRouter extends AnyRouter> = ReturnType<
TRouter['getErrorShape']
>;
Expand Down
1 change: 0 additions & 1 deletion packages/tests/server/inferenceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export type And<Types extends boolean[]> = Types[number] extends true
export type Eq<Left extends boolean, Right extends boolean> = Left extends true
? Right
: Not<Right>;
export type Xor<Types extends [boolean, boolean]> = Not<Eq<Types[0], Types[1]>>;

const secret = Symbol('secret');
type Secret = typeof secret;
Expand Down
69 changes: 69 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5d942f5

Please sign in to comment.