Как экспортировать mongoose.model (xxx, xxx) как класс TypeScript - PullRequest
1 голос
/ 19 мая 2019

Горячий экспорт mongoose.model (xxx, xxx) как класс TypeScript? Облако ты мне поможешь? Большое спасибо !!!!

store_entity.ts
export const StoreSchema: Schema = new Schema({
    name: {
        type: String
    }
}, {
        autoCreate: true,
        versionKey: false
    }
);

StoreSchema.index({ name: 1 }, { unique: true });

export const StoreEntity = mongoose.model('store', StoreSchema, 'store');
test.ts
import { StoreEntity } from './store_entity';

function display(storeEntity: StoreEntity) {
    console.log(storeEntity);
}

Но у меня есть подсказка об ошибке:

'StoreEntity' refers to a value, but is being used as a type here.ts(2749)

в test.ts

...