Skip to content
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

Support tsconfig extending multiple tsconfigs, typescript 5.0 #9412

Closed
JeremyMoeglich opened this issue Mar 12, 2023 · 1 comment · Fixed by #9413
Closed

Support tsconfig extending multiple tsconfigs, typescript 5.0 #9412

JeremyMoeglich opened this issue Mar 12, 2023 · 1 comment · Fixed by #9413

Comments

@JeremyMoeglich
Copy link
Contributor

JeremyMoeglich commented Mar 12, 2023

Describe the bug

If your tsconfig extends multiple other tsconfigs, the build / dev server crashes with the error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array.

This is useful when your in a monorepo with shared compiler options while also extending ./.svelte-kit/tsconfig.json in on of the apps

This feature is introduced in Typescript 5.0

I'll try to fix this in a PR, If I fail I'll comment

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-zk7trz?file=tsconfig.json

The dev server should error out by itself, if it doesn't try npm run build

Logs

> vite build

error during build:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
    at new NodeError (node:internal/errors:399:5)
    at validateString (node:internal/validators:163:11)
    at Object.resolve (node:path:1102:7)
    at validate_user_config (file:///home/jeremy/dev/Web/Tagaro-Web/node_modules/.pnpm/@sveltejs+kit@1.11.0_svelte@3.56.0+vite@4.1.4/node_modules/@sveltejs/kit/src/core/sync/write_tsconfig.js:179:50)
    at write_tsconfig (file:///home/jeremy/dev/Web/Tagaro-Web/node_modules/.pnpm/@sveltejs+kit@1.11.0_svelte@3.56.0+vite@4.1.4/node_modules/@sveltejs/kit/src/core/sync/write_tsconfig.js:45:19)
    at init (file:///home/jeremy/dev/Web/Tagaro-Web/node_modules/.pnpm/@sveltejs+kit@1.11.0_svelte@3.56.0+vite@4.1.4/node_modules/@sveltejs/kit/src/core/sync/sync.js:16:2)
    at Module.all (file:///home/jeremy/dev/Web/Tagaro-Web/node_modules/.pnpm/@sveltejs+kit@1.11.0_svelte@3.56.0+vite@4.1.4/node_modules/@sveltejs/kit/src/core/sync/sync.js:57:2)
    at config (file:///home/jeremy/dev/Web/Tagaro-Web/node_modules/.pnpm/@sveltejs+kit@1.11.0_svelte@3.56.0+vite@4.1.4/node_modules/@sveltejs/kit/src/exports/vite/index.js:291:34)
    at runConfigHook (file:///home/jeremy/dev/Web/Tagaro-Web/node_modules/.pnpm/vite@4.1.4/node_modules/vite/dist/node/chunks/dep-ca21228b.js:62375:31)
    at async resolveConfig (file:///home/jeremy/dev/Web/Tagaro-Web/node_modules/.pnpm/vite@4.1.4/node_modules/vite/dist/node/chunks/dep-ca21228b.js:61876:14)
 ELIFECYCLE  Command failed with exit code 1.

System Info

System:
    OS: Linux 6.2 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 5700X 8-Core Processor
    Memory: 15.49 GB / 31.27 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 19.7.0 - /usr/bin/node
    npm: 9.2.0 - /usr/bin/npm
  Browsers:
    Firefox: 110.0.1

Severity

serious, but I can work around it

Additional Information

The source of this error seems to be

function validate_user_config(kit, cwd, out, config) {
	// we need to check that the user's tsconfig extends the framework config
	const extend = config.options.extends;
	const extends_framework_config = extend && path.resolve(cwd, extend) === out;
        // ...

located in https://github.com/sveltejs/kit/blob/master/packages/kit/src/core/sync/write_tsconfig.js

@JeremyMoeglich JeremyMoeglich changed the title Support tsconfig extending multiple tsconfigs Support tsconfig extending multiple tsconfigs, typescript 5.0 Mar 12, 2023
@JeremyMoeglich
Copy link
Contributor Author

It seems Vite is also affected by this.

Svelte-preprocess, isn't affected by this issue specifically, but typescript 5.0 deprecates importsNotUsedAsValues and throws an error

dummdidumm added a commit that referenced this issue Mar 13, 2023
possible since typescript 5.0
closes #9412

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant