1.9 KiB
1.9 KiB
TypeScript Configuration Guide
Common TypeScript Configuration Issues
Deprecated Options
TypeScript has removed some options in newer versions:
importsNotUsedAsValues: Removed in TypeScript 5.0preserveValueImports: Removed in TypeScript 5.0
These should be replaced with:
verbatimModuleSyntax: This is the recommended replacement
How to Fix Configuration Errors
If you see errors like:
Option 'importsNotUsedAsValues' has been removed. Please remove it from your configuration.
Use 'verbatimModuleSyntax' instead.
Option 'preserveValueImports' has been removed. Please remove it from your configuration.
Use 'verbatimModuleSyntax' instead.
Quick Fix
Run our provided helper script:
node fix-sveltekit-tsconfig.js
This will automatically fix the SvelteKit-generated configuration files.
Manual Fix
- Open the
.svelte-kit/tsconfig.jsonfile - Remove the
importsNotUsedAsValuesandpreserveValueImportsentries - Add
"verbatimModuleSyntax": trueto the compilerOptions
Using our Custom Configuration
We've created a fixed base configuration file:
tsconfig.sveltekit-fixed.json: This contains a pre-fixed version of SvelteKit's configuration
Our main tsconfig.json extends this fixed version.
Build Issues with TypeScript
If you encounter build issues with TypeScript trying to emit files over existing JavaScript files:
- Add
"noEmit": trueto your compilerOptions - Make sure you have proper
includeandexcludesettings:
"include": ["src/**/*.js", "src/**/*.ts", "src/**/*.svelte"],
"exclude": ["node_modules", "build", "dist", ".svelte-kit"]
This ensures TypeScript only checks files but doesn't try to output over them.