I have a project that I am using typescript in and want to use typescript definition files to interface with libraries such as mongoose. I have installed the appropriate .d.ts files via
tsd query mongoose --action install
tsd query node --action install
I'm trying to import mongoose via the following code
///<reference path="../typings/mongoose/mongoose.d.ts">
import mongoose = require("mongoose");
class MongooseUser
{
constructor()
{
}
useMongoose():any {
return mongoose.Collection;
}
}
Obviously, I'm not trying to do anything here at the moment, but when I transpile this I get the following errors
Unable to resolve external module '"mongoose"'.
Module cannot be aliased to a non-module type.
error TS2095: Could not find symbol 'mongoose'.
Either looking for a complete example on how to use these things (which sadly the docs are terrible at providing) or some pointers. Thanks.
Your reference tag is incorrect. You forgot to close it />
. Fixed:
///<reference path="../typings/mongoose/mongoose.d.ts"/>
This will help you prevent such mistakes : https://github.com/TypeStrong/grunt-ts#references
the d.ts is your definition file it has nothing to do with mongoose package it is only for intellisense, are you sure that mongoose is installed in your node_module please check and install it locally as well as globally
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With