WebStorm import syntax

I am thinking about 'upgrading' from VS Code, to WebStorm.

The (Nodejs) project ran fine in VS Code.

WebStorm seems to have better syntax checking, which I prefer, and so am 'fixing' some minor issues.

Old code:

const isPast = require("date-fns/isPast");

if (isPast(expiryDate)) {

..gives "Method Expression is not of Function type" when I try to call the function.

So I google around, and find an answer on some JetBrains support site.

New 'fixed' code:

import parseISO from "date-fns/parseISO";

which clears the syntax warning, but gives me an uncaught exception running that line.

To be clear, this all worked fine running under the free VS Code.


Why would the fix to this syntax 'problem' result in a runtime exception?
Is there any point persevering with WebStorm?

I've spent 5 hours so far, and haven't got the app to run, yet.

 

0
1 comment

Not sure how the 'fix' is related to the initial issue... using the suggested ESM syntax (https://date-fns.org/v2.28.0/docs/isPast) should make the error go away:

import { isPast } from 'date-fns'
0

Please sign in to leave a comment.