diff --git a/waspc/data/Cli/templates/skeleton/tsconfig.json b/waspc/data/Cli/templates/skeleton/tsconfig.json index 4932b229a0..506b0e2fc1 100644 --- a/waspc/data/Cli/templates/skeleton/tsconfig.json +++ b/waspc/data/Cli/templates/skeleton/tsconfig.json @@ -1,11 +1,18 @@ // =============================== IMPORTANT ================================= +// This file is mainly used for Wasp IDE support. // -// This file is only used for Wasp IDE support. You can change it to configure -// your IDE checks, but none of these options will affect the TypeScript -// compiler. Proper TS compiler configuration in Wasp is coming soon :) +// Wasp will compile your code with slightly different (less strict) compilerOptions. +// You can increase the configuration's strictness (e.g., by adding +// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by +// adding "strict": false). Just keep in mind that this will only affect your +// IDE support, not the actual compilation. +// +// Full TypeScript configurability is coming very soon :) { "compilerOptions": { "module": "esnext", + // Needed because this is used as a project reference. + "composite": true, "target": "esnext", // We're bundling all code in the end so this is the most appropriate option, // it's also important for autocomplete to work properly. @@ -20,6 +27,7 @@ "dom.iterable", "esnext" ], + "skipLibCheck": true, "allowJs": true, "typeRoots": [ // This is needed to properly support Vitest testing with jest-dom matchers. @@ -32,10 +40,9 @@ // Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843 "node_modules/@types" ], - // Since this TS config is used only for IDE support and not for - // compilation, the following directory doesn't exist. We need to specify - // it to prevent this error: - // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file - "outDir": ".wasp/phantom" - } + "outDir": ".wasp/out/user" + }, + "include": [ + "src" + ] } diff --git a/waspc/data/Generator/templates/react-app/tsconfig.app.json b/waspc/data/Generator/templates/react-app/tsconfig.app.json new file mode 100644 index 0000000000..e7688c01f8 --- /dev/null +++ b/waspc/data/Generator/templates/react-app/tsconfig.app.json @@ -0,0 +1,20 @@ +{ + "extends": "@tsconfig/vite-react/tsconfig.json", + "compilerOptions": { + // Temporary loosen the type checking until we can address all the errors. + "jsx": "preserve", + "allowJs": true, + "strict": false, + "skipLibCheck": true, + // Allow importing pages with the .tsx extension. + "allowImportingTsExtensions": true, + "noEmit": true, + }, + "include": [ + "src" + ], + "references": [ + // TODO: It would be better to inject this knowledge from Haskell. + { "path": "../../../tsconfig.json" } + ] +} diff --git a/waspc/data/Generator/templates/react-app/tsconfig.json b/waspc/data/Generator/templates/react-app/tsconfig.json index 4e7d14e1cd..c529e779ec 100644 --- a/waspc/data/Generator/templates/react-app/tsconfig.json +++ b/waspc/data/Generator/templates/react-app/tsconfig.json @@ -1,19 +1,7 @@ { - "extends": "@tsconfig/vite-react/tsconfig.json", - "compilerOptions": { - // Temporary loosen the type checking until we can address all the errors. - "jsx": "preserve", - "allowJs": true, - "strict": false, - // Allow importing pages with the .tsx extension. - "allowImportingTsExtensions": true, - }, - "include": [ - "src" - ], + "files": [], "references": [ - { - "path": "./tsconfig.node.json" - } + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" }, ] -} \ No newline at end of file +} diff --git a/waspc/data/Generator/templates/react-app/tsconfig.node.json b/waspc/data/Generator/templates/react-app/tsconfig.node.json index d90bb30d80..2ae4a16a9c 100644 --- a/waspc/data/Generator/templates/react-app/tsconfig.node.json +++ b/waspc/data/Generator/templates/react-app/tsconfig.node.json @@ -2,9 +2,13 @@ "compilerOptions": { "composite": true, "skipLibCheck": true, + "noEmit": true, "module": "ESNext", "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] -} + "include": [ + "vite.config.ts", + "./src/ext-src/vite.config.ts" + ] +} \ No newline at end of file diff --git a/waspc/data/Generator/templates/server/tsconfig.json b/waspc/data/Generator/templates/server/tsconfig.json index f608b225ff..6d0f513a17 100644 --- a/waspc/data/Generator/templates/server/tsconfig.json +++ b/waspc/data/Generator/templates/server/tsconfig.json @@ -4,23 +4,15 @@ "compilerOptions": { // Overriding this until we implement more complete TypeScript support. "strict": false, - // When left unspecified, the 'rootDir' defaults to the longest common path of - // all non-declaration input files. TypeScript mimics the source structure - // inside the output directory (i.e., 'dist'). + + // This property currently doesn't matter because we haven't been running + // TSC on server code since https://github.com/wasp-lang/wasp/pull/1714. // - // Since Wasp apps can (but don't have to) import user files from - // '../../../src', it makes the rootDir's default value inconsistent: - // - When the app doesn't import user files (e.g., the user didn't specify - // any operations), the rootDir is set to the server source dir (/src). - // - When the app imports user files (as is the case for most Wasp apps), - // the rootDir is set to the Wasp project root (../../../). - // - // Our build script (in package.json) requires a consistent structure of - // the output directory, which is why we always make sure to point the rootDir - // to the Wasp project root (../../../). - // - // See this comment for more details: https://github.com/wasp-lang/wasp/pull/1584#discussion_r1404019301 - "rootDir": "../../../", + // When we start running TSC again (after we fix all current errors and + // make project references work for the TS config), then I believe the + // correct configuration is "rootDir": "." (the project reference should + // take care of the user code), but we should double-check. + "rootDir": ".", // Overriding this because we want to use top-level await "module": "esnext", "target": "es2017", @@ -36,5 +28,8 @@ }, "include": [ "src" + ], + "references": [ + { "path": "../../../tsconfig.json" } ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest b/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest index 5a02bbe90a..2565136956 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest @@ -248,6 +248,7 @@ waspBuild/.wasp/build/web-app/src/router.tsx waspBuild/.wasp/build/web-app/src/test/vitest/setup.ts waspBuild/.wasp/build/web-app/src/utils.js waspBuild/.wasp/build/web-app/src/vite-env.d.ts +waspBuild/.wasp/build/web-app/tsconfig.app.json waspBuild/.wasp/build/web-app/tsconfig.json waspBuild/.wasp/build/web-app/tsconfig.node.json waspBuild/.wasp/build/web-app/vite.config.ts diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums index 58f9e728a4..ad945e2745 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums @@ -522,7 +522,7 @@ "file", "server/tsconfig.json" ], - "bc6ba637ac3b2e0cbe9a8d01311fa87c7ba9394148246925c6ff9d562b59e6d1" + "622813a50faf658cd240456ce60406209b8f2c2d15669fcf83ad9566750d67e1" ], [ [ @@ -664,19 +664,26 @@ ], "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5" ], + [ + [ + "file", + "web-app/tsconfig.app.json" + ], + "5262d9e2187938464703a1a414250eb137478e4a7004a95a0a47c26b63313522" + ], [ [ "file", "web-app/tsconfig.json" ], - "dfeee6d883ed2504c149c64b24ca939c0ad4812b78bfdced7293a386a008effd" + "0f84a09c31c7cca7d2bed4fac04c3da0ce54b0996ab80b2b54f1a6a53e6fd139" ], [ [ "file", "web-app/tsconfig.node.json" ], - "30fed1f6aa4710deb690d1ae47628066f34afda7b633f0c696fafcda9e2dbc1e" + "ed42a259d45429569d3c5182e40e008b4c2bffd9c49a643019e8542035d21b7c" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/server/tsconfig.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/server/tsconfig.json index 90d743e771..dd523305d8 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/server/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/server/tsconfig.json @@ -3,23 +3,15 @@ "compilerOptions": { // Overriding this until we implement more complete TypeScript support. "strict": false, - // When left unspecified, the 'rootDir' defaults to the longest common path of - // all non-declaration input files. TypeScript mimics the source structure - // inside the output directory (i.e., 'dist'). + + // This property currently doesn't matter because we haven't been running + // TSC on server code since https://github.com/wasp-lang/wasp/pull/1714. // - // Since Wasp apps can (but don't have to) import user files from - // '../../../src', it makes the rootDir's default value inconsistent: - // - When the app doesn't import user files (e.g., the user didn't specify - // any operations), the rootDir is set to the server source dir (/src). - // - When the app imports user files (as is the case for most Wasp apps), - // the rootDir is set to the Wasp project root (../../../). - // - // Our build script (in package.json) requires a consistent structure of - // the output directory, which is why we always make sure to point the rootDir - // to the Wasp project root (../../../). - // - // See this comment for more details: https://github.com/wasp-lang/wasp/pull/1584#discussion_r1404019301 - "rootDir": "../../../", + // When we start running TSC again (after we fix all current errors and + // make project references work for the TS config), then I believe the + // correct configuration is "rootDir": "." (the project reference should + // take care of the user code), but we should double-check. + "rootDir": ".", // Overriding this because we want to use top-level await "module": "esnext", "target": "es2017", @@ -35,5 +27,8 @@ }, "include": [ "src" + ], + "references": [ + { "path": "../../../tsconfig.json" } ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.app.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.app.json new file mode 100644 index 0000000000..e7688c01f8 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.app.json @@ -0,0 +1,20 @@ +{ + "extends": "@tsconfig/vite-react/tsconfig.json", + "compilerOptions": { + // Temporary loosen the type checking until we can address all the errors. + "jsx": "preserve", + "allowJs": true, + "strict": false, + "skipLibCheck": true, + // Allow importing pages with the .tsx extension. + "allowImportingTsExtensions": true, + "noEmit": true, + }, + "include": [ + "src" + ], + "references": [ + // TODO: It would be better to inject this knowledge from Haskell. + { "path": "../../../tsconfig.json" } + ] +} diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.json index 4e7d14e1cd..c529e779ec 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.json @@ -1,19 +1,7 @@ { - "extends": "@tsconfig/vite-react/tsconfig.json", - "compilerOptions": { - // Temporary loosen the type checking until we can address all the errors. - "jsx": "preserve", - "allowJs": true, - "strict": false, - // Allow importing pages with the .tsx extension. - "allowImportingTsExtensions": true, - }, - "include": [ - "src" - ], + "files": [], "references": [ - { - "path": "./tsconfig.node.json" - } + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" }, ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.node.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.node.json index d90bb30d80..2ae4a16a9c 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.node.json +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.node.json @@ -2,9 +2,13 @@ "compilerOptions": { "composite": true, "skipLibCheck": true, + "noEmit": true, "module": "ESNext", "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] -} + "include": [ + "vite.config.ts", + "./src/ext-src/vite.config.ts" + ] +} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/tsconfig.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/tsconfig.json index 4932b229a0..506b0e2fc1 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/tsconfig.json @@ -1,11 +1,18 @@ // =============================== IMPORTANT ================================= +// This file is mainly used for Wasp IDE support. // -// This file is only used for Wasp IDE support. You can change it to configure -// your IDE checks, but none of these options will affect the TypeScript -// compiler. Proper TS compiler configuration in Wasp is coming soon :) +// Wasp will compile your code with slightly different (less strict) compilerOptions. +// You can increase the configuration's strictness (e.g., by adding +// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by +// adding "strict": false). Just keep in mind that this will only affect your +// IDE support, not the actual compilation. +// +// Full TypeScript configurability is coming very soon :) { "compilerOptions": { "module": "esnext", + // Needed because this is used as a project reference. + "composite": true, "target": "esnext", // We're bundling all code in the end so this is the most appropriate option, // it's also important for autocomplete to work properly. @@ -20,6 +27,7 @@ "dom.iterable", "esnext" ], + "skipLibCheck": true, "allowJs": true, "typeRoots": [ // This is needed to properly support Vitest testing with jest-dom matchers. @@ -32,10 +40,9 @@ // Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843 "node_modules/@types" ], - // Since this TS config is used only for IDE support and not for - // compilation, the following directory doesn't exist. We need to specify - // it to prevent this error: - // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file - "outDir": ".wasp/phantom" - } + "outDir": ".wasp/out/user" + }, + "include": [ + "src" + ] } diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest b/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest index 24e8b832d0..264d7b12cf 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest @@ -245,6 +245,7 @@ waspCompile/.wasp/out/web-app/src/router.tsx waspCompile/.wasp/out/web-app/src/test/vitest/setup.ts waspCompile/.wasp/out/web-app/src/utils.js waspCompile/.wasp/out/web-app/src/vite-env.d.ts +waspCompile/.wasp/out/web-app/tsconfig.app.json waspCompile/.wasp/out/web-app/tsconfig.json waspCompile/.wasp/out/web-app/tsconfig.node.json waspCompile/.wasp/out/web-app/vite.config.ts diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums index 36ac1d92aa..71d675a7e1 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums @@ -529,7 +529,7 @@ "file", "server/tsconfig.json" ], - "bc6ba637ac3b2e0cbe9a8d01311fa87c7ba9394148246925c6ff9d562b59e6d1" + "622813a50faf658cd240456ce60406209b8f2c2d15669fcf83ad9566750d67e1" ], [ [ @@ -678,19 +678,26 @@ ], "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5" ], + [ + [ + "file", + "web-app/tsconfig.app.json" + ], + "5262d9e2187938464703a1a414250eb137478e4a7004a95a0a47c26b63313522" + ], [ [ "file", "web-app/tsconfig.json" ], - "dfeee6d883ed2504c149c64b24ca939c0ad4812b78bfdced7293a386a008effd" + "0f84a09c31c7cca7d2bed4fac04c3da0ce54b0996ab80b2b54f1a6a53e6fd139" ], [ [ "file", "web-app/tsconfig.node.json" ], - "30fed1f6aa4710deb690d1ae47628066f34afda7b633f0c696fafcda9e2dbc1e" + "ed42a259d45429569d3c5182e40e008b4c2bffd9c49a643019e8542035d21b7c" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/server/tsconfig.json b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/server/tsconfig.json index 90d743e771..dd523305d8 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/server/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/server/tsconfig.json @@ -3,23 +3,15 @@ "compilerOptions": { // Overriding this until we implement more complete TypeScript support. "strict": false, - // When left unspecified, the 'rootDir' defaults to the longest common path of - // all non-declaration input files. TypeScript mimics the source structure - // inside the output directory (i.e., 'dist'). + + // This property currently doesn't matter because we haven't been running + // TSC on server code since https://github.com/wasp-lang/wasp/pull/1714. // - // Since Wasp apps can (but don't have to) import user files from - // '../../../src', it makes the rootDir's default value inconsistent: - // - When the app doesn't import user files (e.g., the user didn't specify - // any operations), the rootDir is set to the server source dir (/src). - // - When the app imports user files (as is the case for most Wasp apps), - // the rootDir is set to the Wasp project root (../../../). - // - // Our build script (in package.json) requires a consistent structure of - // the output directory, which is why we always make sure to point the rootDir - // to the Wasp project root (../../../). - // - // See this comment for more details: https://github.com/wasp-lang/wasp/pull/1584#discussion_r1404019301 - "rootDir": "../../../", + // When we start running TSC again (after we fix all current errors and + // make project references work for the TS config), then I believe the + // correct configuration is "rootDir": "." (the project reference should + // take care of the user code), but we should double-check. + "rootDir": ".", // Overriding this because we want to use top-level await "module": "esnext", "target": "es2017", @@ -35,5 +27,8 @@ }, "include": [ "src" + ], + "references": [ + { "path": "../../../tsconfig.json" } ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.app.json b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.app.json new file mode 100644 index 0000000000..e7688c01f8 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.app.json @@ -0,0 +1,20 @@ +{ + "extends": "@tsconfig/vite-react/tsconfig.json", + "compilerOptions": { + // Temporary loosen the type checking until we can address all the errors. + "jsx": "preserve", + "allowJs": true, + "strict": false, + "skipLibCheck": true, + // Allow importing pages with the .tsx extension. + "allowImportingTsExtensions": true, + "noEmit": true, + }, + "include": [ + "src" + ], + "references": [ + // TODO: It would be better to inject this knowledge from Haskell. + { "path": "../../../tsconfig.json" } + ] +} diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.json b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.json index 4e7d14e1cd..c529e779ec 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.json @@ -1,19 +1,7 @@ { - "extends": "@tsconfig/vite-react/tsconfig.json", - "compilerOptions": { - // Temporary loosen the type checking until we can address all the errors. - "jsx": "preserve", - "allowJs": true, - "strict": false, - // Allow importing pages with the .tsx extension. - "allowImportingTsExtensions": true, - }, - "include": [ - "src" - ], + "files": [], "references": [ - { - "path": "./tsconfig.node.json" - } + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" }, ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.node.json b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.node.json index d90bb30d80..2ae4a16a9c 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.node.json +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.node.json @@ -2,9 +2,13 @@ "compilerOptions": { "composite": true, "skipLibCheck": true, + "noEmit": true, "module": "ESNext", "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] -} + "include": [ + "vite.config.ts", + "./src/ext-src/vite.config.ts" + ] +} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/tsconfig.json b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/tsconfig.json index 4932b229a0..506b0e2fc1 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/tsconfig.json @@ -1,11 +1,18 @@ // =============================== IMPORTANT ================================= +// This file is mainly used for Wasp IDE support. // -// This file is only used for Wasp IDE support. You can change it to configure -// your IDE checks, but none of these options will affect the TypeScript -// compiler. Proper TS compiler configuration in Wasp is coming soon :) +// Wasp will compile your code with slightly different (less strict) compilerOptions. +// You can increase the configuration's strictness (e.g., by adding +// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by +// adding "strict": false). Just keep in mind that this will only affect your +// IDE support, not the actual compilation. +// +// Full TypeScript configurability is coming very soon :) { "compilerOptions": { "module": "esnext", + // Needed because this is used as a project reference. + "composite": true, "target": "esnext", // We're bundling all code in the end so this is the most appropriate option, // it's also important for autocomplete to work properly. @@ -20,6 +27,7 @@ "dom.iterable", "esnext" ], + "skipLibCheck": true, "allowJs": true, "typeRoots": [ // This is needed to properly support Vitest testing with jest-dom matchers. @@ -32,10 +40,9 @@ // Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843 "node_modules/@types" ], - // Since this TS config is used only for IDE support and not for - // compilation, the following directory doesn't exist. We need to specify - // it to prevent this error: - // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file - "outDir": ".wasp/phantom" - } + "outDir": ".wasp/out/user" + }, + "include": [ + "src" + ] } diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest b/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest index c2aa1b83ea..179f43327e 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest @@ -533,6 +533,7 @@ waspComplexTest/.wasp/out/web-app/src/router.tsx waspComplexTest/.wasp/out/web-app/src/test/vitest/setup.ts waspComplexTest/.wasp/out/web-app/src/utils.js waspComplexTest/.wasp/out/web-app/src/vite-env.d.ts +waspComplexTest/.wasp/out/web-app/tsconfig.app.json waspComplexTest/.wasp/out/web-app/tsconfig.json waspComplexTest/.wasp/out/web-app/tsconfig.node.json waspComplexTest/.wasp/out/web-app/vite.config.ts diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums index 812cd8b410..af780d4695 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums @@ -1152,7 +1152,7 @@ "file", "server/tsconfig.json" ], - "bc6ba637ac3b2e0cbe9a8d01311fa87c7ba9394148246925c6ff9d562b59e6d1" + "622813a50faf658cd240456ce60406209b8f2c2d15669fcf83ad9566750d67e1" ], [ [ @@ -1315,19 +1315,26 @@ ], "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5" ], + [ + [ + "file", + "web-app/tsconfig.app.json" + ], + "5262d9e2187938464703a1a414250eb137478e4a7004a95a0a47c26b63313522" + ], [ [ "file", "web-app/tsconfig.json" ], - "dfeee6d883ed2504c149c64b24ca939c0ad4812b78bfdced7293a386a008effd" + "0f84a09c31c7cca7d2bed4fac04c3da0ce54b0996ab80b2b54f1a6a53e6fd139" ], [ [ "file", "web-app/tsconfig.node.json" ], - "30fed1f6aa4710deb690d1ae47628066f34afda7b633f0c696fafcda9e2dbc1e" + "ed42a259d45429569d3c5182e40e008b4c2bffd9c49a643019e8542035d21b7c" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/server/tsconfig.json b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/server/tsconfig.json index 90d743e771..dd523305d8 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/server/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/server/tsconfig.json @@ -3,23 +3,15 @@ "compilerOptions": { // Overriding this until we implement more complete TypeScript support. "strict": false, - // When left unspecified, the 'rootDir' defaults to the longest common path of - // all non-declaration input files. TypeScript mimics the source structure - // inside the output directory (i.e., 'dist'). + + // This property currently doesn't matter because we haven't been running + // TSC on server code since https://github.com/wasp-lang/wasp/pull/1714. // - // Since Wasp apps can (but don't have to) import user files from - // '../../../src', it makes the rootDir's default value inconsistent: - // - When the app doesn't import user files (e.g., the user didn't specify - // any operations), the rootDir is set to the server source dir (/src). - // - When the app imports user files (as is the case for most Wasp apps), - // the rootDir is set to the Wasp project root (../../../). - // - // Our build script (in package.json) requires a consistent structure of - // the output directory, which is why we always make sure to point the rootDir - // to the Wasp project root (../../../). - // - // See this comment for more details: https://github.com/wasp-lang/wasp/pull/1584#discussion_r1404019301 - "rootDir": "../../../", + // When we start running TSC again (after we fix all current errors and + // make project references work for the TS config), then I believe the + // correct configuration is "rootDir": "." (the project reference should + // take care of the user code), but we should double-check. + "rootDir": ".", // Overriding this because we want to use top-level await "module": "esnext", "target": "es2017", @@ -35,5 +27,8 @@ }, "include": [ "src" + ], + "references": [ + { "path": "../../../tsconfig.json" } ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.app.json b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.app.json new file mode 100644 index 0000000000..e7688c01f8 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.app.json @@ -0,0 +1,20 @@ +{ + "extends": "@tsconfig/vite-react/tsconfig.json", + "compilerOptions": { + // Temporary loosen the type checking until we can address all the errors. + "jsx": "preserve", + "allowJs": true, + "strict": false, + "skipLibCheck": true, + // Allow importing pages with the .tsx extension. + "allowImportingTsExtensions": true, + "noEmit": true, + }, + "include": [ + "src" + ], + "references": [ + // TODO: It would be better to inject this knowledge from Haskell. + { "path": "../../../tsconfig.json" } + ] +} diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.json b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.json index 4e7d14e1cd..c529e779ec 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.json @@ -1,19 +1,7 @@ { - "extends": "@tsconfig/vite-react/tsconfig.json", - "compilerOptions": { - // Temporary loosen the type checking until we can address all the errors. - "jsx": "preserve", - "allowJs": true, - "strict": false, - // Allow importing pages with the .tsx extension. - "allowImportingTsExtensions": true, - }, - "include": [ - "src" - ], + "files": [], "references": [ - { - "path": "./tsconfig.node.json" - } + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" }, ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.node.json b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.node.json index d90bb30d80..2ae4a16a9c 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.node.json +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.node.json @@ -2,9 +2,13 @@ "compilerOptions": { "composite": true, "skipLibCheck": true, + "noEmit": true, "module": "ESNext", "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] -} + "include": [ + "vite.config.ts", + "./src/ext-src/vite.config.ts" + ] +} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/tsconfig.json b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/tsconfig.json index 4932b229a0..506b0e2fc1 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/tsconfig.json @@ -1,11 +1,18 @@ // =============================== IMPORTANT ================================= +// This file is mainly used for Wasp IDE support. // -// This file is only used for Wasp IDE support. You can change it to configure -// your IDE checks, but none of these options will affect the TypeScript -// compiler. Proper TS compiler configuration in Wasp is coming soon :) +// Wasp will compile your code with slightly different (less strict) compilerOptions. +// You can increase the configuration's strictness (e.g., by adding +// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by +// adding "strict": false). Just keep in mind that this will only affect your +// IDE support, not the actual compilation. +// +// Full TypeScript configurability is coming very soon :) { "compilerOptions": { "module": "esnext", + // Needed because this is used as a project reference. + "composite": true, "target": "esnext", // We're bundling all code in the end so this is the most appropriate option, // it's also important for autocomplete to work properly. @@ -20,6 +27,7 @@ "dom.iterable", "esnext" ], + "skipLibCheck": true, "allowJs": true, "typeRoots": [ // This is needed to properly support Vitest testing with jest-dom matchers. @@ -32,10 +40,9 @@ // Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843 "node_modules/@types" ], - // Since this TS config is used only for IDE support and not for - // compilation, the following directory doesn't exist. We need to specify - // it to prevent this error: - // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file - "outDir": ".wasp/phantom" - } + "outDir": ".wasp/out/user" + }, + "include": [ + "src" + ] } diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest b/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest index 544607942f..9b086261e1 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest @@ -290,6 +290,7 @@ waspJob/.wasp/out/web-app/src/router.tsx waspJob/.wasp/out/web-app/src/test/vitest/setup.ts waspJob/.wasp/out/web-app/src/utils.js waspJob/.wasp/out/web-app/src/vite-env.d.ts +waspJob/.wasp/out/web-app/tsconfig.app.json waspJob/.wasp/out/web-app/tsconfig.json waspJob/.wasp/out/web-app/tsconfig.node.json waspJob/.wasp/out/web-app/vite.config.ts diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums index f99f59fe34..d5b9f617fc 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums @@ -627,7 +627,7 @@ "file", "server/tsconfig.json" ], - "bc6ba637ac3b2e0cbe9a8d01311fa87c7ba9394148246925c6ff9d562b59e6d1" + "622813a50faf658cd240456ce60406209b8f2c2d15669fcf83ad9566750d67e1" ], [ [ @@ -776,19 +776,26 @@ ], "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5" ], + [ + [ + "file", + "web-app/tsconfig.app.json" + ], + "5262d9e2187938464703a1a414250eb137478e4a7004a95a0a47c26b63313522" + ], [ [ "file", "web-app/tsconfig.json" ], - "dfeee6d883ed2504c149c64b24ca939c0ad4812b78bfdced7293a386a008effd" + "0f84a09c31c7cca7d2bed4fac04c3da0ce54b0996ab80b2b54f1a6a53e6fd139" ], [ [ "file", "web-app/tsconfig.node.json" ], - "30fed1f6aa4710deb690d1ae47628066f34afda7b633f0c696fafcda9e2dbc1e" + "ed42a259d45429569d3c5182e40e008b4c2bffd9c49a643019e8542035d21b7c" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/server/tsconfig.json b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/server/tsconfig.json index 90d743e771..dd523305d8 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/server/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/server/tsconfig.json @@ -3,23 +3,15 @@ "compilerOptions": { // Overriding this until we implement more complete TypeScript support. "strict": false, - // When left unspecified, the 'rootDir' defaults to the longest common path of - // all non-declaration input files. TypeScript mimics the source structure - // inside the output directory (i.e., 'dist'). + + // This property currently doesn't matter because we haven't been running + // TSC on server code since https://github.com/wasp-lang/wasp/pull/1714. // - // Since Wasp apps can (but don't have to) import user files from - // '../../../src', it makes the rootDir's default value inconsistent: - // - When the app doesn't import user files (e.g., the user didn't specify - // any operations), the rootDir is set to the server source dir (/src). - // - When the app imports user files (as is the case for most Wasp apps), - // the rootDir is set to the Wasp project root (../../../). - // - // Our build script (in package.json) requires a consistent structure of - // the output directory, which is why we always make sure to point the rootDir - // to the Wasp project root (../../../). - // - // See this comment for more details: https://github.com/wasp-lang/wasp/pull/1584#discussion_r1404019301 - "rootDir": "../../../", + // When we start running TSC again (after we fix all current errors and + // make project references work for the TS config), then I believe the + // correct configuration is "rootDir": "." (the project reference should + // take care of the user code), but we should double-check. + "rootDir": ".", // Overriding this because we want to use top-level await "module": "esnext", "target": "es2017", @@ -35,5 +27,8 @@ }, "include": [ "src" + ], + "references": [ + { "path": "../../../tsconfig.json" } ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.app.json b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.app.json new file mode 100644 index 0000000000..e7688c01f8 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.app.json @@ -0,0 +1,20 @@ +{ + "extends": "@tsconfig/vite-react/tsconfig.json", + "compilerOptions": { + // Temporary loosen the type checking until we can address all the errors. + "jsx": "preserve", + "allowJs": true, + "strict": false, + "skipLibCheck": true, + // Allow importing pages with the .tsx extension. + "allowImportingTsExtensions": true, + "noEmit": true, + }, + "include": [ + "src" + ], + "references": [ + // TODO: It would be better to inject this knowledge from Haskell. + { "path": "../../../tsconfig.json" } + ] +} diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.json b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.json index 4e7d14e1cd..c529e779ec 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.json @@ -1,19 +1,7 @@ { - "extends": "@tsconfig/vite-react/tsconfig.json", - "compilerOptions": { - // Temporary loosen the type checking until we can address all the errors. - "jsx": "preserve", - "allowJs": true, - "strict": false, - // Allow importing pages with the .tsx extension. - "allowImportingTsExtensions": true, - }, - "include": [ - "src" - ], + "files": [], "references": [ - { - "path": "./tsconfig.node.json" - } + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" }, ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.node.json b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.node.json index d90bb30d80..2ae4a16a9c 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.node.json +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.node.json @@ -2,9 +2,13 @@ "compilerOptions": { "composite": true, "skipLibCheck": true, + "noEmit": true, "module": "ESNext", "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] -} + "include": [ + "vite.config.ts", + "./src/ext-src/vite.config.ts" + ] +} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/tsconfig.json b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/tsconfig.json index 4932b229a0..506b0e2fc1 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/tsconfig.json @@ -1,11 +1,18 @@ // =============================== IMPORTANT ================================= +// This file is mainly used for Wasp IDE support. // -// This file is only used for Wasp IDE support. You can change it to configure -// your IDE checks, but none of these options will affect the TypeScript -// compiler. Proper TS compiler configuration in Wasp is coming soon :) +// Wasp will compile your code with slightly different (less strict) compilerOptions. +// You can increase the configuration's strictness (e.g., by adding +// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by +// adding "strict": false). Just keep in mind that this will only affect your +// IDE support, not the actual compilation. +// +// Full TypeScript configurability is coming very soon :) { "compilerOptions": { "module": "esnext", + // Needed because this is used as a project reference. + "composite": true, "target": "esnext", // We're bundling all code in the end so this is the most appropriate option, // it's also important for autocomplete to work properly. @@ -20,6 +27,7 @@ "dom.iterable", "esnext" ], + "skipLibCheck": true, "allowJs": true, "typeRoots": [ // This is needed to properly support Vitest testing with jest-dom matchers. @@ -32,10 +40,9 @@ // Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843 "node_modules/@types" ], - // Since this TS config is used only for IDE support and not for - // compilation, the following directory doesn't exist. We need to specify - // it to prevent this error: - // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file - "outDir": ".wasp/phantom" - } + "outDir": ".wasp/out/user" + }, + "include": [ + "src" + ] } diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest b/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest index cba21bfafc..c12865a23b 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest @@ -249,6 +249,7 @@ waspMigrate/.wasp/out/web-app/src/router.tsx waspMigrate/.wasp/out/web-app/src/test/vitest/setup.ts waspMigrate/.wasp/out/web-app/src/utils.js waspMigrate/.wasp/out/web-app/src/vite-env.d.ts +waspMigrate/.wasp/out/web-app/tsconfig.app.json waspMigrate/.wasp/out/web-app/tsconfig.json waspMigrate/.wasp/out/web-app/tsconfig.node.json waspMigrate/.wasp/out/web-app/vite.config.ts diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums index 78f9ba7f9a..3586d95752 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums @@ -529,7 +529,7 @@ "file", "server/tsconfig.json" ], - "bc6ba637ac3b2e0cbe9a8d01311fa87c7ba9394148246925c6ff9d562b59e6d1" + "622813a50faf658cd240456ce60406209b8f2c2d15669fcf83ad9566750d67e1" ], [ [ @@ -678,19 +678,26 @@ ], "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5" ], + [ + [ + "file", + "web-app/tsconfig.app.json" + ], + "5262d9e2187938464703a1a414250eb137478e4a7004a95a0a47c26b63313522" + ], [ [ "file", "web-app/tsconfig.json" ], - "dfeee6d883ed2504c149c64b24ca939c0ad4812b78bfdced7293a386a008effd" + "0f84a09c31c7cca7d2bed4fac04c3da0ce54b0996ab80b2b54f1a6a53e6fd139" ], [ [ "file", "web-app/tsconfig.node.json" ], - "30fed1f6aa4710deb690d1ae47628066f34afda7b633f0c696fafcda9e2dbc1e" + "ed42a259d45429569d3c5182e40e008b4c2bffd9c49a643019e8542035d21b7c" ], [ [ diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/server/tsconfig.json b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/server/tsconfig.json index 90d743e771..dd523305d8 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/server/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/server/tsconfig.json @@ -3,23 +3,15 @@ "compilerOptions": { // Overriding this until we implement more complete TypeScript support. "strict": false, - // When left unspecified, the 'rootDir' defaults to the longest common path of - // all non-declaration input files. TypeScript mimics the source structure - // inside the output directory (i.e., 'dist'). + + // This property currently doesn't matter because we haven't been running + // TSC on server code since https://github.com/wasp-lang/wasp/pull/1714. // - // Since Wasp apps can (but don't have to) import user files from - // '../../../src', it makes the rootDir's default value inconsistent: - // - When the app doesn't import user files (e.g., the user didn't specify - // any operations), the rootDir is set to the server source dir (/src). - // - When the app imports user files (as is the case for most Wasp apps), - // the rootDir is set to the Wasp project root (../../../). - // - // Our build script (in package.json) requires a consistent structure of - // the output directory, which is why we always make sure to point the rootDir - // to the Wasp project root (../../../). - // - // See this comment for more details: https://github.com/wasp-lang/wasp/pull/1584#discussion_r1404019301 - "rootDir": "../../../", + // When we start running TSC again (after we fix all current errors and + // make project references work for the TS config), then I believe the + // correct configuration is "rootDir": "." (the project reference should + // take care of the user code), but we should double-check. + "rootDir": ".", // Overriding this because we want to use top-level await "module": "esnext", "target": "es2017", @@ -35,5 +27,8 @@ }, "include": [ "src" + ], + "references": [ + { "path": "../../../tsconfig.json" } ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.app.json b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.app.json new file mode 100644 index 0000000000..e7688c01f8 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.app.json @@ -0,0 +1,20 @@ +{ + "extends": "@tsconfig/vite-react/tsconfig.json", + "compilerOptions": { + // Temporary loosen the type checking until we can address all the errors. + "jsx": "preserve", + "allowJs": true, + "strict": false, + "skipLibCheck": true, + // Allow importing pages with the .tsx extension. + "allowImportingTsExtensions": true, + "noEmit": true, + }, + "include": [ + "src" + ], + "references": [ + // TODO: It would be better to inject this knowledge from Haskell. + { "path": "../../../tsconfig.json" } + ] +} diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.json b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.json index 4e7d14e1cd..c529e779ec 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.json @@ -1,19 +1,7 @@ { - "extends": "@tsconfig/vite-react/tsconfig.json", - "compilerOptions": { - // Temporary loosen the type checking until we can address all the errors. - "jsx": "preserve", - "allowJs": true, - "strict": false, - // Allow importing pages with the .tsx extension. - "allowImportingTsExtensions": true, - }, - "include": [ - "src" - ], + "files": [], "references": [ - { - "path": "./tsconfig.node.json" - } + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" }, ] -} \ No newline at end of file +} diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.node.json b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.node.json index d90bb30d80..2ae4a16a9c 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.node.json +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.node.json @@ -2,9 +2,13 @@ "compilerOptions": { "composite": true, "skipLibCheck": true, + "noEmit": true, "module": "ESNext", "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] -} + "include": [ + "vite.config.ts", + "./src/ext-src/vite.config.ts" + ] +} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/tsconfig.json b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/tsconfig.json index 4932b229a0..506b0e2fc1 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/tsconfig.json @@ -1,11 +1,18 @@ // =============================== IMPORTANT ================================= +// This file is mainly used for Wasp IDE support. // -// This file is only used for Wasp IDE support. You can change it to configure -// your IDE checks, but none of these options will affect the TypeScript -// compiler. Proper TS compiler configuration in Wasp is coming soon :) +// Wasp will compile your code with slightly different (less strict) compilerOptions. +// You can increase the configuration's strictness (e.g., by adding +// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by +// adding "strict": false). Just keep in mind that this will only affect your +// IDE support, not the actual compilation. +// +// Full TypeScript configurability is coming very soon :) { "compilerOptions": { "module": "esnext", + // Needed because this is used as a project reference. + "composite": true, "target": "esnext", // We're bundling all code in the end so this is the most appropriate option, // it's also important for autocomplete to work properly. @@ -20,6 +27,7 @@ "dom.iterable", "esnext" ], + "skipLibCheck": true, "allowJs": true, "typeRoots": [ // This is needed to properly support Vitest testing with jest-dom matchers. @@ -32,10 +40,9 @@ // Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843 "node_modules/@types" ], - // Since this TS config is used only for IDE support and not for - // compilation, the following directory doesn't exist. We need to specify - // it to prevent this error: - // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file - "outDir": ".wasp/phantom" - } + "outDir": ".wasp/out/user" + }, + "include": [ + "src" + ] } diff --git a/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/tsconfig.json b/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/tsconfig.json index 4932b229a0..506b0e2fc1 100644 --- a/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/tsconfig.json +++ b/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/tsconfig.json @@ -1,11 +1,18 @@ // =============================== IMPORTANT ================================= +// This file is mainly used for Wasp IDE support. // -// This file is only used for Wasp IDE support. You can change it to configure -// your IDE checks, but none of these options will affect the TypeScript -// compiler. Proper TS compiler configuration in Wasp is coming soon :) +// Wasp will compile your code with slightly different (less strict) compilerOptions. +// You can increase the configuration's strictness (e.g., by adding +// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by +// adding "strict": false). Just keep in mind that this will only affect your +// IDE support, not the actual compilation. +// +// Full TypeScript configurability is coming very soon :) { "compilerOptions": { "module": "esnext", + // Needed because this is used as a project reference. + "composite": true, "target": "esnext", // We're bundling all code in the end so this is the most appropriate option, // it's also important for autocomplete to work properly. @@ -20,6 +27,7 @@ "dom.iterable", "esnext" ], + "skipLibCheck": true, "allowJs": true, "typeRoots": [ // This is needed to properly support Vitest testing with jest-dom matchers. @@ -32,10 +40,9 @@ // Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843 "node_modules/@types" ], - // Since this TS config is used only for IDE support and not for - // compilation, the following directory doesn't exist. We need to specify - // it to prevent this error: - // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file - "outDir": ".wasp/phantom" - } + "outDir": ".wasp/out/user" + }, + "include": [ + "src" + ] } diff --git a/waspc/examples/todoApp/tsconfig.json b/waspc/examples/todoApp/tsconfig.json index 4932b229a0..506b0e2fc1 100644 --- a/waspc/examples/todoApp/tsconfig.json +++ b/waspc/examples/todoApp/tsconfig.json @@ -1,11 +1,18 @@ // =============================== IMPORTANT ================================= +// This file is mainly used for Wasp IDE support. // -// This file is only used for Wasp IDE support. You can change it to configure -// your IDE checks, but none of these options will affect the TypeScript -// compiler. Proper TS compiler configuration in Wasp is coming soon :) +// Wasp will compile your code with slightly different (less strict) compilerOptions. +// You can increase the configuration's strictness (e.g., by adding +// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by +// adding "strict": false). Just keep in mind that this will only affect your +// IDE support, not the actual compilation. +// +// Full TypeScript configurability is coming very soon :) { "compilerOptions": { "module": "esnext", + // Needed because this is used as a project reference. + "composite": true, "target": "esnext", // We're bundling all code in the end so this is the most appropriate option, // it's also important for autocomplete to work properly. @@ -20,6 +27,7 @@ "dom.iterable", "esnext" ], + "skipLibCheck": true, "allowJs": true, "typeRoots": [ // This is needed to properly support Vitest testing with jest-dom matchers. @@ -32,10 +40,9 @@ // Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843 "node_modules/@types" ], - // Since this TS config is used only for IDE support and not for - // compilation, the following directory doesn't exist. We need to specify - // it to prevent this error: - // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file - "outDir": ".wasp/phantom" - } + "outDir": ".wasp/out/user" + }, + "include": [ + "src" + ] } diff --git a/waspc/headless-test/examples/todoApp/todoApp.wasp b/waspc/headless-test/examples/todoApp/todoApp.wasp index 457d46d560..a7c7850339 100644 --- a/waspc/headless-test/examples/todoApp/todoApp.wasp +++ b/waspc/headless-test/examples/todoApp/todoApp.wasp @@ -1,6 +1,6 @@ app todoApp { wasp: { - version: "^0.15.0" + version: "^0.16.0" }, title: "ToDo App", auth: { diff --git a/waspc/headless-test/examples/todoApp/tsconfig.json b/waspc/headless-test/examples/todoApp/tsconfig.json index 4932b229a0..e8f2a3eec6 100644 --- a/waspc/headless-test/examples/todoApp/tsconfig.json +++ b/waspc/headless-test/examples/todoApp/tsconfig.json @@ -1,11 +1,18 @@ // =============================== IMPORTANT ================================= +// This file is mainly used for Wasp IDE support. // -// This file is only used for Wasp IDE support. You can change it to configure -// your IDE checks, but none of these options will affect the TypeScript -// compiler. Proper TS compiler configuration in Wasp is coming soon :) +// Wasp will compile your code with slightly different (less strict) compilerOptions. +// You can increase the configuration's strictness (e.g., by adding +// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by +// adding "strict": false). Just keep in mind that this will only affect your +// IDE support, not the actual compilation. +// +// Full TypeScript configurability is coming very soon :) { "compilerOptions": { "module": "esnext", + // Needed because this is used as a project reference. + "composite": true, "target": "esnext", // We're bundling all code in the end so this is the most appropriate option, // it's also important for autocomplete to work properly. @@ -20,6 +27,7 @@ "dom.iterable", "esnext" ], + "skipLibCheck": true, "allowJs": true, "typeRoots": [ // This is needed to properly support Vitest testing with jest-dom matchers. @@ -32,10 +40,13 @@ // Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843 "node_modules/@types" ], - // Since this TS config is used only for IDE support and not for - // compilation, the following directory doesn't exist. We need to specify - // it to prevent this error: - // https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file - "outDir": ".wasp/phantom" - } + "outDir": ".wasp/out/user", + "paths" : { + "@util": ["./src/util.js"], + "@components/*": ["./src/components/*"], + } + }, + "include": [ + "src" + ] } diff --git a/waspc/src/Wasp/ExternalConfig/TsConfig.hs b/waspc/src/Wasp/ExternalConfig/TsConfig.hs index fe443b9647..a518322af4 100644 --- a/waspc/src/Wasp/ExternalConfig/TsConfig.hs +++ b/waspc/src/Wasp/ExternalConfig/TsConfig.hs @@ -24,6 +24,7 @@ data TsConfig = TsConfig data CompilerOptions = CompilerOptions { _module :: !(Maybe String), target :: !(Maybe String), + composite :: !(Maybe Bool), moduleResolution :: !(Maybe String), jsx :: !(Maybe String), strict :: !(Maybe Bool), diff --git a/waspc/src/Wasp/Generator/ExternalConfig/TsConfig.hs b/waspc/src/Wasp/Generator/ExternalConfig/TsConfig.hs index 7f1ef46628..e76b7ba148 100644 --- a/waspc/src/Wasp/Generator/ExternalConfig/TsConfig.hs +++ b/waspc/src/Wasp/Generator/ExternalConfig/TsConfig.hs @@ -44,7 +44,9 @@ validateSrcTsConfig tsConfig = validateRequiredFieldInCompilerOptions "lib" ["dom", "dom.iterable", "esnext"] T.lib, validateRequiredFieldInCompilerOptions "allowJs" True T.allowJs, validateRequiredFieldInCompilerOptions "typeRoots" ["node_modules/@testing-library", "node_modules/@types"] T.typeRoots, - validateRequiredFieldInCompilerOptions "outDir" ".wasp/phantom" T.outDir + validateRequiredFieldInCompilerOptions "outDir" ".wasp/out/user" T.outDir, + validateRequiredFieldInCompilerOptions "composite" True T.composite, + anyValueIsFine (FieldName ["compilerOptions", "skipLibCheck"]) ] where validateRequiredFieldInCompilerOptions fieldName expectedValue getFieldValue = case fieldValue of @@ -62,6 +64,9 @@ validateSrcTsConfig tsConfig = showAsJsValue expectedValue ++ "." ] + anyValueIsFine :: FullyQualifiedFieldName -> [String] + anyValueIsFine = const [] + validateFieldValue :: (Eq value, IsJavascriptValue value) => FullyQualifiedFieldName -> value -> value -> [String] validateFieldValue fullyQualifiedFieldName expectedValue actualValue = if actualValue == expectedValue diff --git a/waspc/src/Wasp/Generator/WebAppGenerator.hs b/waspc/src/Wasp/Generator/WebAppGenerator.hs index 2f896c4f4c..83c90afbcb 100644 --- a/waspc/src/Wasp/Generator/WebAppGenerator.hs +++ b/waspc/src/Wasp/Generator/WebAppGenerator.hs @@ -65,6 +65,7 @@ genWebApp spec = do sequence [ genFileCopy [relfile|README.md|], genFileCopy [relfile|tsconfig.json|], + genFileCopy [relfile|tsconfig.app.json|], genFileCopy [relfile|tsconfig.node.json|], genFileCopy [relfile|netlify.toml|], genPackageJson spec (npmDepsForWasp spec), diff --git a/waspc/waspc.cabal b/waspc/waspc.cabal index 2d22d2fd79..d8af354554 100644 --- a/waspc/waspc.cabal +++ b/waspc/waspc.cabal @@ -6,7 +6,7 @@ cabal-version: 2.4 -- Consider using hpack, or maybe even hpack-dhall. name: waspc -version: 0.15.2 +version: 0.16.0 description: Please see the README on GitHub at homepage: https://github.com/wasp-lang/wasp/waspc#readme bug-reports: https://github.com/wasp-lang/wasp/issues @@ -304,6 +304,7 @@ library Wasp.Generator.NpmInstall Wasp.Generator.NpmInstall.Common Wasp.Generator.NpmInstall.InstalledNpmDepsLog + Wasp.Generator.ImportPathAlias Wasp.Generator.SdkGenerator Wasp.Generator.SdkGenerator.Auth.AuthFormsG Wasp.Generator.SdkGenerator.Auth.EmailAuthG