Im trying to build a very simple model with typegoose inside Vue + electron.
This is my simplified code:
import { getModelForClass, prop, modelOptions } from '@typegoose/typegoose';
@modelOptions({
schemaOptions: { collection: 'ability_group' }
})
export class RmfCategoryGroup2 {
@prop( {type: () => String} )
public name: string;
}
export const CategoryGroup2DAO = getModelForClass(RmfCategoryGroup2);
When app launches in electron, the window opens and i have an error:
Uncaught TypeError: Right-hand side of 'instanceof' is not an object
at addModelToTypegoose (typegoose.ts:180)
at getModelForClass (typegoose.ts:87)
at Module../src/model/RmfCategoryGroup.ts (RmfCategoryGroup.ts:17)
at __webpack_require__ (bootstrap:24)
at fn (hot module replacement:61)
at Module../src/services/category_groups_service.ts (categories_service.ts:8)
at __webpack_require__ (bootstrap:24)
at fn (hot module replacement:61)
at Module../node_modules/babel-loader/lib/index.js!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader/index.js??clonedRuleSet-41[0].rules[0].use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/admin/category-groups/list.vue?vue&type=script&lang=ts& (form.vue?58cc:74)
at __webpack_require__ (bootstrap:24)
If i activate debug on typegoose i have the following traces before error:
Assigning global Schema Options to "TimeStamps"
globalOptions.ts:27 "parseENV" got called
globalOptions.ts:14 "setGlobalOptions" got called with Object
globalOptions.ts:20 new Global Options: Object
prop.ts:50 Added "RmfCategoryGroup2.name" to the Decorator Cache
utils.ts:569 Assigning global Schema Options to "RmfCategoryGroup2"
typegoose.ts:127 buildSchema called for "RmfCategoryGroup2"
schema.ts:49 _buildSchema Called for RmfCategoryGroup2 with options: Object
processProp.ts:471 Detecting PropType
processProp.ts:40 Starting to process "RmfCategoryGroup2.name"
processProp.ts:62 Prop Option "type" is set to ƒ type() {
return String;
}
utils.ts:657 Final getType: dim: 0, type: ƒ type() {
return String;
}
typegoose.ts:127 buildSchema called for "type"
utils.ts:569 Assigning global Schema Options to "type"
schema.ts:49 _buildSchema Called for type with options: Object
typegoose.ts:127 buildSchema called for "type"
schema.ts:49 _buildSchema Called for type with options: Object
The version im using are:
electron: 11.2.1 node: 14.7.6 vue: 2.6.14 typescript: 4.5.5 typegoose: 5.11.97 mongoose: 6.3.1 vuetify: 2.6.4
im using mongoose-extend-schema: 1.0.0 in another part of app
My tsconfig.ts
{
"compilerOptions": {
"strictNullChecks": false,
//"target": "esnext",
"target": "ES6",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"moduleResolution": "node",
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"useDefineForClassFields": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
"baseUrl": ".",
"noImplicitThis": false,
"resolveJsonModule": true,
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
typegoose version 9.8.1 Thanks!!