Ask questionsMissing 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.
Logs
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
npm init -y
at empty foldernpm i -D svelte typescript
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"outDir": "./build",
"noEmitOnError": true,
"noImplicitAny": true
},
"files": [
"test.ts"
]
}
test.ts
with the following import: import * as svelte from 'svelte/compiler'
npx tsc
Expected behavior I should not need to manually install Svelte's dependencies; compilation should not fail.
Information about your Svelte project:
Severity Annoying. I can manually install Svelte's dependencies into my project.
Answer
questions
Rich-Harris
Is there a way to fix this by adding the types as dependencies, but not the packages?
Related questions