How do I decide whether @types/* goes into `dependencies` or `devDependencies`?

可紊 提交于 2019-11-28 16:16:45

Let's say you're developing a package "A" that have @types/some-module package in devDependencies. For some reason you're exporting the type from @types/some-module

import {SomeType} from 'some-module';
export default class APackageClass {
     constructor(private config: SomeType) {

     }
}

Right now Typescript consumers of package "A" are unable to guess what SomeType is, since devDependencies of package "A" are NOT installed.

In that particular case you NEED to place @types/* package with regular "dependencies". For other cases "devDependencies" are good enough.

Are you generating a bundle? If so, I'd suggest not spending too much time debating what goes where. devDependencies and dependencies are only meaningful if you're publishing a package that can be used by others and you don't want to spam them with useless dependencies.

Place it in devDependencies. Like you said "types are needed for development and aren't used in runtime".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!