Skip to content

How to configure Path aliases with TypeScript in SvelteKit ? #7

Answered by jeblister
jeblister asked this question in Questions
Discussion options

You must be logged in to vote

You have to update two configs: tsconfig and svelte.config.js to define path aliases in SvelteKit. You can use the $lib alias that is provided by SvelteKit by default or create your own aliases.

Here is an example of tsconfig.json and svelte.config.js, those files are based on the (1) and (2) sources below:

// tsconfig.json
{
	"extends": "./.svelte-kit/tsconfig.json",
	"compilerOptions": {
		"allowJs": true,
		"checkJs": true,
		"esModuleInterop": true,
		"forceConsistentCasingInFileNames": true,
		"resolveJsonModule": true,
		"skipLibCheck": true,
		"sourceMap": true,
		"strict": false,
		// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
		"paths": {
			"$src":…

Replies: 1 comment

Comment options

jeblister
Mar 13, 2023
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by jeblister
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant