From 7f581073117b37975fdc5e3a5e58c6448b0e0c0f Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Mon, 4 Dec 2023 19:24:11 +0100 Subject: [PATCH] [iceshrimp-js] Build with tsc so we get type declarations --- packages/iceshrimp-js/package.json | 2 +- packages/iceshrimp-js/src/api.ts | 2 +- packages/iceshrimp-js/src/api.types.ts | 2 +- packages/iceshrimp-js/src/index.ts | 14 ++++++------ packages/iceshrimp-js/src/streaming.ts | 2 +- packages/iceshrimp-js/src/streaming.types.ts | 2 +- packages/iceshrimp-js/tsconfig.json | 23 +++++++++++++++----- 7 files changed, 30 insertions(+), 17 deletions(-) diff --git a/packages/iceshrimp-js/package.json b/packages/iceshrimp-js/package.json index f00b5796a..fe993b940 100644 --- a/packages/iceshrimp-js/package.json +++ b/packages/iceshrimp-js/package.json @@ -5,7 +5,7 @@ "main": "./built/index.js", "types": "./built/index.d.ts", "scripts": { - "build": "swc src -d built -D", + "build": "tsc", "build:debug": "swc src -d built -s -D", "render": "yarn build && yarn api && yarn api-prod && cp temp/iceshrimp-js.api.json etc/ && yarn api-doc", "tsd": "tsc && tsd", diff --git a/packages/iceshrimp-js/src/api.ts b/packages/iceshrimp-js/src/api.ts index 141aa4b85..f3182d091 100644 --- a/packages/iceshrimp-js/src/api.ts +++ b/packages/iceshrimp-js/src/api.ts @@ -1,4 +1,4 @@ -import { Endpoints } from "./api.types"; +import { Endpoints } from "./api.types.js"; const MK_API_ERROR = Symbol(); diff --git a/packages/iceshrimp-js/src/api.types.ts b/packages/iceshrimp-js/src/api.types.ts index 9bad7ec2d..0c4ec3c42 100644 --- a/packages/iceshrimp-js/src/api.types.ts +++ b/packages/iceshrimp-js/src/api.types.ts @@ -34,7 +34,7 @@ import { NoteReaction, Signin, MessagingMessage, -} from "./entities"; +} from "./entities.js"; type TODO = Record | null; diff --git a/packages/iceshrimp-js/src/index.ts b/packages/iceshrimp-js/src/index.ts index a909d4b32..0247b28f2 100644 --- a/packages/iceshrimp-js/src/index.ts +++ b/packages/iceshrimp-js/src/index.ts @@ -1,8 +1,8 @@ -import { Endpoints } from "./api.types"; -import Stream, { Connection } from "./streaming"; -import { Channels } from "./streaming.types"; -import { Acct } from "./acct"; -import * as consts from "./consts"; +import { Endpoints } from "./api.types.js"; +import Stream, { Connection } from "./streaming.js"; +import { Channels } from "./streaming.types.js"; +import { Acct } from "./acct.js"; +import * as consts from "./consts.js"; export { Endpoints, Stream, Connection as ChannelConnection, Channels, Acct }; @@ -14,6 +14,6 @@ export const ffVisibility = consts.ffVisibility; // api extractor not supported yet //export * as api from './api'; //export * as entities from './entities'; -import * as api from "./api"; -import * as entities from "./entities"; +import * as api from "./api.js"; +import * as entities from "./entities.js"; export { api, entities }; diff --git a/packages/iceshrimp-js/src/streaming.ts b/packages/iceshrimp-js/src/streaming.ts index 924e33a45..6f093bdb2 100644 --- a/packages/iceshrimp-js/src/streaming.ts +++ b/packages/iceshrimp-js/src/streaming.ts @@ -1,6 +1,6 @@ import { EventEmitter } from "eventemitter3"; import ReconnectingWebsocket from "reconnecting-websocket"; -import { BroadcastEvents, Channels } from "./streaming.types"; +import { BroadcastEvents, Channels } from "./streaming.types.js"; function autobind(instance: any): void { const prototype = Object.getPrototypeOf(instance); diff --git a/packages/iceshrimp-js/src/streaming.types.ts b/packages/iceshrimp-js/src/streaming.types.ts index c0b0b030c..6a3da4ddd 100644 --- a/packages/iceshrimp-js/src/streaming.types.ts +++ b/packages/iceshrimp-js/src/streaming.types.ts @@ -9,7 +9,7 @@ import type { PageEvent, User, UserGroup, -} from "./entities"; +} from "./entities.js"; type FIXME = any; diff --git a/packages/iceshrimp-js/tsconfig.json b/packages/iceshrimp-js/tsconfig.json index 642bcc45b..e2b755075 100644 --- a/packages/iceshrimp-js/tsconfig.json +++ b/packages/iceshrimp-js/tsconfig.json @@ -1,8 +1,9 @@ { "$schema": "http://json.schemastore.org/tsconfig", "compilerOptions": { - "target": "es2020", - "module": "commonjs", + "target": "ES2022", + "module": "nodenext", + "moduleResolution": "nodenext", "declaration": true, "declarationMap": true, "sourceMap": true, @@ -13,8 +14,20 @@ "strictNullChecks": true, "experimentalDecorators": true, "noImplicitReturns": true, - "esModuleInterop": true + "esModuleInterop": true, + "typeRoots": [ + "./node_modules/@types" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["src/**/*"], - "exclude": ["node_modules", "test/**/*"] + "include": [ + "src/**/*" + ], + "exclude": [ + "node_modules", + "test/**/*" + ] }