New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expression produces a union type that is too complex to represent. #499
Comments
could you give an code example? |
@hasezoey I'm also running into this error on import { ObjectId } from "bson";
import { getModelForClass, prop as Property } from "@typegoose/typegoose";
export class User {
readonly _id?: ObjectId;
@Property({ required: true, type: () => Date })
createdAt!: Date;
@Property({ type: () => Date })
deletedAt!: Date | null;
@Property({ required: true })
email!: string;
@Property({ required: true, type: () => Date })
updatedAt!: Date;
@Property({ required: true })
username!: string;
@Property({ required: true })
password!: string;
}
export const UserModel = getModelForClass(User);
UserModel.create({
createdAt: new Date(),
deletedAt: null,
email: "",
updatedAt: new Date(),
username: "",
password: "",
}) Output:
|
@ezracelli does the error still appear when using the right ObjectId type that is and what versions are you using:
|
@hasezoey Yep, unfortunately the error persists when using {
"dependencies": {
"@typegoose/typegoose": "^7.6.0",
"bson": "^4.3.0",
"mongoose": "5.10.18"
},
"devDependencies": {
"@types/mongoose": "^5",
"typescript": "^4.2.4"
}
}
Should I be pinning |
sorry for the late reply, but i cannot reproduce this problem Code Used// NodeJS: 16.1.0
// MongoDB: 4.2-bionic (Docker)
import { getModelForClass, prop } from "@typegoose/typegoose"; // @typegoose/typegoose@7.6.0
import * as mongoose from "mongoose"; // mongoose@5.10.18 @types/mongoose@5.10.5
export class User {
public readonly _id?: mongoose.Types.ObjectId;
@prop({ required: true, type: () => Date })
public createdAt!: Date;
@prop({ type: () => Date })
public deletedAt!: Date | null;
@prop({ required: true })
public email!: string;
@prop({ required: true, type: () => Date })
public updatedAt!: Date;
@prop({ required: true })
public username!: string;
@prop({ required: true })
public password!: string;
}
export const UserModel = getModelForClass(User);
(async () => {
await mongoose.connect(`mongodb://localhost:27017/`, { useNewUrlParser: true, dbName: "verifyMASTER", useCreateIndex: true, useUnifiedTopology: true });
const doc = await UserModel.create({
createdAt: new Date(),
deletedAt: null,
email: "y",
updatedAt: new Date(),
username: "y",
password: "y",
});
console.log(doc);
await mongoose.disconnect();
})(); Reproduction repo: https://github.com/typegoose/typegoose-testing/tree/verify499 |
@harveyconnor @ezracelli does this issue still persist in typegoose 8.3 or typegoose 9.0 beta? |
@hasezoey Hi we haven't migrated yet, just been using it without typings |
Closing this issue because it is stale (for quite a long time), i had kept this open until now because of actions/stale#766 to have a issue to test with |
Hi I'm getting the error:
Expression produces a union type that is too complex to represent.
. I get the error when I call the.create()
method on a model.These are my versions:
This is stopping me from getting any type definitions for my models so everything is as if I'm coding in plain js..
The text was updated successfully, but these errors were encountered: