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

Intellisense shows non existent errors (double created variables) #112

Open
gsicilia82 opened this issue Jan 4, 2023 · 4 comments
Open

Comments

@gsicilia82
Copy link

Describe the bug
Intellisense shows error messages if variables with same names are declared in multiple scripts.

To Reproduce
Create two scripts with same variable names. Not all double declared variables are shown as an error. I got two copies from same script, but not all variables are marked as double-created.

Expected behavior
There should not be errors at all

Screenshots
image

Version information (please complete the following information):

  • Extension version: 1.2.0
  • VS Code version: 1.74.2
  • ioBroker admin version: 6.3.5
  • ioBroker nodejs version: 16.19.0
  • ioBroker javascript adapter version: 6.1.4
@nokxs
Copy link
Owner

nokxs commented Jan 14, 2023

I know of the issue, but I don't know how to resolve it. The problem appears, because of the include settings in tsconfig.json. If the include is specified like this

  "include": [
    "scripts/global/**/*.js",
    "scripts/global/**/*.ts",
    ".iobroker/types/javascript.d.ts"
  ],

then the compiler does not compile the script at all and all defintions defined in javascript.d.ts are not found. This leads to squiggles for every iobroker definied function.

My solution for this problem is using an anonymous function in every script, which is directly executed. Example:

(() => {
   // Add your code in here
})();

This approach is more like a workarround, but for its a good enough solution.

@gsicilia82
Copy link
Author

Unfortunately, I am not a pro about these kind of "deep" topics. Therefore, I cannot help about further workarounds. Maybe, some ioBroker experts could help?

@nokxs
Copy link
Owner

nokxs commented Mar 8, 2023

I just found out about Project References in Typescript: https://www.typescriptlang.org/docs/handbook/project-references.html

These might be the solution to the problem, but I'm not sure about it yet. If I find some time I will have a deeper look into the topic.

@gsicilia82
Copy link
Author

It would be really appreciated. At the moment I don't like to use vscode cause of this intellisense issue.

Thanks for your effort.

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