Skip to content

Commit f77fe44

Browse files
committed
refactor: new tsconfig/tsdown config
1 parent 978b477 commit f77fe44

7 files changed

Lines changed: 43 additions & 25 deletions

File tree

src/client/StelliaClient.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ export class StelliaClient<
101101
throw new Error("Environment not provided");
102102
}
103103

104-
const srcPath = path.dirname(path.resolve(process.argv[1]));
104+
const entryPoint = process.argv[1];
105+
if (!entryPoint) {
106+
throw new Error("Unable to resolve the entry point from process.argv[1]");
107+
}
108+
109+
const srcPath = path.dirname(path.resolve(entryPoint));
105110
const filePath = path.join(srcPath, "..", "stellia.json");
106111
return new Promise((resolve, reject) => {
107112
fs.readFile(filePath, async (err, data) => {

src/structures/Event.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ type PreReadyEventKeys =
1515

1616
type ClientReadyFor<K extends EventKeys> = K extends PreReadyEventKeys ? boolean : true;
1717

18-
export type EventExecute<K extends EventKeys, ExtraArgs extends unknown[] = []> = (
19-
client: StelliaClient<ClientReadyFor<K>>,
20-
...args: [...ExtraArgs, ...ClientEvents[K]]
21-
) => Awaitable<unknown>;
18+
export type EventExecute<K extends EventKeys, ExtraArgs extends unknown[] = []> = (client: StelliaClient<ClientReadyFor<K>>, ...args: [...ExtraArgs, ...ClientEvents[K]]) => Awaitable<unknown>;
2219

2320
export interface EventDataStructure<K extends EventKeys> {
2421
name: K;
2522
once?: boolean;
2623
}
24+
2725
export interface EventStructureWithoutGuildConfiguration<K extends EventKeys> {
2826
data: EventDataStructure<K>;
2927
execute: EventExecute<K>;
@@ -39,18 +37,18 @@ export interface EventStructureWithAllGuildsConfiguration<K extends EventKeys, T
3937
execute: EventExecute<K, [TGuildsConfig]>;
4038
}
4139

42-
export function defineEvent<K extends EventKeys>(event: EventStructureWithoutGuildConfiguration<K>) {
40+
export function defineEvent<K extends EventKeys>(event: EventStructureWithoutGuildConfiguration<K>): EventStructureWithoutGuildConfiguration<K> {
4341
return event;
4442
}
4543

4644
export function createGuildEventFactory<TConfig extends GuildConfigurationType = GuildConfigurationType>() {
47-
return function <K extends EventKeys>(event: EventStructureWithGuildConfiguration<K, TConfig>) {
45+
return function <K extends EventKeys>(event: EventStructureWithGuildConfiguration<K, TConfig>): EventStructureWithGuildConfiguration<K, TConfig> {
4846
return event;
4947
};
5048
}
5149

5250
export function createAllGuildsEventFactory<TGuildsConfig extends GuildsConfiguration = GuildsConfiguration>() {
53-
return function <K extends EventKeys>(event: EventStructureWithAllGuildsConfiguration<K, TGuildsConfig>) {
51+
return function <K extends EventKeys>(event: EventStructureWithAllGuildsConfiguration<K, TGuildsConfig>): EventStructureWithAllGuildsConfiguration<K, TGuildsConfig> {
5452
return event;
5553
};
5654
}

src/utils/ContentUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export namespace ContentUtils {
2-
export const ellipsis = (content: string, max: number) => {
2+
export const ellipsis = (content: string, max: number): string => {
33
return content.length > max ? content.slice(0, max) + "..." : content;
44
};
55
}

src/utils/logger.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import { toError } from "@utils/index.js";
33

44
const prefix = "[StelliaJS]";
55
export const logger = {
6-
info: (message: string) => {
6+
info: (message: string): void => {
77
console.log(`${logSymbols.info} ${prefix} ${message}`);
88
},
9-
success: (message: string) => {
9+
success: (message: string): void => {
1010
console.log(`${logSymbols.success} ${prefix} ${message}`);
1111
},
12-
warn: (message: string) => {
12+
warn: (message: string): void => {
1313
console.warn(`${logSymbols.warning} ${prefix} ${message}`);
1414
},
15-
error: (message: string) => {
15+
error: (message: string): void => {
1616
console.error(`${logSymbols.error} ${prefix} ${message}`);
1717
},
18-
errorWithInformation: (message: string, error: unknown) => {
18+
errorWithInformation: (message: string, error: unknown): void => {
1919
console.error(`${logSymbols.error} ${prefix} ${message}:`, toError(error));
2020
}
2121
};

src/utils/translation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type TranslateArgs = Record<string, unknown>;
55

66
let _instance: i18n;
77

8-
export const initTranslations = (instance: i18n) => {
8+
export const initTranslations = (instance: i18n): void => {
99
_instance = instance;
1010
};
1111

tsconfig.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
{
22
"compilerOptions": {
3-
"strictPropertyInitialization": false,
43
"target": "ES2025",
4+
"lib": ["ES2025"],
55
"module": "NodeNext",
6+
"moduleResolution": "NodeNext",
7+
"moduleDetection": "force",
8+
"verbatimModuleSyntax": true,
9+
"strict": true,
10+
"strictPropertyInitialization": false,
11+
"noUncheckedIndexedAccess": true,
12+
"noImplicitOverride": true,
13+
"exactOptionalPropertyTypes": true,
614
"esModuleInterop": true,
715
"forceConsistentCasingInFileNames": true,
8-
"strict": true,
916
"skipLibCheck": true,
17+
"isolatedModules": true,
18+
"resolveJsonModule": true,
19+
"declaration": true,
20+
"isolatedDeclarations": true,
21+
"noEmit": false,
22+
"types": ["node"],
1023
"paths": {
1124
"@client/*": ["./src/client/*"],
1225
"@constants/*": ["./src/constants/*"],
@@ -17,5 +30,6 @@
1730
"*": ["./src/*"]
1831
}
1932
},
20-
"include": ["src/**/*"]
21-
}
33+
"include": ["src/**/*"],
34+
"exclude": ["node_modules", "dist"]
35+
}

tsdown.config.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { defineConfig } from "tsdown";
22

33
export default defineConfig({
4-
entry: "./src/index.ts",
4+
entry: ["./src/index.ts"],
55
platform: "node",
6-
dts: true,
7-
format: "esm",
6+
format: ["esm"],
7+
target: "es2025",
88
clean: true,
9-
deps: {
10-
skipNodeModulesBundle: true
11-
}
9+
dts: {
10+
oxc: true
11+
},
12+
unused: false,
1213
});

0 commit comments

Comments
 (0)