From 36aad9bdab3961b48d83f5811240a6580854d370 Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 29 Jan 2021 18:03:21 -0600 Subject: [PATCH] Move global express args definition This way tests that import the http utilities but not the routes won't error due to missing types. --- src/node/http.ts | 13 ++++++++++++- src/node/routes/index.ts | 10 ---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/node/http.ts b/src/node/http.ts index 18fee9f84..eb8c91f94 100644 --- a/src/node/http.ts +++ b/src/node/http.ts @@ -5,10 +5,21 @@ import qs from "qs" import safeCompare from "safe-compare" import { HttpCode, HttpError } from "../common/http" import { normalize, Options } from "../common/util" -import { AuthType } from "./cli" +import { AuthType, DefaultedArgs } from "./cli" import { commit, rootPath } from "./constants" +import { Heart } from "./heart" import { hash } from "./util" +declare global { + // eslint-disable-next-line @typescript-eslint/no-namespace + namespace Express { + export interface Request { + args: DefaultedArgs + heart: Heart + } + } +} + /** * Replace common variable strings in HTML templates. */ diff --git a/src/node/routes/index.ts b/src/node/routes/index.ts index 5a84ff6ec..41c07a09a 100644 --- a/src/node/routes/index.ts +++ b/src/node/routes/index.ts @@ -26,16 +26,6 @@ import * as _static from "./static" import * as update from "./update" import * as vscode from "./vscode" -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace Express { - export interface Request { - args: DefaultedArgs - heart: Heart - } - } -} - /** * Register all routes and middleware. */