Skip to content
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

Serialization error when working with TypeScript #20

Open
dhwanik-speed opened this issue Apr 17, 2023 · 4 comments
Open

Serialization error when working with TypeScript #20

dhwanik-speed opened this issue Apr 17, 2023 · 4 comments

Comments

@dhwanik-speed
Copy link

Getting error - error TS4118: The type of this node cannot be serialized because its property '[hasInstance]' cannot be serialized. when using TypeScript.

Example model:

import mongoose, { Schema } from "mongoose";
import mongooseLong from "mongoose-long";

mongooseLong(mongoose);

const { Decimal128, Long } = Schema.Types;

const ExchangeSchema = new Schema({
  timestamp: Long,
  meta: [{
    timestamp: Long,
    pair: String,
    _id: false
  }],
  rates: {
    type: Map,
    of: Decimal128,
  },
  conversion_rate_fetch_timestamp: Long,
}, {
  timestamps: true,
});

Version information:
mongodb: ^5.2.0
mongoose: ^6.3.4
mongoose-long: ^0.6.0
typescript: ^4.7.2

Any help/workarounds are appreciated. Thanks!

@IslandRhythms
Copy link

image
I'm getting a different error

@dhwanik-speed
Copy link
Author

You need to install mongodb package through NPM for it to work

@IslandRhythms
Copy link

image
I do have it installed

@IslandRhythms
Copy link

image
Running it anyway causes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants