I'm using Node.js with MongoDB and TypeScript.
The following two lines of code:
const ObjectID = require("mongodb").ObjectID;
const id = new ObjectID("5b681f5b61020f2d8ad4768d");
compile without error.
But when I change the second line to:
const id: ObjectID = new ObjectID("5b681f5b61020f2d8ad4768d");
I get an error:
Cannot find name 'ObjectID'
Why isn't ObjectID recognised as a type in TypeScript?