Skip to content

Unused @types files installed by node modules pollutes and breaks the main project #31148

Closed
@falsandtru

Description

@falsandtru

Even when we don't use it in the main project. For instance, I'm using del package only in the build script file and it is .js file not .ts file.

https://github.com/falsandtru/pjax-api/blob/master/gulpfile.js

But it polluted and broke the main project:

https://travis-ci.org/falsandtru/pjax-api/jobs/525654172#L512

This is caused by sindresorhus/del@0361dcc.

You shouldn't automatically include unused/unimported @types files installed by node modules in the compile targets because they usually won't be used when they are not imported explicitly (regardless of direct or indirect). Or you should provide a way to exclude unexpected @types files by tsconfig.json to avoid this problem as a temporary workaround.

TypeScript Version: 3.4.0-dev.20190425

Search Terms:

Code

You can reproduce this problem also with https://github.com/falsandtru/spica.

  1. clone https://github.com/falsandtru/spica
  2. checkout v0.0.247.
  3. run npm i
  4. run npm i [email protected]
  5. run gulp ts:dist

Expected behavior:

pass

Actual behavior:

TypeScript error: src/throttle.ts(7,5): Error TS2322: Type 'Timeout' is not assignable to type 'number'.
TypeScript error: src/throttle.ts(28,5): Error TS2322: Type 'Timeout' is not assignable to type 'number'.

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions