TypeError: tocktimer_1.Tock is not a constructor
Hi, using this library, I run into the following error:
Tock is not a constructor
I'm using it in conjunction with nodejs and Typescript:
import { Tock } from 'tocktimer';
export class MyClass {
time = new Tock();
...
}
why does the error occur? Any idea?
try removing the curly braces from the import
I think ydaniv is right. I should probably add this to the readme.
Thanks guys, but unfortunately it didn't work. I got the error:
tocktimer_1.default is not a constructor
But I found a way that worked for me:
import * as Tock from 'tocktimer';
This is the only way that worked.
how about just
import 'tock';
?
no, this won't work. Typescript does not recognise the class. Even when declaring
declare var Tock: any;
so that VSCode does not show any errors and I then create a new object
new Tock()
leads to the error:
ReferenceError: Tock is not defined