Skip to content

Uninstalled optional peer dependencies causing error during type check #669

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

Open
BlueGreenMagick opened this issue May 25, 2025 · 0 comments

Comments

@BlueGreenMagick
Copy link

BlueGreenMagick commented May 25, 2025

Describe the bug
Uninstalled optional peer dependencies such as 'pug' causes the following error during type checking with tsc

error TS2307: Cannot find module 'pug' or its corresponding type declarations.

> import type { Options as PugOptions } from 'pug';

This issue did not occur in svelte-preprocess v5.1.4 because @types/pug was installed as a direct dependency. Since v6, that type dependency has been removed, leading to errors when pug is not installed.

The issue is also applicable for other optional peer dependencies, such as @babel/core. Which can be remedied by having @types/babel__core as dependency.

Logs

To Reproduce

  1. With pnpm, create a typescript project with esbuild.config.ts that imports sveltePreprocess.
  2. Make sure that skipLibCheck in tsconfig.json is not set to false.
  3. Run pnpm tsc

Expected behavior
No errors should be thrown when pug is not installed, as it is an optional dependency.

Stacktraces

Information about your project:

  • Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10)

  • Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc)

  • svelte-preprocess version: 6.0.3

  • Whether your project uses Webpack or Rollup:

Additional context

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

1 participant