-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: add a default "include": [] array to generated tsconfig.json, and warn if not populated by user config
#16593
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
base: version-3
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@sveltejs/kit': patch | ||
| --- | ||
|
|
||
| fix: add a default `"include": []` array to generated tsconfig.json, and warn if not populated by user config |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,6 +47,7 @@ export function write_tsconfig(kit, root) { | |||||||||
| ...ESSENTIAL_OPTIONS, | ||||||||||
| ...RECOMMENDED_OPTIONS | ||||||||||
| }, | ||||||||||
| include: [], | ||||||||||
| exclude: [kit.files.serviceWorker] | ||||||||||
| }, | ||||||||||
| { | ||||||||||
|
|
@@ -100,13 +101,15 @@ function write_parent_tsconfig(root, dir, id, config, example, transform) { | |||||||||
| const user_config = load_user_tsconfig(dir); | ||||||||||
|
|
||||||||||
| if (user_config && modified_since_last_check(user_config.file)) { | ||||||||||
| const relative = path.relative(process.cwd(), user_config.file); | ||||||||||
|
|
||||||||||
| // now that we've written the parent config, we can resolve the | ||||||||||
| // user config and validate that nothing important was overwritten | ||||||||||
| if (!extends_id(user_config.options, id)) { | ||||||||||
| console.warn( | ||||||||||
| styleText( | ||||||||||
| ['bold', 'yellow'], | ||||||||||
| `${path.relative(process.cwd(), user_config.file)} should extend SvelteKit's built-in configuration:` | ||||||||||
| `${relative} should extend SvelteKit's built-in configuration:` | ||||||||||
| ) | ||||||||||
| ); | ||||||||||
|
|
||||||||||
|
|
@@ -115,8 +118,12 @@ function write_parent_tsconfig(root, dir, id, config, example, transform) { | |||||||||
| return; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const resolved = ts.parseJsonConfigFileContent(user_config.options, ts.sys, dir).options; | ||||||||||
| const warnings = validate_resolved_config(resolved, config.compilerOptions); | ||||||||||
| const resolved = ts.parseJsonConfigFileContent(user_config.options, ts.sys, dir); | ||||||||||
| const warnings = validate_resolved_config(resolved.options, config.compilerOptions); | ||||||||||
|
|
||||||||||
| if (resolved.raw.include?.length === 0) { | ||||||||||
| warnings.push(`Missing "include" array`); | ||||||||||
|
Member
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. This message is not providing enough context and needs actionable advice. And why do we not do
Member
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. Might be because the user should specify those themselves in the root tsconfig.json. If we did it for them, the moment they add a new entry to their root
Member
Author
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. Exactly — it's a lot more visible if it's in their own config. Ideally the CLI would put What about this?
Suggested change
Member
Author
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. Or more verbosely:
Suggested change
(Trying to avoid making things too verbose, because the text wraps in an ugly awkward way if it takes multiple lines)
Member
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. The first is better because technically everything will get type checked when it's missing. Like if you did a build it would type check your build output files. Maybe we can swap the "*" with a "your-directory" or "your-file" |
||||||||||
| } | ||||||||||
|
|
||||||||||
| if (warnings.length > 0) { | ||||||||||
| console.warn( | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "noEmit": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "test", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "resolveJsonModule": true, | ||
| "rewriteRelativeImportExtensions": true | ||
| }, | ||
| "include": ["src", "unit-test", "test", "playwright.config.js"], | ||
| "extends": "$app/tsconfig" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "resolveJsonModule": true | ||
| }, | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "unit-test", "test"] | ||
| "include": ["src", "unit-test", "test", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "resolveJsonModule": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "test", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "noEmit": true, | ||
| "resolveJsonModule": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "test", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "noEmit": true, | ||
| "resolveJsonModule": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "test", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "noEmit": true, | ||
| "resolveJsonModule": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "test", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "noEmit": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "test", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "noEmit": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "test", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "noEmit": true | ||
| }, | ||
| "extends": "$app/tsconfig", | ||
| "include": ["source", "test", "vite.custom.config.js", "playwright.config.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "skipLibCheck": true, | ||
| "sourceMap": true, | ||
| "moduleResolution": "bundler" | ||
| } | ||
| // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias | ||
| // except #lib which is handled by the package.json imports field | ||
| // | ||
| // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes | ||
| // from the referenced tsconfig.json - TypeScript does not merge them in | ||
| "include": ["src", "test", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "noEmit": true, | ||
| "resolveJsonModule": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "test", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "sourceMap": true, | ||
| "noEmit": true | ||
| } | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "sourceMap": true, | ||
| "noEmit": true | ||
| } | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "sourceMap": true, | ||
| "noEmit": true | ||
| } | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "noEmit": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "noEmit": true, | ||
| "rewriteRelativeImportExtensions": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "noEmit": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "noEmit": true | ||
| }, | ||
| "extends": "$app/tsconfig" | ||
| "extends": "$app/tsconfig", | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "sourceMap": true, | ||
| "noEmit": true | ||
| } | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "sourceMap": true, | ||
| "noEmit": true | ||
| } | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "sourceMap": true, | ||
| "noEmit": true | ||
| } | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "sourceMap": true, | ||
| "noEmit": true | ||
| } | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "sourceMap": true, | ||
| "noEmit": true | ||
| } | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "sourceMap": true, | ||
| "noEmit": true | ||
| } | ||
| "include": ["src", "*.js"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,4 @@ | ||
| { | ||
| "extends": "$app/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "resolveJsonModule": true, | ||
| "sourceMap": true, | ||
| "noEmit": true | ||
| } | ||
| "include": ["src", "*.js"] | ||
| } |
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.
If it's completely missing, this would evaluate to
undefined, which doesn't equal 0 - right? Should we just have!resolved.raw.include?.length?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.
Or is this going to be inheriting from the generated one, which has
[]? In which case, why the?.? Is it just because the types can't know that?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.
it's intentional — if
includeis unspecified, everything inside the directory containing thetsconfig.jsonis included. if it's specified-but-empty, as is the case for a user config that extends$app/tsconfig, nothing will be included. i guess this could be clearer