Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

'number' only refers to a type, but is being used as a value here

src/db/models/point.ts:10:11 – error TS2693: ‘number’ only refers to a type, but is being used as a value here.

const PointSchema: Schema = new Schema({
  id: {
    type: String,
    required: true,
    unique: true,
    index: true,
  },
  point: {
    type: number,
    required: true,
  },
});

export interface PointProp extends Document {
  id: string;
  point: number;
}

export default model<PointProp>('point', PointSchema);

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You are using a TypeScript type inside an object, as value, just as what the error says. You should have given more info, but I am guessing you are working with Mongoose. In that case, number (the TypeScript type) should be Number (the object)

const PointSchema: Schema = new Schema({
  id: {
    type: String,
    required: true,
    unique: true,
    index: true,
  },
  point: {
    type: Number, // <---
    required: true,
  },
});

See https://mongoosejs.com/docs/guide.html#definition for more information.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading