-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treat user code as a referenced project #2444
Changes from all commits
382dc59
79924a0
4d3f95d
91b6f80
ae5bcaf
7f9e078
2d4c5c9
f390cd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We added this option, but we validate it with |
||
"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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Todo: leave comment why not noEmit. |
||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" }, | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
] | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newline |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": ".", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Link to previous history. |
||
// Overriding this because we want to use top-level await | ||
"module": "esnext", | ||
"target": "es2017", | ||
|
@@ -36,5 +28,8 @@ | |
}, | ||
"include": [ | ||
"src" | ||
], | ||
"references": [ | ||
{ "path": "../../../tsconfig.json" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Todo: draw this knowledge from Haskell. Same thing in package.json. |
||
] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo: explore why doesn't next need this