Skip to content

Commit 5f20276

Browse files
committed
fix(twenty-front): fix tsconfig to properly typecheck all files with tsgo
The previous tsconfig setup used project references with `files: []`, which caused `tsgo -p tsconfig.json` to check nothing (tsgo requires the configs to include files directly, not through project references). ## Changes by package ### twenty-front - Simplified from 4 configs to 2: tsconfig.json (all files) + tsconfig.build.json (prod) - Removed: tsconfig.dev.json, tsconfig.spec.json, tsconfig.storybook.json - Updated jest.config.mjs, eslint.config.mjs, vite.config.ts references - Made applicationId optional in FieldMetadataItem and ObjectMetadataItem - Added missing navigationMenuItem translation - Added objectLabelSingular to Search GraphQL query ### twenty-ui - Simplified from 5 configs to 2: tsconfig.json (all files) + tsconfig.lib.json (build) - Removed: tsconfig.dev.json, tsconfig.spec.json, tsconfig.storybook.json - Removed baseUrl (not supported by tsgo) - Updated vite.config.ts and .storybook/main.ts references ### twenty-shared - Simplified from 3 configs to 2: tsconfig.json (all files) + tsconfig.lib.json (build) - Removed: tsconfig.spec.json - Removed baseUrl (not supported by tsgo) ### twenty-sdk - Simplified from 3 configs to 2: tsconfig.json (all files) + tsconfig.lib.json (build) - Removed: tsconfig.spec.json ### twenty-emails - Simplified to single tsconfig.json (all files) ### twenty-eslint-rules - Simplified from 3 configs to 1: tsconfig.json (all files) - Removed: tsconfig.lint.json, tsconfig.spec.json - Updated jest.config.mjs reference ### create-twenty-app - Simplified from 3 configs to 2: tsconfig.json (all files) + tsconfig.lib.json (build) - Removed: tsconfig.spec.json ## Note on pre-existing type errors Proper type checking now reveals ~77 pre-existing errors in twenty-front and ~1100 in twenty-server that were previously hidden. These are primarily: - Icon prop type mismatches (twenty-ui icons have required props that are optional in IconComponentProps) - Type inference issues with Object.keys() returning string | number | symbol These should be fixed in follow-up PRs.
2 parents da95b0e + 183cf6c commit 5f20276

File tree

349 files changed

+3045
-1977
lines changed

Some content is hidden

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

349 files changed

+3045
-1977
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@
5454
},
5555
"jestrunner.codeLensSelector": "**/*.{test,spec,integration-spec}.{js,jsx,ts,tsx}",
5656
"typescript.tsdk": "node_modules/typescript/lib",
57-
"typescript.experimental.useTsgo": true
57+
"typescript.experimental.useTsgo": false
5858
}

packages/create-twenty-app/src/constants/base-application/tsconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
"skipLibCheck": true,
2323
"skipDefaultLibCheck": true,
2424
"resolveJsonModule": true,
25+
"paths": {
26+
"src/*": ["./src/*"],
27+
"~/*": ["./*"]
28+
}
2529
},
2630
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
2731
}

packages/create-twenty-app/src/utils/__tests__/app-template.spec.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('copyBaseApplicationProject', () => {
4141
});
4242

4343
// Verify src/app/ folder exists
44-
const srcAppPath = join(testAppDirectory, 'src', 'app');
44+
const srcAppPath = join(testAppDirectory, 'src');
4545
expect(await fs.pathExists(srcAppPath)).toBe(true);
4646

4747
// Verify application.config.ts exists in src/app/
@@ -114,7 +114,6 @@ describe('copyBaseApplicationProject', () => {
114114
const appConfigPath = join(
115115
testAppDirectory,
116116
'src',
117-
'app',
118117
'application.config.ts',
119118
);
120119
const appConfigContent = await fs.readFile(appConfigPath, 'utf8');
@@ -127,7 +126,7 @@ describe('copyBaseApplicationProject', () => {
127126

128127
// Verify it imports the role identifier
129128
expect(appConfigContent).toContain(
130-
"import { DEFAULT_FUNCTION_ROLE_UNIVERSAL_IDENTIFIER } from './default-function.role'",
129+
"import { DEFAULT_FUNCTION_ROLE_UNIVERSAL_IDENTIFIER } from 'src/default-function.role'",
131130
);
132131

133132
// Verify display name and description
@@ -156,7 +155,6 @@ describe('copyBaseApplicationProject', () => {
156155
const roleConfigPath = join(
157156
testAppDirectory,
158157
'src',
159-
'app',
160158
'default-function.role.ts',
161159
);
162160
const roleConfigContent = await fs.readFile(roleConfigPath, 'utf8');
@@ -216,7 +214,6 @@ describe('copyBaseApplicationProject', () => {
216214
const appConfigPath = join(
217215
testAppDirectory,
218216
'src',
219-
'app',
220217
'application.config.ts',
221218
);
222219
const appConfigContent = await fs.readFile(appConfigPath, 'utf8');
@@ -247,11 +244,11 @@ describe('copyBaseApplicationProject', () => {
247244

248245
// Read both app configs
249246
const firstAppConfig = await fs.readFile(
250-
join(firstAppDir, 'src', 'app', 'application.config.ts'),
247+
join(firstAppDir, 'src', 'application.config.ts'),
251248
'utf8',
252249
);
253250
const secondAppConfig = await fs.readFile(
254-
join(secondAppDir, 'src', 'app', 'application.config.ts'),
251+
join(secondAppDir, 'src', 'application.config.ts'),
255252
'utf8',
256253
);
257254

@@ -289,11 +286,11 @@ describe('copyBaseApplicationProject', () => {
289286

290287
// Read both role configs
291288
const firstRoleConfig = await fs.readFile(
292-
join(firstAppDir, 'src', 'app', 'default-function.role.ts'),
289+
join(firstAppDir, 'src', 'default-function.role.ts'),
293290
'utf8',
294291
);
295292
const secondRoleConfig = await fs.readFile(
296-
join(secondAppDir, 'src', 'app', 'default-function.role.ts'),
293+
join(secondAppDir, 'src', 'default-function.role.ts'),
297294
'utf8',
298295
);
299296

packages/create-twenty-app/src/utils/app-template.ts

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as fs from 'fs-extra';
22
import { join } from 'path';
33
import { v4 } from 'uuid';
44

5-
const APP_FOLDER = 'src/app';
5+
const APP_FOLDER = 'src';
66

77
export const copyBaseApplicationProject = async ({
88
appName,
@@ -36,6 +36,10 @@ export const copyBaseApplicationProject = async ({
3636
appDirectory: appFolderPath,
3737
});
3838

39+
await createDefaultFunction({
40+
appDirectory: appFolderPath,
41+
});
42+
3943
await createApplicationConfig({
4044
displayName: appDisplayName,
4145
description: appDescription,
@@ -67,6 +71,7 @@ generated
6771
6872
# dev
6973
/dist/
74+
.twenty
7075
7176
# production
7277
/build
@@ -139,7 +144,7 @@ export const HelloWorld = () => {
139144
140145
export default defineFrontComponent({
141146
universalIdentifier: '${universalIdentifier}',
142-
name: 'hello-world',
147+
name: 'hello-world-front-component',
143148
description: 'A sample front component',
144149
component: HelloWorld,
145150
});
@@ -151,6 +156,41 @@ export default defineFrontComponent({
151156
);
152157
};
153158

159+
const createDefaultFunction = async ({
160+
appDirectory,
161+
}: {
162+
appDirectory: string;
163+
}) => {
164+
const universalIdentifier = v4();
165+
const triggerUniversalIdentifier = v4();
166+
167+
const content = `import { defineFunction } from 'twenty-sdk';
168+
169+
const handler = async (): Promise<{ message: string }> => {
170+
return { message: 'Hello, World!' };
171+
};
172+
173+
export default defineFunction({
174+
universalIdentifier: '${universalIdentifier}',
175+
name: 'hello-world-function',
176+
description: 'A sample serverless function',
177+
timeoutSeconds: 5,
178+
handler,
179+
triggers: [
180+
{
181+
universalIdentifier: '${triggerUniversalIdentifier}',
182+
type: 'route',
183+
path: '/hello-world-function',
184+
httpMethod: 'GET',
185+
isAuthRequired: false,
186+
},
187+
],
188+
});
189+
`;
190+
191+
await fs.writeFile(join(appDirectory, 'hello-world.function.ts'), content);
192+
};
193+
154194
const createApplicationConfig = async ({
155195
displayName,
156196
description,
@@ -161,7 +201,7 @@ const createApplicationConfig = async ({
161201
appDirectory: string;
162202
}) => {
163203
const content = `import { defineApp } from 'twenty-sdk';
164-
import { DEFAULT_FUNCTION_ROLE_UNIVERSAL_IDENTIFIER } from './default-function.role';
204+
import { DEFAULT_FUNCTION_ROLE_UNIVERSAL_IDENTIFIER } from 'src/default-function.role';
165205
166206
export default defineApp({
167207
universalIdentifier: '${v4()}',
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"extends": "../../tsconfig.base.json",
23
"compilerOptions": {
34
"allowJs": false,
45
"esModuleInterop": false,
@@ -8,19 +9,17 @@
89
"noImplicitAny": true,
910
"strictBindCallApply": false,
1011
"noEmit": true,
12+
"types": ["jest", "node"],
1113
"paths": {
1214
"@/*": ["./src/*"]
1315
}
1416
},
15-
"files": [],
16-
"include": [],
17-
"references": [
18-
{
19-
"path": "./tsconfig.lib.json"
20-
},
21-
{
22-
"path": "./tsconfig.spec.json"
23-
}
24-
],
25-
"extends": "../../tsconfig.base.json"
17+
"include": [
18+
"src/**/*.ts",
19+
"src/**/*.tsx",
20+
"src/**/*.d.ts",
21+
"**/__mocks__/**/*",
22+
"vite.config.ts",
23+
"jest.config.mjs"
24+
]
2625
}

packages/create-twenty-app/tsconfig.spec.json

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
{
2-
"type": "module",
2+
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"jsx": "react-jsx",
55
"allowJs": false,
66
"esModuleInterop": false,
77
"allowSyntheticDefaultImports": true,
88
"strict": true,
9-
"types": ["vite/client"],
9+
"types": ["vite/client", "node"],
1010
"paths": {
1111
"@/*": ["./src/*"],
1212
"src/*": ["./src/*"]
1313
}
1414
},
15-
"files": [],
16-
"include": ["vite.config.ts"],
17-
"references": [
18-
{
19-
"path": "./tsconfig.lib.json"
20-
}
21-
],
22-
"extends": "../../tsconfig.base.json"
15+
"include": [
16+
"src/**/*.ts",
17+
"src/**/*.tsx",
18+
"vite.config.ts"
19+
]
2320
}

packages/twenty-eslint-rules/jest.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
silent: false,
55
preset: '../../jest.preset.js',
66
transform: {
7-
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
7+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.json' }],
88
},
99
moduleFileExtensions: ['ts', 'js', 'html'],
1010
coverageDirectory: '../../coverage/packages/twenty-eslint-rules',

packages/twenty-eslint-rules/tsconfig.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,8 @@
44
"outDir": "../../.cache/tsc",
55
"esModuleInterop": true,
66
"moduleResolution": "node16",
7-
"module": "node16"
7+
"module": "node16",
8+
"types": ["jest", "node"]
89
},
9-
"files": [],
10-
"include": [],
11-
"references": [
12-
{
13-
"path": "./tsconfig.lint.json"
14-
},
15-
{
16-
"path": "./tsconfig.spec.json"
17-
}
18-
]
10+
"include": ["**/*.ts", "jest.config.mjs"]
1911
}

packages/twenty-eslint-rules/tsconfig.lint.json

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

0 commit comments

Comments
 (0)