8000 Support tsconfig extending multiple tsconfigs, typescript 5.0 · Issue #9412 · sveltejs/kit · GitHub
[go: up one dir, main page]

Skip to content
Support tsconfig extending multiple tsconfigs, typescript 5.0 #9412
@JeremyMoeglich

Description

@JeremyMoeglich

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0