Skip to main content

Known Issues

Known Issues

Please look here first, to decide if it is a Typegoose or a Mongoose issue.

transpile-only

Never run ts-node --transpile-only or tsc --transpile-only, otherwise sometimes types are missing completly or are the wrong type.

tsconfig-paths

TypeScript provides the option to alias paths (with tsconfig-paths), but is somehow incompatible with Typegoose, more info in here

Self-Containing classes

It is currently not possible to use a self-containing class (sub-documents)

class SomeClass {
@prop()
public ref: SomeClass; // ERROR "Maximum Class Stack Size Exceeded"
}

For References, this will work

class SomeClass {
@prop({ ref: () => SomeClass }) // or hardcode the string
public ref: Ref<SomeClass>;
}

Babel

This Section may be outdated

Using babel as a TypeScript compiler is known to cause problems (like incorrect types), we recommened you use tsc directly, or ts-node or ts-jest for jest-testing.

If Babel is still needed, then read Babel TypeScript preset and install the following plugins:

info

emitDecoratorMetadata is not strictly needed, see Use Without emitDecoratorMetadata

module.exports = {
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
'babel-plugin-transform-typescript-metadata',
['@babel/plugin-proposal-class-properties', { loose: true }],
]
}

prop on get & set

@prop cannot be applied to get & set (ES6), because virtuals do not accept options & schema.loadClass wouldn't load these.

Webpack

Webpack's minimize cannot be used with typegoose, because typegoose relies heavily on reflection and property names.

In webpack, it can be disabled when adding the following to the webpack config:

module.exports = {
optimization: {
minimize: false
}
}
note

There are some workarounds for some minification problems, like the class name (which would be the model name) can be changed with customName.