A base TypeScript configuration for working with Svelte applications.
npx @tessl/cli install tessl/npm-tsconfig--svelte@5.0.0@tsconfig/svelte provides a foundational TypeScript configuration specifically tailored for Svelte applications. It contains compiler options optimized for Svelte development including ESNext module settings, bundler module resolution, ES2017 target compatibility, and verbatim module syntax to properly handle Svelte's preprocessing requirements.
npm install --save-dev @tsconfig/svelte or yarn add --dev @tsconfig/svelteThis package is used by extending it in your project's tsconfig.json:
{
"extends": "@tsconfig/svelte/tsconfig.json"
}{
"extends": "@tsconfig/svelte/tsconfig.json",
"compilerOptions": {
// Additional project-specific compiler options can be added here
"baseUrl": ".",
"paths": {
"$lib": ["src/lib"],
"$lib/*": ["src/lib/*"]
}
},
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"]
}Provides a base TypeScript configuration that can be extended in Svelte projects, incorporating all necessary compiler options for optimal Svelte development.
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Svelte",
"_version": "5.0.0",
"compilerOptions": {
"module": "esnext",
"moduleResolution": "bundler",
"target": "es2017",
"verbatimModuleSyntax": true,
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
}
}Configures TypeScript to use modern ECMAScript modules with bundler-style resolution, optimized for Svelte's build process.
{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "bundler"
}
}"esnext" for modern ES module support"bundler" for build tool compatibilitySets the ECMAScript target version for broad browser compatibility while maintaining modern language features.
{
"compilerOptions": {
"target": "es2017"
}
}"es2017" for compatibility with modern browsers while supporting async/await and other ES2017 featuresIncludes configuration options specifically required for proper Svelte preprocessing and type checking.
{
"compilerOptions": {
"verbatimModuleSyntax": true,
"sourceMap": true
}
}true to enforce explicit import type syntax, required because Svelte Preprocess cannot distinguish between values and typestrue to enable source maps for accurate debugging with Svelte compiler warnings/errorsEnables TypeScript's strict mode and interoperability options for robust type safety.
{
"compilerOptions": {
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
}
}true to enable all strict type checking optionstrue for seamless integration between CommonJS and ES modulestrue to skip type checking of declaration files for faster compilation/// <reference types="svelte" /> to a .d.ts file or entry file to prevent TypeScript errors// TypeScript Configuration Schema (for reference)
interface TSConfig {
$schema?: string;
display?: string;
_version?: string;
compilerOptions?: {
module?: "esnext" | "commonjs" | "amd" | "system" | "umd" | "es6" | "es2015" | "es2020" | "es2022" | "node16" | "nodenext";
moduleResolution?: "node" | "classic" | "bundler";
target?: "es3" | "es5" | "es6" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "esnext";
verbatimModuleSyntax?: boolean;
sourceMap?: boolean;
strict?: boolean;
esModuleInterop?: boolean;
skipLibCheck?: boolean;
// Additional compiler options can be specified
[key: string]: any;
};
// Standard tsconfig.json properties
include?: string[];
exclude?: string[];
files?: string[];
extends?: string | string[];
}