Skip to content

Missing dependencies in svelte/compiler type definitions #3397

Closed
@luiz

Description

@luiz

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

  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": [
		"test.ts"
	]
}
  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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions