Useful or not, from you.
svelte Missing dependencies in svelte/compiler type definitions

Describe the bug When compiling a Typescript code that uses svelte/compile, it fails because of missing libraries inside Svelte package.


node_modules/svelte/types/compiler/index.d.ts:4:22 - error TS2307: Cannot find module 'estree-walker'.

4 export { walk } from 'estree-walker';

node_modules/svelte/types/compiler/preprocess/index.d.ts:1:27 - error TS2307: Cannot find module 'magic-string'.

1 import { SourceMap } from 'magic-string';

To Reproduce

  1. Create new Node project: npm init -y at empty folder
  2. Install Svelte and Tyepscript: npm i -D svelte typescript
  3. Configure Typescript:
	"compilerOptions": {
		"target": "es2016",
		"module": "commonjs",
		"outDir": "./build",
		"noEmitOnError": true,
		"noImplicitAny": true
	"files": [
  1. Create test.ts with the following import: import * as svelte from 'svelte/compiler'
  2. Run npx tsc

Expected behavior I should not need to manually install Svelte's dependencies; compilation should not fail.

Information about your Svelte project:

  • Svelte: 3.8.0
  • Typescript: 3.5.3

Severity Annoying. I can manually install Svelte's dependencies into my project.

That's a useful answer
Without any help

Is there a way to fix this by adding the types as dependencies, but not the packages?