mongoosejs / mongoose-lean-getters

Apply getters on lean() documents: https://mongoosejs.com/docs/tutorials/lean.html
Apache License 2.0
11 stars 16 forks source link

index.d.ts causing TypeScript or runtime error #11

Closed NightRare closed 2 years ago

NightRare commented 2 years ago

Thanks.

IslandRhythms commented 2 years ago

Run npx tsc filename.ts and then node ./filename.js to confirm second section runtime error

uncomment line 2 and comment line 3 to confirm first section error

comment untyped schema and line 2 and uncomment typed Schema and line 3 to confirm last section error.

import * as mongoose from 'mongoose';
// import * as mongooseLeanGetters from 'mongoose-lean-getters';
import mongooseLeanGetters from 'mongoose-lean-getters';

interface Test {
    name: string
}

const testSchema = new mongoose.Schema({
    name: String
});
/*
const testSchema = new mongoose.Schema<Test>({
    name: String
});
*/
testSchema.plugin(mongooseLeanGetters);
vkarpov15 commented 2 years ago

We fixed this in #14 . You'll be able to do both import mongooseLeanGetters from 'mongoose-lean-getters' and import { mongooseLeanGetters } from 'mongoose-lean-getters'