WebStorm autocomplete for npm modues - javascript

I recently started following a course about Node.js. I have an issue in WebStorm. I am trying to explore the validator module. The autocomplete in WebStorm doesn't give me choices for methods unless I select the default in the drop-down list which is unusual across all programming languages including JS !!! is it an issue and if yes what is the solution?

The problems occur because of the weird way properties are defined.
Normally installing Typescript stubs can be used as a workaround. But this doesn't work for validator due to WEB-43528. Please follow this ticket for updates
Using import validator from "./validator"; instead of require() can be used as a workaround

Related

How do I enable JavaScript type checking in Vue files on Visual Studio Code?

I have found the settings in Visual Studio Code to enable type checking for JavaScript in JS files. Such that: Bad code is highlighted and it also shows the reason why it's bad code
This behavior does not occur for JavaScript code in Vue files. I have searched through all the settings in Visual Studio Code. I have scoured the internet for any extension that can do this for me to no avail.
How can I make my Vue files type-check the JavaScript in them?
LOL. I found the answer.
All I had to do was add //#ts-check directly underneath the script tag and type checking was enabled.
So HAPPY!!!
Thank you, everyone, for your input
For best results I'd suggest starting a new project using vue-cli and selecting the options for TypeScript and ESLint. You'll also need the ESLint extension for VS Code.
Here's a helpful blog post showing the parts of this process.
Once you have a nicely working setup with the clean project, then move the code over. I suggest this because getting all the config right can be a mess with an existing project.

Adding watermark.js to angular 4

Hi I am trying to add watermark to the image and i am trying to include watermark.js to the angular 4. Could someone please tell me how to include watermark.js in angular. I tried installing using
npm install watermark -save
and then using the
import * as watermark from 'watermark';
but the above line throws me an error stating cannot find module 'watermark'
can someone please tell how i can import the watermark.js and use it to watermark my image?
You're missing type definitions for watermark.js. However, judging by this github issue, the authors of this lib currently don't offer them.
You have a couple of possibilities to fix this:
Declare type definition manually. This is the quickest way, but you'll also lose all type safety when it comes to using this lib
Help with creating proper type definitions (as shown in this tutorial). This way you'll be type safe, learn a lot about the TS type system, and, as a bonus, contribute back to the OSS community.
Good luck!

How do I get WebStorm's JavaScript Library support using DefinitelyTyped interface definitions to work?

I'm trying to get WebStorm's JavaScript Library support using DefinitelyTyped TypeScript interface definitions to work as expected (hopefully as intended) in JavaScript.
I've added the library definitions using the Download feature...
I made sure it's in the global scope, too.
Yet I can't seem to reference THREE or any of the other DefinitelyTyped library module definitions.
It's not just undefined inside of JSDoc references, it's undefined everywhere. I know I should have "#type" here instead of "#param", I was just trying to elicit a different result; the results are the same.
What am I doing wrong?
Do I need to create a _references.js as one would for Visual Studio or something?
Restart WebStorm at least twice (possibly four times) after having added the interface definitions. 🤦
This solution applies to WebStorm 2016.2.1

NetBeans IDE no autocomplete due to JSX parsing error [duplicate]

I've just downloaded Netbeans 8.1 for PHP. Based on https://netbeans.org/bugzilla/show_bug.cgi?id=250288 , it appears that there is no native ReactJS/JSX support. Is anyone using this for react. Are there any workarounds? I'm been using Netbeans for years and would hate to have to move to a different IDE.
Well, i'm a Netbeans user too, but because of needs like this, i've switched myself from Netbeans to Sublime (first) and now to Atom for Frontend development and honestly, the workflow is great. I use ReactJS, AngularJS and VueJS, and for all of this Atom fits my needs.
Atom uses packages (like plugins) to support all of this, here's what i use for React:
Atom (https://atom.io/)
React Package (https://atom.io/packages/react)
The package adds:
Syntax highlighting
Snippets
Automatic indentation and folding
JSX Reformatting
HTML to JSX conversion
Autocomplete
Something important to remember is that sometimes Atom uses the wrong syntax highlight for some reason, so, in JSX files just click in the bottom right corner (next to the encoding) and you can select your filetype there (for ReactJS, should be Javascript(JSX)) and everything should be fine :)
I invite you to try it, its a great experience and for backend development (in my case, PHP) Netbeans is way better, from a lot of benefits that in frontend you might not need (the most to me is think is "Go to declaration", which in frontend i don't have/need).
If you want to know what other packages i use that might help you in frontend development just let me know and i'll update this post :)
Good luck!
Try this:
https://blogs.oracle.com/geertjan/entry/react_js_and_netbeans_ide1
It's still in early development but it should do the job.
Support for ReactJS is now included in Netbeans 8.2
source (last post):
https://netbeans.org/bugzilla/show_bug.cgi?id=250778
I personally don't find it satisfactory yet, which brought me to this question....

WebStorm: How to generate JSDoc documentation

I just started using WebStorm and JSDoc to document my JavaScript. Still I have not found a way to generate a HTML documentation using some kind of WebStorm built-in functionality. I searched the web and Stack Overflow, but only found a lot of questions about the syntax of JSDoc, etc.
What am I missing? I am using WebStorm 7.0.3.
Since Webstorm v8.0.0, you can create JSDoc comments by simply typing /** right before the method or function declaration you want to add the documentation, and then press Enter, this will generate a basic block with all your parameters already set.
More info on this Webstorm article.
Nice article about jsDoc for phpStorm at this link.
In WebStorm I guess the same.
WebStorm has no built-in functionality to generate documentation. You can use external solutions for that, at least as https://github.com/jsdoc3/jsdoc
I use jsduck for that: https://github.com/senchalabs/jsduck
WebStorm has a built-in function to help a little when creating JSDoc documentation in your code, they explain it in this article. As far as I could look for, there's no plugin on the WebStorm plugin store to further help us creating nor rendering JSDoc documentation. For that, you would need to use external tools.

Categories

Resources