Skip to content
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

Add @types/enzyme as a dependency #139

Closed
rdsedmundo opened this issue Apr 16, 2019 · 1 comment
Closed

Add @types/enzyme as a dependency #139

rdsedmundo opened this issue Apr 16, 2019 · 1 comment

Comments

@rdsedmundo
Copy link

On the package's typings definitions, enzyme typings are being used, but it's not included as a dependency on the package, so if someone doesn't install @types/enzyme manually, a couple of errors appear.

index.d.ts

/// <reference types="cheerio" />
import {CommonWrapper, ShallowWrapper, ReactWrapper} from 'enzyme';

Sample errors

node_modules/enzyme-to-json/index.d.ts:2:59 - error TS7016: Could not find a declaration file for module 'enzyme'. '/node_modules/enzyme/build/index.js' implicitly has an 'any' type.
  Try `npm install @types/enzyme` if it exists or add a new declaration (.d.ts) file containing `declare module 'enzyme';`

import {CommonWrapper, ShallowWrapper, ReactWrapper} from 'enzyme';
                                                            ~~~~~~~~

node_modules/enzyme-to-json/index.d.ts:31:57 - error TS2304: Cannot find name 'Cheerio'.

31 export declare function toJson(wrapper: CommonWrapper | Cheerio, options?: Options): Json;

I know that someone can just install @types/enzyme and the errors are gone, but the correct thing to do is to include the package as a dependency here, as it's being referenced.

@VincentLanglet
Copy link
Collaborator

Enzyme is a peerDependency. So we should eventually add @types/enzyme as peerDependency too.

But I never saw a @types package as a dependency. If you're just a javascript user, you don't need it. If you're a typescript it's your responsability to install @types package everytime you install a library.

If someone give me one example where @types are set a dependency/peer-dependency, I'll reconsider the question

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

2 participants