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

webdriverio $ conflict with jquery $ #30313

Closed
4 tasks done
NiGhTTraX opened this issue Nov 6, 2018 · 3 comments
Closed
4 tasks done

webdriverio $ conflict with jquery $ #30313

NiGhTTraX opened this issue Nov 6, 2018 · 3 comments

Comments

@NiGhTTraX
Copy link

Running tsc (npm run build) in https://github.com/NiGhTTraX/react-cosmos-proxy-buffet:

node_modules/@types/jquery/misc.d.ts:4990:15 - error TS2451: Cannot redeclare block-scoped variable '$'.

4990 declare const $: JQueryStatic;
                   ~

  node_modules/@types/webdriverio/index.d.ts:1919:18
    1919 declare function $(selector: string): WebdriverIO.Client<WebdriverIO.RawResult<WebdriverIO.Element>> & WebdriverIO.RawResult<WebdriverIO.Element>;
                          ~
    '$' was also declared here.

node_modules/@types/webdriverio/index.d.ts:1919:18 - error TS2451: Cannot redeclare block-scoped variable '$'.

1919 declare function $(selector: string): WebdriverIO.Client<WebdriverIO.RawResult<WebdriverIO.Element>> & WebdriverIO.RawResult<WebdriverIO.Element>;
                      ~

  node_modules/@types/jquery/misc.d.ts:4990:15
    4990 declare const $: JQueryStatic;
                       ~
    '$' was also declared here.

node_modules/@types/webdriverio/index.d.ts:1920:18 - error TS2451: Cannot redeclare block-scoped variable '$'.

1920 declare function $<P>(selector: string): WebdriverIO.Client<P>;
                      ~

  node_modules/@types/jquery/misc.d.ts:4990:15
    4990 declare const $: JQueryStatic;
                       ~
    '$' was also declared here.
@NiGhTTraX
Copy link
Author

Sorry for the ping, but have the authors seen this? @nmalaguti @timbru31 @daveparslow

Since I'm actually not using both jquery and webdriverio at the same time, is there any way to disable the @types/jquery package through tsconfig.json (I could have a separate config for the test files).

@daveparslow
Copy link
Contributor

From a webdriver.io perspective, it is by design as it does have a global $ which is not the same as the jQuery $.

This is a TypeScript question (https://github.com/Microsoft/TypeScript/) about conflicting types, but I can give pointers. Yes, It is pretty typical to have separate config for test files although you typically might want your test config to extend your base tsconfig for your project and then just exclude jQuery and use ---traceResolution with the TypesScript compile if you are not sure why jQuery is getting included. For details you can search TypeScript issues such as this one microsoft/TypeScript#22331

@uniqueiniquity
Copy link
Contributor

See #32490

NiGhTTraX added a commit to NiGhTTraX/react-connect-state that referenced this issue Feb 19, 2019
This is to avoid
DefinitelyTyped/DefinitelyTyped#30313.

According to the TS docs:

> Keep in mind that automatic inclusion is only important if you’re
using files with global declarations (as opposed to files declared as
modules). If you use an import "foo" statement, for instance,
TypeScript may still look through node_modules
& node_modules/@types folders to find the foo package.
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

3 participants