Type instantiation is excessively deep and possibly infinite.ts(2589)
See original GitHub issuePrerequisites
- I have written a descriptive issue title
Mongoose version
6.5.2
Node.js version
14.18.3
MongoDB version
4.4
Operating system
No response
Operating system version (i.e. 20.04, 11.3, 10)
No response
Issue
when use bulkwrite show ts error can help for solved this error
this my model:
export class BaseModel {
@Field()
_id?: string;
@Field()
createdAt?: Date;
@Field()
updatedAt?: Date
}
export class Member extends BasicModel {
@Field(() => GraphQLBigInt)
@prop()
memberId?: number;
@Field({ nullable: true })
@prop()
firstname?: string;
@Field()
@prop()
lastname?: string;
@prop()
password?: string;
@prop()
public regMember?: RegMember;
}
@ObjectType()
export class MemberData {
@Field(() => [Member])
docs?: Member[];
}
export const MemberModel = getModelForClass(Member) as ISoftDeleteModel<
Member,
typeof Member
>;
sample code:
MemberModel.bulkWrite([
{
updateOne: {
filter: {
firstname: "test"
},
update: {
firstname:"guide"
}
}
}
])
in this block show error:
...
filter: {
firstname: "test"
},
...
and show this error:
(property) firstname: string
Type instantiation is excessively deep and possibly infinite.ts(2589)
Type of property 'Duplex' circularly references itself in mapped type '{ [Key in "prototype" | "on" | "once" | "setMaxListeners" | "listenerCount" | "pipeline" | "getEventListeners" | "errorMonitor" | "captureRejectionSymbol" | "captureRejections" | "defaultMaxListeners" | ... 14 more ... | "consumers"]: (typeof Writable)[Key] extends typeof Writable ? [...] : typeof Writable extends (...'.ts(2615)
Type of property 'PassThrough' circularly references itself in mapped type '{ [Key in "prototype" | "on" | "once" | "setMaxListeners" | "listenerCount" | "pipeline" | "getEventListeners" | "errorMonitor" | "captureRejectionSymbol" | "captureRejections" | "defaultMaxListeners" | ... 14 more ... | "consumers"]: (typeof Writable)[Key] extends typeof Writable ? [...] : typeof Writable extends (...'.ts(2615)
Type of property 'Query' circularly references itself in mapped type '{ get: ["get"]; set: ["set"]; default: ["default"]; deleteModel: ["deleteModel"]; models: any; model: ["model"]; modelNames: ["modelNames"]; plugin: ["plugin"]; startSession: ["startSession"]; ... 35 more ...; mquery: [...] | [...]; }'.ts(2615)
Type of property 'Readable' circularly references itself in mapped type '{ [Key in "prototype" | "on" | "once" | "setMaxListeners" | "listenerCount" | "pipeline" | "getEventListeners" | "errorMonitor" | "captureRejectionSymbol" | "captureRejections" | "defaultMaxListeners" | ... 14 more ... | "consumers"]: (typeof Writable)[Key] extends typeof Writable ? [...] : typeof Writable extends (...'.ts(2615)
Type of property 'Stream' circularly references itself in mapped type '{ [Key in "prototype" | "on" | "once" | "setMaxListeners" | "listenerCount" | "pipeline" | "getEventListeners" | "errorMonitor" | "captureRejectionSymbol" | "captureRejections" | "defaultMaxListeners" | ... 14 more ... | "consumers"]: (typeof Writable)[Key] extends typeof Writable ? [...] : typeof Writable extends (...'.ts(2615)
Type of property 'Transform' circularly references itself in mapped type '{ [Key in "prototype" | "on" | "once" | "setMaxListeners" | "listenerCount" | "pipeline" | "getEventListeners" | "errorMonitor" | "captureRejectionSymbol" | "captureRejections" | "defaultMaxListeners" | ... 14 more ... | "consumers"]: (typeof Writable)[Key] extends typeof Writable ? [...] : typeof Writable extends (...'.ts(2615)
Type of property 'Writable' circularly references itself in mapped type '{ from: ["from"]; prototype: ["prototype"] | ["prototype", "read"] | ["prototype", "destroy"] | ["prototype", "eventNames"] | ["prototype", "addListener"] | ["prototype", "on"] | ... 38 more ... | [...]; ... 25 more ...; consumers: [...] | ... 4 more ... | [...]; }'.ts(2615)
Type of property 'Writable' circularly references itself in mapped type '{ from: ["from"]; prototype: ["prototype"] | ["prototype", "read"] | ["prototype", "destroy"] | ["prototype", "eventNames"] | ["prototype", "addListener"] | ["prototype", "on"] | ... 55 more ... | [...]; ... 25 more ...; consumers: [...] | ... 4 more ... | [...]; }'.ts(2615)
Type of property 'Writable' circularly references itself in mapped type '{ from: ["from"]; prototype: ["prototype"] | ["prototype", "read"] | ["prototype", "destroy"] | ["prototype", "eventNames"] | ["prototype", "addListener"] | ["prototype", "on"] | ... 57 more ... | [...]; ... 25 more ...; consumers: [...] | ... 4 more ... | [...]; }'.ts(2615)
Type of property 'Writable' circularly references itself in mapped type '{ prototype: ["prototype"] | ["prototype", "eventNames"] | ["prototype", "addListener"] | ["prototype", "on"] | ["prototype", "once"] | ["prototype", "removeListener"] | ... 10 more ... | [...]; ... 22 more ...; consumers: [...] | ... 4 more ... | [...]; }'.ts(2615)
Type of property '_mongooseOptions' circularly references itself in mapped type '{ remove: ["remove"]; populate: ["populate"]; lean: ["lean"]; catch: ["catch"]; then: ["then"]; tailable: ["tailable"]; error: ["error"]; slice: ["slice"]; $where: ["$where"]; deleteOne: ["deleteOne"]; ... 85 more ...; within: [...]; }'.ts(2615)
Type of property 'autoEncryption' circularly references itself in mapped type '{ raw: ["raw"]; forceServerObjectId: ["forceServerObjectId"]; readConcern: ["readConcern"] | ["readConcern", "toJSON"] | ["readConcern", "level"]; retryWrites: ["retryWrites"]; ... 65 more ...; tls: [...]; }'.ts(2615)
Type of property 'base' circularly references itself in mapped type '{ [Key in keyof Model<any, {}, {}, {}, any>]: Model<any, {}, {}, {}, any>[Key] extends Model<any, {}, {}, {}, any> ? [Key] : Model<any, {}, {}, {}, any> extends Model<...>[Key] ? [...] : Model<...>[Key] extends readonly (infer ArrayType)[] ? Model<...> extends ArrayType ? [...] : ArrayType extends Model<...> ? [...]...'.ts(2615)
Type of property 'childSchemas' circularly references itself in mapped type '{ [Key in keyof Schema<any, Model<any, any, any, any, any>, {}, {}, {}, {}, "type", { [x: string]: any; }>]: Schema<any, Model<any, any, any, any, any>, {}, {}, {}, {}, "type", { ...; }>[Key] extends Schema<...> ? [...] : Schema<...> extends Schema<...>[Key] ? [...] : Schema<...>[Key] extends readonly (infer ArrayTy...'.ts(2615)
Type of property 'collections' circularly references itself in mapped type '{ close: ["close"]; collection: ["collection"]; db: ["db"] | ["db", "collection"] | ["db", "options"] | ["db", "readConcern"] | ["db", "readConcern", "toJSON"] | ["db", "readConcern", "level"] | ... 103 more ... | [...]; ... 44 more ...; eventNames: [...]; }'.ts(2615)
Type of property 'conn' circularly references itself in mapped type '{ [Key in keyof Collection<Document>]: Collection<Document>[Key] extends Collection<Document> ? [Key] : Collection<...> extends Collection<...>[Key] ? [...] : Collection<...>[Key] extends readonly (infer ArrayType)[] ? Collection<...> extends ArrayType ? [...] : ArrayType extends Collection<...> ? [...] : [...] : [....'.ts(2615)
Type of property 'db' circularly references itself in mapped type '{ validate: ["validate"]; remove: ["remove"]; populate: ["populate"]; $where: ["$where"]; baseModelName: ["baseModelName"]; collection: ["collection"] | ["collection", ...any[]]; db: ["db"] | [...]; ... 61 more ...; ensureIndexes: [...]; }'.ts(2615)
Type of property 'defaultTransactionOptions' circularly references itself in mapped type '{ [Key in keyof ClientSession]: ClientSession[Key] extends ClientSession ? [Key] : ClientSession extends ClientSession[Key] ? [...] : ClientSession[Key] extends readonly (infer ArrayType)[] ? ClientSession extends ArrayType ? [...] : ArrayType extends ClientSession ? [...] : [...] : [...] | [...]; }'.ts(2615)
Type of property 'discriminators' circularly references itself in mapped type '{ [Key in keyof Model<any, {}, {}, {}, any>]: Model<any, {}, {}, {}, any>[Key] extends Model<any, {}, {}, {}, any> ? [Key] : Model<any, {}, {}, {}, any> extends Model<...>[Key] ? [...] : Model<...>[Key] extends readonly (infer ArrayType)[] ? Model<...> extends ArrayType ? [...] : ArrayType extends Model<...> ? [...]...'.ts(2615)
Type of property 'discriminators' circularly references itself in mapped type '{ [Key in keyof Schema<any, Model<any, any, any, any, any>, {}, {}, {}, {}, "type", { [x: string]: any; }>]: Schema<any, Model<any, any, any, any, any>, {}, {}, {}, {}, "type", { ...; }>[Key] extends Schema<...> ? [...] : Schema<...> extends Schema<...>[Key] ? [...] : Schema<...>[Key] extends readonly (infer ArrayTy...'.ts(2615)
Type of property 'keyVaultClient' circularly references itself in mapped type '{ [Key in keyof AutoEncryptionOptions]: AutoEncryptionOptions[Key] extends AutoEncryptionOptions ? [...] : AutoEncryptionOptions extends AutoEncryptionOptions[Key] ? [...] : AutoEncryptionOptions[Key] extends readonly (infer ArrayType)[] ? AutoEncryptionOptions extends ArrayType ? [...] : ArrayType extends AutoEncry...'.ts(2615)
Type of property 'model' circularly references itself in mapped type '{ options: ["options"] | ["options", string]; populate: ["populate"]; match: ["match"]; select: ["select"]; transform: ["transform"]; model: ["model"] | ["model", ...any[]]; path: ["path"]; perDocumentLimit: [...]; strictPopulate: [...]; justOne: [...]; }'.ts(2615)
Type of property 'models' circularly references itself in mapped type '{ [Key in keyof Connection]: Connection[Key] extends Connection ? [Key] : Connection extends Connection[Key] ? [...] : Connection[Key] extends readonly (infer ArrayType)[] ? Connection extends ArrayType ? [...] : ArrayType extends Connection ? [...] : [...] : [...] | [...]; }'.ts(2615)
Type of property 'models' circularly references itself in mapped type '{ get: ["get"]; set: ["set"]; default: ["default"]; deleteModel: ["deleteModel"]; models: ["models"] | ["models", string] | ["models", string, ...any[]]; model: ["model"]; modelNames: ["modelNames"]; ... 37 more ...; mquery: [...] | [...]; }'.ts(2615)
Type of property 'options' circularly references itself in mapped type '{ options: ["options"] | ["options", ...any[]]; close: ["close"]; db: ["db"]; readConcern: ["readConcern"] | ["readConcern", "toJSON"] | ["readConcern", "level"]; readPreference: [...] | ... 12 more ... | [...]; ... 24 more ...; withSession: [...]; }'.ts(2615)
Type of property 'options' circularly references itself in mapped type '{ options: ["options"] | ["options", ...any[]]; isPinned: ["isPinned"]; recoveryToken: ["recoveryToken"]; isStarting: ["isStarting"]; isActive: ["isActive"]; isCommitted: ["isCommitted"]; }'.ts(2615)
Type of property 'paths' circularly references itself in mapped type '{ [Key in keyof Schema<any, Model<any, any, any, any, any>, {}, {}, {}, {}, "type", { [x: string]: any; }>]: Schema<any, Model<any, any, any, any, any>, {}, {}, {}, {}, "type", { ...; }>[Key] extends Schema<...> ? [...] : Schema<...> extends Schema<...>[Key] ? [...] : Schema<...>[Key] extends readonly (infer ArrayTy...'.ts(2615)
Type of property 'populate' circularly references itself in mapped type '{ populate: ["populate"] | ["populate", ...any[]]; lean: ["lean"]; strict: ["strict"]; sanitizeProjection: ["sanitizeProjection"]; sanitizeFilter: ["sanitizeFilter"]; }'.ts(2615)
Type of property 'prototype' circularly references itself in mapped type '{ prototype: ["prototype"] | ["prototype", ...any[]]; }'.ts(2615)
Type of property 'schema' circularly references itself in mapped type '{ options: ["options"]; validate: ["validate"]; get: ["get"]; schema: ["schema"] | ["schema", ...any[]]; set: ["set"]; index: ["index"]; default: ["default"]; text: ["text"]; cast: ["cast"]; required: [...]; ... 10 more ...; validators: [...] | ... 11 more ... | [...]; }'.ts(2615)
Type of property 'schema' circularly references itself in mapped type '{ schema: ["schema"] | ["schema", ...any[]]; model: ["model"]; }'.ts(2615)
Type of property 'session' circularly references itself in mapped type '{ [Key in keyof TransactionOptions]: TransactionOptions[Key] extends TransactionOptions ? [Key] : TransactionOptions extends TransactionOptions[Key] ? [...] : TransactionOptions[Key] extends readonly (infer ArrayType)[] ? TransactionOptions extends ArrayType ? [...] : ArrayType extends TransactionOptions ? [...] : [...'.ts(2615)
Type of property 'transaction' circularly references itself in mapped type '{ [Key in keyof ClientSession]: ClientSession[Key] extends ClientSession ? [Key] : ClientSession extends ClientSession[Key] ? [...] : ClientSession[Key] extends readonly (infer ArrayType)[] ? ClientSession extends ArrayType ? [...] : ArrayType extends ClientSession ? [...] : [...] : [...] | [...]; }'.ts(2615)
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:18
Top Results From Across the Web
“Type instantiation is excessively deep and possibly infinite ...
Type instantiation is excessively deep and possibly infinite.ts (2589); Mapped types; Generics; Conditional types.
Read more >how to ignore "Type instantiation is excessively deep and ...
Type instantiation is excessively deep and possibly infinite. ts (2589). It happens when TS decides that types become too complex to compute ...
Read more >TypeScript. Type instantiation is excessively deep ... - Ilya Zykin
Type instantiation is excessively deep and possibly infinite.ts (2589). Visual Studio Code IDE displays it to me for a component. The most unpleasant...
Read more >Type instantiation is excessively deep and possibly infinite ...
Getting `Type instantiation is excessively deep and possibly infinite` errors whenever I pass MongoClient as a parameter in my code after ...
Read more >TypeScript - i18next documentation
Type error - excessively deep and possibly infinite. If you face this issue whenever calling the t function: TS2589: Type instantiation is excessively...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
thanks for the explanation @IslandRhythms, it seems we had a different understanding of the label meanings, thanks for clarifying (personally in my projects i have
needs repro script
if there is no repro script present andhas repro script
if a repro script is present and actually reproduces it, regardless if other labels are present)Based off of @hasezoey 's script here: https://github.com/Automattic/mongoose/issues/12277#issuecomment-1216400738 I’d advise either using Mongoose’s automatic type inference:
or calling
mongoose.model<>
with the raw doc type as the first generic:rather than trying to manually create a hydrated document type and passing it to
mongoose.model<>
. That being said, we’ll investigate more to see if we can come up with a fix.