Skip to content

Missing dependencies in svelte/compiler type definitions #8544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mattlucock opened this issue Apr 30, 2023 · 2 comments
Closed

Missing dependencies in svelte/compiler type definitions #8544

mattlucock opened this issue Apr 30, 2023 · 2 comments

Comments

@mattlucock
Copy link

mattlucock commented Apr 30, 2023

Describe the bug

Svelte ships with type definitions (types/compiler/index.d.ts and types/compiler/interfaces.d.ts) that reference type definitions from estree and estree-walker. However, Svelte does not ship with these estree type definitions and does not reference them as dependencies, so they don't exist at install time, therefore Svelte's type definitions are broken. This hinders me in running the TypeScript compiler on my own code, even though this issue has nothing to do with me.

node_modules/.pnpm/[email protected]/node_modules/svelte/types/compiler/index.d.ts:4:22 - error TS2307: Cannot find module 'estree-walker' or its corresponding type declarations.

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

node_modules/.pnpm/[email protected]/node_modules/svelte/types/compiler/interfaces.d.ts:1:53 - error TS2307: Cannot find module 'estree' or its corresponding type declarations.

1 import { AssignmentExpression, Node, Program } from 'estree';

I thought to install @types/estree and estree-walker as a temporary workaround, but even this does not work, because there exists an ESM/CJS incompatibility in the reference to the estree-walker types.

node_modules/.pnpm/[email protected]/node_modules/svelte/types/compiler/index.d.ts:4:22 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("estree-walker")' call instead.

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

This issue was first reported in #3397 in 2019, and was apparently fixed, and then was apparently regressed not too long after, and then was never fixed again. This issue is very much still present.

Reproduction

Any trivial TypeScript setup importing svelte/compiler should reproduce this issue.

Logs

No response

System Info

System:
    OS: macOS 13.3.1
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 31.14 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.0.0 - /usr/local/bin/node
    npm: 9.6.4 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 111.1.49.120
    Chrome: 111.0.5563.110
    Firefox: 111.0
    Safari: 16.4

Severity

annoyance

@xxkl1
Copy link
Contributor

xxkl1 commented May 1, 2023

I think the #3397 (comment) can solve this problem.

@gtm-nayan
Copy link
Contributor

This should've been fixed in version 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants