From 6d68a704a36cc0e30e1f59df6f2654409ad25d8f Mon Sep 17 00:00:00 2001 From: b1ek Date: Sat, 11 May 2024 21:58:25 +1000 Subject: [PATCH] fix: tsc errors --- src/client.ts | 2 +- src/config.ts | 3 ++- src/routes/delete.ts | 2 +- src/routes/get.ts | 2 +- src/routes/list.ts | 4 ++-- src/routes/upload.ts | 1 + src/store.ts | 4 ++-- tsconfig.json | 4 +++- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/client.ts b/src/client.ts index 82e9a89..fbe93a3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,4 +1,4 @@ -import crypto from 'node:crypto'; +import * as crypto from 'node:crypto'; export type Client = { name: string; diff --git a/src/config.ts b/src/config.ts index 34905bd..573caaa 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,8 +1,9 @@ import { Client, checkKey } from './client.js'; -import fsp from 'node:fs/promises'; +import * as fsp from 'node:fs/promises'; import Ajv from 'ajv'; import { existsSync } from 'node:fs'; +// @ts-expect-error: esnext moment const ajv = new Ajv(); const config_validate = ajv.compile({ diff --git a/src/routes/delete.ts b/src/routes/delete.ts index 8fd3f11..d7266c3 100644 --- a/src/routes/delete.ts +++ b/src/routes/delete.ts @@ -1,5 +1,5 @@ import { type FastifyPluginAsync } from 'fastify'; -import fsp from 'node:fs/promises'; +import * as fsp from 'node:fs/promises'; import { Config, config } from '../config.js'; import { InvalidAuthorization } from '../errors.js'; diff --git a/src/routes/get.ts b/src/routes/get.ts index c6b2a21..23701b4 100644 --- a/src/routes/get.ts +++ b/src/routes/get.ts @@ -1,5 +1,5 @@ import { FastifyPluginAsync } from 'fastify'; -import fsp from 'node:fs/promises'; +import * as fsp from 'node:fs/promises'; import { Config, config } from '../config.js'; import { InvalidAuthorization, NotFoundError } from '../errors.js'; diff --git a/src/routes/list.ts b/src/routes/list.ts index 5cf796a..0fe89d1 100644 --- a/src/routes/list.ts +++ b/src/routes/list.ts @@ -1,6 +1,6 @@ import { type FastifyPluginAsync } from 'fastify'; -import fsp from 'node:fs/promises'; -import path from 'node:path'; +import * as fsp from 'node:fs/promises'; +import * as path from 'node:path'; import { Stats } from 'node:fs'; import { Config, config } from '../config.js'; diff --git a/src/routes/upload.ts b/src/routes/upload.ts index 1f8ebaf..a94a699 100644 --- a/src/routes/upload.ts +++ b/src/routes/upload.ts @@ -14,6 +14,7 @@ type UploadPayload = { data: string; // base64-encoded name: string; }; +// @ts-expect-error: esnext moment const ajv = new Ajv(); const upload_schema = { type: 'object', diff --git a/src/store.ts b/src/store.ts index 8efb2a8..d716f21 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1,7 +1,7 @@ import { config } from './config.js'; -import path from 'path'; -import fsp from 'node:fs/promises'; +import * as path from 'path'; +import * as fsp from 'node:fs/promises'; import { NoKeyClient } from './client.js'; function getClient(clientName: string): NoKeyClient | undefined { diff --git a/tsconfig.json b/tsconfig.json index 95e4a11..ff5411c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,7 @@ { "compilerOptions": { - "lib": ["ES2023"] + "lib": ["ES2023"], + "module": "NodeNext", + "moduleResolution": "NodeNext" } }