Skip to content

Commit e11cf4e

Browse files
committed
fix: resolve TypeScript typing issues across monorepo
- Add Jest type definitions to backend package - Fix database package TypeScript build configuration to generate .d.ts files - Add @nbw/database dependency to frontend package - Fix incorrect import paths in frontend components - Add missing @types/unidecode dependency to song package - Improve build script with proper build order and error handling - Update frontend tsconfig to use bundler module resolution All packages now build successfully with proper type exports.
1 parent c9ffc37 commit e11cf4e

File tree

15 files changed

+90
-80
lines changed

15 files changed

+90
-80
lines changed

apps/backend/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"@types/bcryptjs": "^2.4.6",
7171
"@types/bun": "^1.2.10",
7272
"@types/express": "^4.17.21",
73+
"@types/jest": "^29.5.12",
7374
"@types/multer": "^1.4.12",
7475
"@types/node": "^20.17.10",
7576
"@types/passport": "^1.0.17",
@@ -79,8 +80,10 @@
7980
"@types/passport-local": "^1.0.38",
8081
"@types/passport-oauth2": "^1.4.17",
8182
"@types/supertest": "^2.0.16",
83+
"jest": "^29.7.0",
8284
"source-map-support": "^0.5.21",
8385
"supertest": "^6.3.4",
86+
"ts-jest": "^29.1.2",
8487
"ts-loader": "^9.5.1",
8588
"ts-node": "^10.9.2",
8689
"tsc-watch": "^6.2.1",

apps/backend/src/jest.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference types="jest" />
2+
3+
declare global {
4+
namespace jest {
5+
interface Matchers<R> {
6+
toBeDefined(): R;
7+
toHaveBeenCalled(): R;
8+
toHaveBeenCalledWith(...args: any[]): R;
9+
toHaveBeenCalledTimes(times: number): R;
10+
toEqual(expected: any): R;
11+
toThrow(error?: any): R;
12+
toResolve(): R;
13+
toReject(): R;
14+
}
15+
}
16+
}
17+
18+
export {};

apps/backend/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@
2424
}
2525
},
2626
"include": [
27-
"src/**/*.ts"
27+
"src/**/*.ts",
28+
"src/**/*.d.ts"
2829
],
2930
"exclude": [
3031
"node_modules",
3132
"dist",
32-
"**/*.spec.ts",
33-
"**/*.test.ts",
3433
"e2e/**/*",
3534
"test/**/*"
3635
]

apps/frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@hookform/resolvers": "^3.3.4",
1818
"@mdx-js/loader": "^3.0.1",
1919
"@mdx-js/react": "^3.0.1",
20+
"@nbw/database": "workspace:*",
2021
"@next/mdx": "^14.2.6",
2122
"@next/third-parties": "^14.2.5",
2223
"@radix-ui/react-dialog": "^1.0.5",

apps/frontend/src/app/(content)/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FeaturedSongsDtoType, SongPreviewDtoType } from '@nbw/database';
1+
import type { FeaturedSongsDtoType, SongPreviewDtoType } from '@nbw/database';
22
import { Metadata } from 'next';
33

44
import axiosInstance from '@web/lib/axios';

apps/frontend/src/modules/song-edit/components/client/context/EditSong.context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { zodResolver } from '@hookform/resolvers/zod';
44
import type { UploadSongDtoType } from '@nbw/database';
55
import { parseSongFromBuffer } from '@nbw/song';
6-
import type { SongFileType } from '@nbw/song/src/types';
6+
import type { SongFileType } from '@nbw/song';
77
import { useRouter } from 'next/navigation';
88
import { createContext, useCallback, useEffect, useState } from 'react';
99
import {

apps/frontend/src/modules/song-upload/components/client/context/UploadSong.context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { zodResolver } from '@hookform/resolvers/zod';
44
import { BG_COLORS, THUMBNAIL_CONSTANTS } from '@nbw/config';
55
import { parseSongFromBuffer } from '@nbw/song';
6-
import { SongFileType } from '@nbw/song/src/types';
6+
import type { SongFileType } from '@nbw/song';
77
import { createContext, useContext, useEffect, useState } from 'react';
88
import {
99
FieldErrors,

apps/frontend/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"esnext"
1010
],
1111
"module": "esnext",
12-
"moduleResolution": "node",
12+
"moduleResolution": "bundler",
1313
"jsx": "preserve",
1414
"downlevelIteration": true,
1515
"allowJs": true,

bun.lock

Lines changed: 24 additions & 59 deletions
Large diffs are not rendered by default.

eslint.config.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import globals from 'globals';
88
export default [
99
// Base JavaScript configuration
1010
js.configs.recommended,
11+
...tseslint.configs.recommended,
1112

1213
// Global ignore patterns
1314
{
@@ -21,8 +22,6 @@ export default [
2122
'**/*.config.ts',
2223
'**/generated/**',
2324
'.eslintrc.js',
24-
'**/*.spec.ts',
25-
'**/*.test.ts',
2625
],
2726
},
2827

@@ -42,6 +41,8 @@ export default [
4241
globals: {
4342
// Universal globals that work everywhere
4443
...globals.node,
44+
...globals.jest,
45+
...globals.bun,
4546
...globals.browser,
4647
...globals.es2021,
4748
console: 'readonly',
@@ -55,8 +56,19 @@ export default [
5556
},
5657
},
5758
plugins: {
58-
'@typescript-eslint': tseslint,
59-
prettier: prettierPlugin,
59+
'import/resolver': {
60+
typescript: {
61+
// Point to all tsconfig.json files in your workspaces
62+
project: [
63+
'apps/*/tsconfig.json',
64+
'packages/*/tsconfig.json',
65+
'./tsconfig.json', // Also include the root tsconfig as a fallback
66+
],
67+
},
68+
node: true,
69+
},
70+
// Allow Bun built-in modules
71+
'import/core-modules': ['bun:test', 'bun'],
6072
},
6173
rules: {
6274
// Turn off rules that conflict with TypeScript

0 commit comments

Comments
 (0)