eslint-plugin-node icon indicating copy to clipboard operation
eslint-plugin-node copied to clipboard

TypeScript import type and node/no-extraneous-import

Open Toilal opened this issue 3 years ago • 1 comments

It seems node/no-extraneous-import should not report when using TypeScript import type ....

import type is used for compilation only, so there's no risk at all to hit runtime errors because of unavailable dependency.

Toilal avatar Feb 27 '22 11:02 Toilal

Note that if you are shipping a package with .d.ts type definition files, then imported types may be necessary for your type declarations to work. This is why many packages with native type definition files have dependencies (not devDependencies) on other type-only packages. For example, Jest has a runtime dependency on @types/node (link). So ultimately, type definition files can only be omitted as dependencies if they are used exclusively in sources that are transpiled (and not included in the build).

fasttime avatar Apr 04 '22 16:04 fasttime