Intellisense for Javascript in VSCode not working - javascript

I have been searching the web for a answer but cant find it. In vscode i cant get intellisense for javascript working.
Example:
var name = "test";
var name.to.... here i want it to suggest touppercase, but nothing is happening.
Any good suggestions about fixing this?

make sure the language selected is set to javaScript. when the file extension is .js it's automatically set the lang to js. if your file does not have the .js extension you just need to set it manually in the bottom bar.
docs

Had a situation today, s1 has intellisense, but s2 has Not
adding 'let' to s2 fixed the issue, maybe a scoped variable can help VS code infer the type & provide intellisense.

Related

How to utilize a JavaScript library (jsPDF)

Some Background:
I've been looking for a way to programmatically create a pdf from a collection of images. It’s possible to do 90% of what I need through Word automation, but the problem is you can’t disable JPEG conversion when exporting to a PDF. Originally, I had hoped there’d be a free command line utility out there, but that’s not the case.
The best thing I could find is the JavaScript library jsPDF. I know almost nothing about Javascript, but library seems easy enough to use from the documentation.
This page has an extremely basic example of using JavaScript with VBA. Sadly there’s very little information out there on doing this kind of thing.
The only relevant thing I could find on Stackoverflow is this one unresolved post. I attempted the same method here and not surprisingly, it didn’t work. I get an error stating saying “syntax error” on the add code line.
Sub PDF1()
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim script As String
script = fso.OpenTextFile("***\jsPDF-master\src\jspdf.js", 1, False).ReadAll
‘This requires a reference to Microsoft Script Control 1.0
Dim o As New ScriptControl
o.Language = "JScript"
With o
.AddCode script
End With
End Sub
I really doubt this is the right approach. The entire library is probably 20k+ lines of code. Is what I’m trying to do even possible?
Any help would be greatly appreciated. Any other suggestions of alternate methods creating PDFs would also be helpful.

Getting Netbeans autocomplete working for a JavaScript project with lots of classes as includes

I have a project in Netbeans 8.0 with around 12 javascript includes. When in one JavaScript class file, if I instantiate another custom class from the project and press "." after the var name, it does not pop up any autocompletes with my member variables and methods from my classes in the project.
Example: in one javascript file have a class like :
class Person(){
doStuff(){
// sh happens
}
}
and in another javascript include, (both of which are included in index.html as the project's main URL in the project properties) try to reference it mid-code like...
class StaffManager(){
manageStuff(){
var aPerson = new Person();
aPerson.doSt ;/* BY THIS TIME AUTOCOMPLETE SHOULD BE SAYING "doStuff()" right? (I had to add the semicolon for stack overflow not to throw err)*/
}
}
Look at the commment, that's where you stop typing because autocomplete is giving you options from the class... or so it did in my old IDE's.
Is this supposed to work in Netbeans? Or what did I miss?
Do I need to start some kind of class path declaration? (can't it just parse my project?)
Does it parse "new ___()" to reference classes for autocomplete or is there any way to type cast vars that makes autocomplete work?
I'm new to OOP application development in javascript using Netbeans, and am missing something pretty game-changing for rapidly developing software: proper auto complete for custom classes. I'm assuming it MUST do this, as so many other IDEs do, but if not please also feel free to suggest how easy it can be in other IDEs that do this auto-magically.
Thank You.
First you can try to import your Person object via the ES2015 import.
So import * from Person or smth like that. This is, maybe a better way if it is possible on your enviroment. And than you can see, whether it is working or not.
If not feel free to create a ticket here please, with steps to reproduce and maybe a little sample project: https://issues.apache.org/jira/projects/NETBEANS. Would be help a lot. I think it should work, I can test it later too.
Thx :)
Update:
Apparently what I want to do with these classes is only in the ES6 spec that may not have been supported until maybe Netbeans 8.2, I found this article highlighting a bunch of E6 syntax additions to the editor that are right up this alley.
This came out last year (2016) so I don't know how I missed the memo. I've been coding valid programming with no autocomplete and red underlined error flags for too long! If you are doing ES6 and are using Netbeans 8.1 or older you should definitely upgrade asap!
Here's the reference to that article where it gives some nice examples of new features you can do in editor in 8.2+:
https://jaxenter.com/netbeans/ecmascript-6-lands-in-netbeans-ide

Searching good JavaScript formatter for eclipse

I am using eclipse as my IDE but I don't like the installed formatters. I also builded my own one but didn't get it to work like I want it to. For example things like that happen often:
Is there somebody out there with a good JavaScript formatter or a link with a list of some. I only found a few (e.g. the google formatter) but I don't like one of them.
Try changing the formatting preferences individually.
Window->Preferences->JavaScript->Code Style->Formatter
You'll have to save them as a new file. The only issue i have is that the object declaration won't use tabs instead of spaces for the property declarations.

How do I create a folder using ExtendScript?

This seems like it would be a very easy problem to solve, but I've been banging my head against it for almost an hour. All I need is a snippet of javascript/extendscript code so that my InDesign CS6 script can create a folder. I know the existing folder in which the new one should be created, and I know the name that this new folder should be called. But how do I get javascript to do it?
By the way, all searches online for the folderObj.create() method, which is in the JavaScript Tools Guide, prove useless. I've tried several variations on that method, but nothing seems to actually create the folder. What am I missing?
var f = new Folder('/c/myfolder/');
if (!f.exists)
f.create();
Okay, found a work-around: I have to specify the folder absolutely, rather than use the ~ home shortcut. In addition, I have use /Volumes at the very beginning. Thus, the code becomes:
var f = new Folder("/Volumes/apache HD/Users/apache/Desktop/my_new_fodler");
f.create();
And that seems to work, finally. Thanks for your help, #Anna Forrest and #fabiantheblind! (You seem to be the resident ExtendScript expert around here.)
try this:
var f = new Folder("~/Desktop/my_new_fodler");
f.create();

Require() function in JavaScript

When I open console of Chrome 14 and type...
require (or require(), if that matters)
I get: ReferenceError.
This means that JavaScript doesn't have that function by default, right? At least on web browsers.
Why I'm talking about that?
I needed Markdown parser for JavaScript.
What to do?
I, as usually, opened GitHub and searched for it. The first results that matched my needs was this and this.
Usually (I'm not that good with JavaScript) I include script I want to use before my code using <script /> tag and then... well - use it. But this time I don't get what's happening... :(
Usage for #1 script:
var input = "# Heading\n\nParagraph";
var output = require( "markdown" ).toHTML( input );
print( output );
Usage for #2 script:
var marked = require('marked');
console.log(marked('i am using __markdown__.'));
Where does that require() came from? Thanks in an advice! :)
It's a way to include node.js packages. Luckily, the first package you linked to, markdown-js, is very smart. It checks whether it is included as a node package, and if not, will set the markdown object to window.markdown. So all you have to do is include this file in a <script> tag and you should be able to use the markdown object from the global scope.
From the page you link to:
The simple way to use it with CommonJS is:
Looks like require comes from CommonJS

Categories

Resources