InstantSplit/docs/TYPESCRIPT.md

68 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2025-06-21 23:30:33 +03:00
# TypeScript Configuration Guide
## Common TypeScript Configuration Issues
### Deprecated Options
TypeScript has removed some options in newer versions:
- `importsNotUsedAsValues`: Removed in TypeScript 5.0
- `preserveValueImports`: 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:
```bash
node fix-sveltekit-tsconfig.js
```
This will automatically fix the SvelteKit-generated configuration files.
### Manual Fix
1. Open the `.svelte-kit/tsconfig.json` file
2. Remove the `importsNotUsedAsValues` and `preserveValueImports` entries
3. Add `"verbatimModuleSyntax": true` to 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:
1. Add `"noEmit": true` to your compilerOptions
2. Make sure you have proper `include` and `exclude` settings:
```json
"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.
## References
- [TypeScript 5.0 Release Notes](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/)
- [SvelteKit TypeScript Documentation](https://kit.svelte.dev/docs/typescript)