Skip to content

Commit 8f6f077

Browse files
authored
Refactor/Update TypeScript configuration across all packages (#74)
2 parents c8dadc6 + 696f3f9 commit 8f6f077

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+542
-206
lines changed

.github/workflows/typecheck.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Type Check
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- main
8+
pull_request:
9+
branches:
10+
- develop
11+
- main
12+
13+
jobs:
14+
typecheck:
15+
runs-on: ubuntu-latest
16+
env:
17+
THUMBNAIL_URL: ${{ vars.THUMBNAIL_URL }}
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Install bun
24+
uses: oven-sh/setup-bun@v2
25+
with:
26+
bun-version: latest
27+
28+
- name: Install dependencies
29+
run: bun install
30+
31+
- name: Type check (project references)
32+
run: bun run typecheck

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
"files.associations": {
1717
".css": "tailwindcss",
1818
"*.scss": "tailwindcss"
19-
}
19+
},
20+
"typescript.tsdk": "./node_modules/typescript/lib",
21+
"typescript.enablePromptUseWorkspaceTsdk": true
2022
}

apps/backend/scripts/build.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,20 @@ const build = async () => {
6565
target: 'bun',
6666
minify: false,
6767
sourcemap: 'linked',
68-
external: optionalRequirePackages.filter((pkg) => {
69-
try {
70-
require(pkg);
71-
return false;
72-
} catch (_) {
73-
return true;
74-
}
75-
}),
68+
external: [
69+
...optionalRequirePackages.filter((pkg) => {
70+
try {
71+
require(pkg);
72+
return false;
73+
} catch (_) {
74+
return true;
75+
}
76+
}),
77+
'@nbw/config',
78+
'@nbw/database',
79+
'@nbw/song',
80+
'@nbw/sounds',
81+
],
7682
splitting: true,
7783
});
7884

apps/backend/tsconfig.build.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

apps/backend/tsconfig.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,13 @@
88
"removeComments": true,
99
"allowSyntheticDefaultImports": true,
1010
"sourceMap": true,
11-
"outDir": "./dist",
12-
"baseUrl": "./",
1311
"emitDecoratorMetadata": true,
14-
// Relaxed strict settings for backend
15-
"strictNullChecks": false,
16-
"noImplicitAny": false,
17-
"strictBindCallApply": false,
18-
"forceConsistentCasingInFileNames": false,
19-
"noFallthroughCasesInSwitch": false,
12+
2013
// Path mapping
14+
"baseUrl": ".",
2115
"paths": {
2216
"@server/*": ["src/*"]
2317
}
2418
},
25-
"include": ["src/**/*.ts", "src/**/*.d.ts"],
26-
"exclude": ["node_modules", "dist", "e2e/**/*", "test/**/*"]
19+
"include": ["src", "scripts"]
2720
}

apps/frontend/next.config.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import createMDX from '@next/mdx';
44

55
const nextConfig = {
66
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
7+
// Externalize packages that use Node.js built-in modules for server components
8+
serverExternalPackages: ['@nbw/database', '@nbw/config'],
79
// See: https://github.com/Automattic/node-canvas/issues/867#issuecomment-1925284985
810
webpack: (config, { isServer }) => {
911
config.externals.push({
@@ -12,8 +14,9 @@ const nextConfig = {
1214

1315
// Prevent @nbw/thumbnail from being bundled on the server
1416
// It uses HTMLCanvasElement which is not available in Node.js
17+
// Also externalize backend packages that use Node.js modules
1518
if (isServer) {
16-
config.externals.push('@nbw/thumbnail');
19+
config.externals.push('@nbw/thumbnail', '@nbw/database');
1720
}
1821

1922
return config;

apps/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
7-
"build": "next build",
7+
"build": "next build --webpack",
88
"start": "next start",
99
"lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
1010
"test": "jest"

apps/frontend/src/app/(content)/(info)/blog/[id]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { PostType, getPostData } from '@web/lib/posts';
77
import { CustomMarkdown } from '@web/modules/shared/components/CustomMarkdown';
88

99
type BlogPageProps = {
10-
params: { id: string };
10+
params: Promise<{ id: string }>;
1111
};
1212

1313
export async function generateMetadata({

apps/frontend/src/app/(content)/(info)/help/[id]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { PostType, getPostData } from '@web/lib/posts';
77
import { CustomMarkdown } from '@web/modules/shared/components/CustomMarkdown';
88

99
type HelpPageProps = {
10-
params: { id: string };
10+
params: Promise<{ id: string }>;
1111
};
1212

1313
export async function generateMetadata({
@@ -34,8 +34,8 @@ export async function generateMetadata({
3434
};
3535
}
3636

37-
const HelpPost = ({ params }: HelpPageProps) => {
38-
const { id } = params;
37+
const HelpPost = async ({ params }: HelpPageProps) => {
38+
const { id } = await params;
3939
let post: PostType;
4040

4141
try {

apps/frontend/src/app/(content)/song/[id]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Metadata } from 'next';
22
import { cookies } from 'next/headers';
33

4-
import { SongViewDtoType } from '@nbw/database';
4+
import type { SongViewDtoType } from '@nbw/database';
55
import axios from '@web/lib/axios';
66
import { SongPage } from '@web/modules/song/components/SongPage';
77

0 commit comments

Comments
 (0)