From 096c81aef90dd9de3d4899229bf038d2f752a83b Mon Sep 17 00:00:00 2001 From: Fabian Meyer <3982806+meyfa@users.noreply.github.com> Date: Sat, 14 Dec 2024 12:30:22 +0100 Subject: [PATCH] feat: Enable TS option verbatimModuleSyntax (#471) --- src/cache.ts | 4 ++-- src/controllers/canteens-controller.ts | 2 +- src/controllers/legend-controller.ts | 2 +- src/controllers/plans-controller.ts | 4 ++-- src/fixup.ts | 4 ++-- src/http-server.ts | 4 ++-- src/job.ts | 8 ++++---- src/response.ts | 4 ++-- src/routes/canteens.ts | 2 +- src/routes/default.ts | 2 +- src/routes/meta/index.ts | 2 +- src/routes/meta/legend.ts | 2 +- src/routes/plans.ts | 6 +++--- src/server.ts | 2 +- src/util/date-format.ts | 2 +- test/fixup.test.ts | 4 ++-- test/routes/404.test.ts | 2 +- test/routes/canteens.test.ts | 2 +- test/routes/default.test.ts | 2 +- test/routes/fixtures.ts | 2 +- test/routes/meta/legend.test.ts | 2 +- test/routes/plans.test.ts | 2 +- tsconfig.json | 6 ++++-- 23 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/cache.ts b/src/cache.ts index 1806b56..9343460 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -1,6 +1,6 @@ import { formatDate, parseDate } from './util/date-format.js' -import { Adapter } from 'fs-adapters' -import { CanteenPlan, DateSpec } from 'ka-mensa-fetch' +import type { Adapter } from 'fs-adapters' +import type { CanteenPlan, DateSpec } from 'ka-mensa-fetch' /** * ENOENT error code. diff --git a/src/controllers/canteens-controller.ts b/src/controllers/canteens-controller.ts index b7f55d6..08cadb3 100644 --- a/src/controllers/canteens-controller.ts +++ b/src/controllers/canteens-controller.ts @@ -1,4 +1,4 @@ -import { Canteen, Line, canteens } from 'ka-mensa-fetch' +import { type Canteen, type Line, canteens } from 'ka-mensa-fetch' import { NotFoundError } from '../errors.js' /** diff --git a/src/controllers/legend-controller.ts b/src/controllers/legend-controller.ts index d4d701c..1f49fd2 100644 --- a/src/controllers/legend-controller.ts +++ b/src/controllers/legend-controller.ts @@ -1,4 +1,4 @@ -import { LegendItem, legend } from 'ka-mensa-fetch' +import { type LegendItem, legend } from 'ka-mensa-fetch' /** * API controller for retrieving the legend. diff --git a/src/controllers/plans-controller.ts b/src/controllers/plans-controller.ts index d3cd4a2..9f03345 100644 --- a/src/controllers/plans-controller.ts +++ b/src/controllers/plans-controller.ts @@ -1,5 +1,5 @@ -import { CanteenLine, CanteenPlan, DateSpec } from 'ka-mensa-fetch' -import { Cache } from '../cache.js' +import type { CanteenLine, CanteenPlan, DateSpec } from 'ka-mensa-fetch' +import type { Cache } from '../cache.js' import { NotFoundError } from '../errors.js' /** diff --git a/src/fixup.ts b/src/fixup.ts index 44c2165..096f230 100644 --- a/src/fixup.ts +++ b/src/fixup.ts @@ -1,5 +1,5 @@ -import { CanteenPlan, DateSpec, matchCanteenByName, matchLineByName } from 'ka-mensa-fetch' -import { Cache } from './cache.js' +import { type CanteenPlan, type DateSpec, matchCanteenByName, matchLineByName } from 'ka-mensa-fetch' +import type { Cache } from './cache.js' /** * Fix a single plan. This fills in missing data (specifically: IDs) by matching it against existing data diff --git a/src/http-server.ts b/src/http-server.ts index 4a63649..8094157 100644 --- a/src/http-server.ts +++ b/src/http-server.ts @@ -1,6 +1,6 @@ import { onTermination } from 'omniwheel' -import { Cache } from './cache.js' -import fastify, { FastifyInstance } from 'fastify' +import type { Cache } from './cache.js' +import fastify, { type FastifyInstance } from 'fastify' import cors from '@fastify/cors' import { sendError } from './response.js' import { ApiError, BadRequestError, InternalServerError, NotFoundError } from './errors.js' diff --git a/src/job.ts b/src/job.ts index 1f2e2a5..1d5825f 100644 --- a/src/job.ts +++ b/src/job.ts @@ -1,12 +1,12 @@ -import { CanteenPlan, DateSpec, fetchMensa } from 'ka-mensa-fetch' +import { type CanteenPlan, type DateSpec, fetchMensa } from 'ka-mensa-fetch' import { group } from 'group-items' import moment from 'moment' import ms from 'ms' -import { Config } from './config.js' +import type { Config } from './config.js' import { getSessionCookie } from './get-session-cookie.js' -import { Cache } from './cache.js' +import type { Cache } from './cache.js' import { formatDate } from './util/date-format.js' -import { Logger } from 'winston' +import type { Logger } from 'winston' /** * Maximum age of a plan that is still considered valid for caching. If a plan diff --git a/src/response.ts b/src/response.ts index 82a883e..d207abc 100644 --- a/src/response.ts +++ b/src/response.ts @@ -1,5 +1,5 @@ -import { FastifyReply } from 'fastify' -import { ApiError } from './errors.js' +import type { FastifyReply } from 'fastify' +import type { ApiError } from './errors.js' /** * Respond with an error message. diff --git a/src/routes/canteens.ts b/src/routes/canteens.ts index 4c8ffa3..79450e5 100644 --- a/src/routes/canteens.ts +++ b/src/routes/canteens.ts @@ -1,5 +1,5 @@ import { CanteensController } from '../controllers/canteens-controller.js' -import { FastifyPluginAsync } from 'fastify' +import type { FastifyPluginAsync } from 'fastify' import { sendResult } from '../response.js' /** diff --git a/src/routes/default.ts b/src/routes/default.ts index 04a558f..90d27bd 100644 --- a/src/routes/default.ts +++ b/src/routes/default.ts @@ -1,4 +1,4 @@ -import { FastifyPluginAsync } from 'fastify' +import type { FastifyPluginAsync } from 'fastify' import { sendResult } from '../response.js' /** diff --git a/src/routes/meta/index.ts b/src/routes/meta/index.ts index 0ee81ea..fa44cd8 100644 --- a/src/routes/meta/index.ts +++ b/src/routes/meta/index.ts @@ -1,5 +1,5 @@ import { legendRoute } from './legend.js' -import { FastifyPluginAsync } from 'fastify' +import type { FastifyPluginAsync } from 'fastify' /** * Create the route that combines meta information routes. diff --git a/src/routes/meta/legend.ts b/src/routes/meta/legend.ts index 8b2bdc0..5030fdd 100644 --- a/src/routes/meta/legend.ts +++ b/src/routes/meta/legend.ts @@ -1,5 +1,5 @@ import { LegendController } from '../../controllers/legend-controller.js' -import { FastifyPluginAsync } from 'fastify' +import type { FastifyPluginAsync } from 'fastify' import { sendResult } from '../../response.js' /** diff --git a/src/routes/plans.ts b/src/routes/plans.ts index 6e0a285..62a3b56 100644 --- a/src/routes/plans.ts +++ b/src/routes/plans.ts @@ -1,10 +1,10 @@ -import { DateSpec, canteens } from 'ka-mensa-fetch' -import { Cache } from '../cache.js' +import { type DateSpec, canteens } from 'ka-mensa-fetch' +import type { Cache } from '../cache.js' import { parseDate } from '../util/date-format.js' import { PlansController } from '../controllers/plans-controller.js' import { BadRequestError } from '../errors.js' import { parseCommaFilter } from '../util/parse-comma-filter.js' -import { FastifyPluginAsync } from 'fastify' +import type { FastifyPluginAsync } from 'fastify' import { sendResult } from '../response.js' const CANTEEN_IDS = canteens.map(({ id }) => id) diff --git a/src/server.ts b/src/server.ts index 4190efe..73a3378 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,5 +1,5 @@ import { DirectoryAdapter } from 'fs-adapters' -import { Config, getConfig } from './config.js' +import { type Config, getConfig } from './config.js' import { Cache } from './cache.js' import { runFetchJob } from './job.js' import { onTermination } from 'omniwheel' diff --git a/src/util/date-format.ts b/src/util/date-format.ts index bcd2022..647c8be 100644 --- a/src/util/date-format.ts +++ b/src/util/date-format.ts @@ -1,4 +1,4 @@ -import { DateSpec } from 'ka-mensa-fetch' +import type { DateSpec } from 'ka-mensa-fetch' /** * Format the given date spec into a string YYYY-MM-DD. diff --git a/test/fixup.test.ts b/test/fixup.test.ts index a7450c9..a04e0a1 100644 --- a/test/fixup.test.ts +++ b/test/fixup.test.ts @@ -1,7 +1,7 @@ import assert from 'node:assert' import { Cache } from '../src/cache.js' -import { MemoryAdapter, ReadWriteOptions } from 'fs-adapters' -import { CanteenPlan, canteens, DateSpec } from 'ka-mensa-fetch' +import { MemoryAdapter, type ReadWriteOptions } from 'fs-adapters' +import { type CanteenPlan, canteens, type DateSpec } from 'ka-mensa-fetch' import { fixupCache } from '../src/fixup.js' /** diff --git a/test/routes/404.test.ts b/test/routes/404.test.ts index 718fc30..d879ac2 100644 --- a/test/routes/404.test.ts +++ b/test/routes/404.test.ts @@ -3,7 +3,7 @@ import { Cache } from '../../src/cache.js' import { MemoryAdapter } from 'fs-adapters' import assert from 'node:assert' import { HttpStatus } from 'omniwheel' -import { FastifyInstance } from 'fastify' +import type { FastifyInstance } from 'fastify' import winston from 'winston' import { defaultOptions } from './fixtures.js' diff --git a/test/routes/canteens.test.ts b/test/routes/canteens.test.ts index 51517d6..8790d34 100644 --- a/test/routes/canteens.test.ts +++ b/test/routes/canteens.test.ts @@ -4,7 +4,7 @@ import { MemoryAdapter } from 'fs-adapters' import assert from 'node:assert' import { HttpStatus } from 'omniwheel' import { canteens } from 'ka-mensa-fetch' -import { FastifyInstance } from 'fastify' +import type { FastifyInstance } from 'fastify' import winston from 'winston' import { defaultOptions } from './fixtures.js' diff --git a/test/routes/default.test.ts b/test/routes/default.test.ts index 0331bb2..fd7e54b 100644 --- a/test/routes/default.test.ts +++ b/test/routes/default.test.ts @@ -3,7 +3,7 @@ import { Cache } from '../../src/cache.js' import { MemoryAdapter } from 'fs-adapters' import assert from 'node:assert' import { HttpStatus } from 'omniwheel' -import { FastifyInstance } from 'fastify' +import type { FastifyInstance } from 'fastify' import winston from 'winston' import { defaultOptions } from './fixtures.js' diff --git a/test/routes/fixtures.ts b/test/routes/fixtures.ts index 63b808b..3684eac 100644 --- a/test/routes/fixtures.ts +++ b/test/routes/fixtures.ts @@ -1,4 +1,4 @@ -import { HttpServerOptions } from '../../src/http-server.js' +import type { HttpServerOptions } from '../../src/http-server.js' export const defaultOptions: HttpServerOptions = { host: '127.0.0.1', diff --git a/test/routes/meta/legend.test.ts b/test/routes/meta/legend.test.ts index 2f1edbb..6ac7e27 100644 --- a/test/routes/meta/legend.test.ts +++ b/test/routes/meta/legend.test.ts @@ -4,7 +4,7 @@ import { MemoryAdapter } from 'fs-adapters' import assert from 'node:assert' import { HttpStatus } from 'omniwheel' import { legend } from 'ka-mensa-fetch' -import { FastifyInstance } from 'fastify' +import type { FastifyInstance } from 'fastify' import winston from 'winston' import { defaultOptions } from '../fixtures.js' diff --git a/test/routes/plans.test.ts b/test/routes/plans.test.ts index a2b7bd9..dfcc563 100644 --- a/test/routes/plans.test.ts +++ b/test/routes/plans.test.ts @@ -3,7 +3,7 @@ import { Cache } from '../../src/cache.js' import { MemoryAdapter } from 'fs-adapters' import assert from 'node:assert' import { HttpStatus } from 'omniwheel' -import { FastifyInstance, LightMyRequestResponse } from 'fastify' +import type { FastifyInstance, LightMyRequestResponse } from 'fastify' import { canteens } from 'ka-mensa-fetch' import winston from 'winston' import { defaultOptions } from './fixtures.js' diff --git a/tsconfig.json b/tsconfig.json index cb0e681..709dd9f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,10 +2,12 @@ "compilerOptions": { "lib": ["ES2022"], "target": "ES2022", - "module": "ES2022", - "moduleResolution": "Node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "esModuleInterop": true, "strict": true, + "verbatimModuleSyntax": true, + "skipLibCheck": true, "inlineSourceMap": true, "outDir": "./dist" },