sveltejs / sveltejs/kit

option to configure the location of `tsconfig.json`

Open
#7,444 5 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

types / typescript
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

i keep my tsconfig.json for svelte in a different location so i can have different tsconfigs for different parts of my project that are recognised by my IDE:

my-project/
├── src/
│   ├── routes/
│   │   └── +page.svelte
│   └── tsconfig.json // for typechecking the source code, DOES extend ./.svelte-kit/tsconfig.json
├── tests/
│   ├── test.ts
│   └── tsconfig.json // for typechecking the tests, DOES NOT extend ./.svelte-kit/tsconfig.json
├── .eslintrc.cjs
├── svelte.config.js
├── playwright.config.ts
├── tsconfig.json // for typechecking the config files, DOES NOT extend ./.svelte-kit/tsconfig.json
└── vite.config.ts

but when running vite build, i think it's using the top level tsconfig.json which is not intended to be used on the svelte code, resulting in the following warning:

> vite build

Your tsconfig.json should extend the configuration generated by SvelteKit:
{
  "extends": "./.svelte-kit/tsconfig.json"
}

i attempted to specify the tsconfig path in svelte.config.js with the preprocess property but it didn't work:

import adapter from '@sveltejs/adapter-auto'
import preprocess from 'svelte-preprocess'

/** @type {import('@sveltejs/kit').Config} */
const config = {
    preprocess: preprocess({
        typescript: { tsconfigFile: './src/tsconfig.json' },
    }),
    kit: {
        adapter: adapter(),
    },
}
export default config
Describe the proposed solution

an option to specify the path to the tsconfig.json file

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the repository's handling of svelte.config.js and the tsconfig.json used by vite build. Compare the root configuration with the proposed src/tsconfig.json and trace where the SvelteKit-generated .svelte-kit/tsconfig.json warning is produced. Done means a configurable path is honored during the build and the intended Svelte configuration no longer triggers that warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
build-system, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.