question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unresolved variable or type `Dropbox`

See original GitHub issue

Before you start Have you checked StackOverflow, previous issues, and Dropbox Developer Forums for help? Yes

What is your question? I’m trying to adjust a JSDoc annotation for Dropbox 6.x.x but face an issue with Dropbox type.

I’m importing Dropbox:

import dropbox from "dropbox";

And then I get a warning «Unresolved variable or type Dropbox»: 30_215746

Is it a Dropbox or IDEA/WebStorm issue?

Versions

  • What version of the SDK are you using? 6.0.2
  • What version of the language are you using? 2020
  • Are you using Javascript or Typescript? JS
  • What platform are you using? (if applicable) Windows, Node.js + NPM

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
rogebrdcommented, Oct 9, 2020

Unfortunately, with the way the SDK is structured, it doesn’t make sense to have a default export. We have two main objects Dropbox which handles all of the main route logic, and DropboxAuth which handles all auth related logic.

What this means in the case of this is that when you import the entire package, you cannot reference it as a default object. However, if you use named imports, you can reference it directly. This example gives no errors and correctly links to the classes when I command+click into them (both JetBrains & VSCode):

import { Dropbox, DropboxAuth } from "dropbox";

/**
 * Dropbox Factory
 * 
 * @function
 * @param {DropboxAuth} DropboxAuth instance
 * @returns {Dropbox} Dropbox instance
 * @private
 */
const factory = function factory(auth){
    const dbx = new Dropbox({
        auth: auth
    });
    return dbx;
};

Still working through the import error when this example is run but from a JSDoc standpoint it should be fine.

From what I understand, there would be no case in which the return variable type would not match the constructor. Meaning if you construct via new Dropbox.Dropbox() then the return JSDoc annotation would be * @return {Dropbox.Dropbox} .... This is because the plain Dropbox object contains the entire package not a default export. If you inspect that object directly, it contains Dropbox and DropboxAuth which is what we expect.

When I try to run this example however:

import Dropbox from "dropbox";

/**
 * Dropbox Factory
 * 
 * @function
 * @param {Dropbox.DropboxAuth} DropboxAuth instance
 * @returns {Dropbox.Dropbox} Dropbox instance
 * @private
 */
const factory = function factory(auth){
    const dbx = new Dropbox.Dropbox({
        auth: auth
    });
    return dbx;
};

I am able to successfully see the class definitions in VSCode and am unable to see them in JetBrains. I added this comment to the ticket you posted above also.

1reaction
rogebrdcommented, Oct 5, 2020

I see, yes we did migrate away from the DropboxTypes because internally it was a mess of local references to itself. I do believe that it should work if you use dropbox.Dropbox, or at least this works in VSCode. I will continue to investigate this issue though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebStorm: unresolved variable or type altough library is loaded
There is a warning 'unresolved variable or type' although the corresponding library 'TweenMax' is loaded like:
Read more >
Automatically defined variables triggering "Unresolved ...
I'm getting errors like this in my nodejs files: "Unresolved variable or type __dirname" node automatically sets that variable, so it should not...
Read more >
I have a problem with connecting Dropbox API to my iOS app ...
For the "Use of undeclared type 'DropboxOAuthCompletion'" and "Use of unresolved ... This screenshot doesn't show where that variable would be set or...
Read more >
Unresolved and Unresolvable? Tensions in the Refugee ...
State interests vis-à-vis refugees are enmeshed with moral values, and are also highly variable, depending in part on historical experience, ...
Read more >
Unresolved reference to CRF in Define.XML - Pinnacle 21
pdf » in the column « Href » of the sheet « Documents ») and I write the corresponding pages in the column...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found