VSCode and JavaScript

17 views
Skip to first unread message

Alan Karp

unread,
Dec 8, 2023, 5:02:50 PM12/8/23
to <friam@googlegroups.com>
Someone suggested installing a TypeScript plugin to VSCode to get better JavaScript error reporting.  I just looked, and there are a gazillion TypeScript plugins.  Which one should I use?

--------------
Alan Karp

Raoul Duke

unread,
Dec 8, 2023, 6:17:56 PM12/8/23
to fr...@googlegroups.com
ironic since both are msft products. 

should be like falling off a rolling log instead

--
You received this message because you are subscribed to the Google Groups "friam" group.
To unsubscribe from this group and stop receiving emails from it, send an email to friam+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/friam/CANpA1Z0FL1GGtQbj710yCATpkqY5dB0Ov1R7S%3D5YMcY-mV%2BbtQ%40mail.gmail.com.

Dan Connolly

unread,
Dec 8, 2023, 7:44:39 PM12/8/23
to fr...@googlegroups.com
On Fri, Dec 8, 2023 at 4:02 PM Alan Karp <alan...@gmail.com> wrote:
Someone suggested installing a TypeScript plugin to VSCode to get better JavaScript error reporting.  I just looked, and there are a gazillion TypeScript plugins.  Which one should I use?

I think the relevant plug-in is built-in.

I suggest taking a look at https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html 

--

Raoul Duke

unread,
Dec 8, 2023, 8:04:21 PM12/8/23
to fr...@googlegroups.com
(er, and would plain old js even get any benefit from ts? since there are no type annotations?)

Kurt Thams

unread,
Dec 8, 2023, 8:04:26 PM12/8/23
to fr...@googlegroups.com, Dan Connolly
TypeScript support is built in. 

I think the question for you would be how do you get your Javascript file to be treated with TypeScript strictness, since VSCode uses the filename extension to determine which type checking to apply.

According to copilot, below is how to do it. Not tested by myself.

Kurt


  1. Create a jsconfig.json file in the root of your project if it doesn't already exist.
  2. In the jsconfig.json file, set "checkJs": true inside the "compilerOptions" object. Here's an example:


{
  "compilerOptions"{
    "module""commonjs",
    "target""es6",
    "checkJs"true
  },
  "include"[
    "*.js"
  ]
}







--
You received this message because you are subscribed to the Google Groups "friam" group.
To unsubscribe from this group and stop receiving emails from it, send an email to friam+un...@googlegroups.com.

Alan Karp

unread,
Dec 8, 2023, 8:17:46 PM12/8/23
to fr...@googlegroups.com
I'm using JavaScript with VSCode.  The problem is that the error reporting in the editor is pathetic.  Someone said the TypeScript plugin did better error reporting for JavaScript.

--------------
Alan Karp


On Fri, Dec 8, 2023 at 5:04 PM Raoul Duke <rao...@gmail.com> wrote:
(er, and would plain old js even get any benefit from ts? since there are no type annotations?)

--
You received this message because you are subscribed to the Google Groups "friam" group.
To unsubscribe from this group and stop receiving emails from it, send an email to friam+un...@googlegroups.com.

Alan Karp

unread,
Dec 8, 2023, 8:20:49 PM12/8/23
to fr...@googlegroups.com
On Fri, Dec 8, 2023 at 4:44 PM Dan Connolly <dc...@madmode.com> wrote:

I think the relevant plug-in is built-in.

I suggest taking a look at https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html 

I don't see a VSCode plugin there. 

--------------
Alan Karp


--
You received this message because you are subscribed to the Google Groups "friam" group.
To unsubscribe from this group and stop receiving emails from it, send an email to friam+un...@googlegroups.com.

Chip Morningstar

unread,
Dec 8, 2023, 8:57:47 PM12/8/23
to 'Kevin Reid' via friam
The first entry the list of a gazillion TypeScript plugins should be the one from Microsoft.  That’s the one you want.

Chip

Alan Karp

unread,
Dec 9, 2023, 7:41:55 PM12/9/23
to fr...@googlegroups.com
On Fri, Dec 8, 2023 at 5:04 PM Kurt Thams <kurt....@gmail.com> wrote:
TypeScript support is built in. 

I think the question for you would be how do you get your Javascript file to be treated with TypeScript strictness, since VSCode uses the filename extension to determine which type checking to apply.

According to copilot, below is how to do it. Not tested by myself.

Kurt

Thanks, Kurt.  That did find the source error that I make most often, for (i = 0; i++; i<n)  instead of for(let i=0; i++; i<n), but it also catches things that aren't errors.  The program starts with

use strict;
let Foo = (function(self) {
     self.bar = "bar";   // Reports Property "bar does not exist ...

but the program runs just fine.  The errors go away if I change checkJs to false, but then it doesn't catch my let i error either.  I tried several suggestions from Copilot, but none of them work.

--------------
Alan Karp
 

Alan Karp

unread,
Dec 9, 2023, 7:47:57 PM12/9/23
to fr...@googlegroups.com
On Fri, Dec 8, 2023 at 5:57 PM Chip Morningstar <ch...@fudco.com> wrote:
The first entry the list of a gazillion TypeScript plugins should be the one from Microsoft.  That’s the one you want.
 
I installed it, but the VSCode editor doesn't find the error I make most often, for(i=0;i<n;i++).

--------------
Alan Karp

Douglas Crockford

unread,
Dec 10, 2023, 8:11:25 AM12/10/23
to friam

If you want to be writing high quality JavaScript, you should be using JSLint.

Alan Karp

unread,
Dec 10, 2023, 1:27:33 PM12/10/23
to fr...@googlegroups.com
On Sun, Dec 10, 2023 at 5:11 AM Douglas Crockford <dou...@crockford.com> wrote:

If you want to be writing high quality JavaScript, you should be using JSLint.

That's a separate issue.  

I use an IDE to catch errors as I am editing.  I'm disappointed at how poorly VSCode does with JavaScript. 

--------------
Alan Karp
Reply all
Reply to author
Forward
0 new messages