Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
Typescript error: type this is not assignable to type this

I am new to typescript and I am working on one project and I am trying to set up the project and I got an error from backend typescript I don't know how I solve it if someone knows that help me.

TS File

import { Document, Model, model, Schema } from "mongoose";
import { IUser } from "./GenUser";

/**
* Interface to model GenStatus for TypeScript.
* @param cStatusCode: string 
* @param cStatusName: string 
* @param cStatusDesc: string
* @param iEnteredby: string
* @param tEntered: Date
* @param iUpdatedby: string
* @param tUpdated: Date;
*/
export interface IStatus extends Document {
  cStatusCode: string;
  cStatusName: string;
  cStatusDesc: string;
  iEnteredby: IUser['_id'];
  tEntered: Date;
  iUpdatedby: IUser['_id'];
  tUpdated: Date;
}

const GenStatus: Schema = new Schema({
  cStatusCode: {
    type: String,
    required: true,
    unique: true
  },
  cStatusName: {
    type: String,
    required: true,
    unique: true
  },
  cStatusDesc: {
    type: String,
    required: true
  },
  iEnteredby: {
    type: Schema.Types.ObjectId,
    ref: "User"
  },
  tEntered: {
    type: Date
  },
  iUpdatedby: {
    type: Schema.Types.ObjectId,
    ref: "User"
  },
  tUpdated: {
    type: Date
  }
});

const Status: Model<IStatus> = model("gen_Status", GenStatus);

export default Status;

Error

src/models/GenStatus.ts:55:7 - error TS2322: Type 'Model<Document<any, any, any>, any, any>' is not assignable to type 'Model<IStatus, {}, {}>'. The types returned by 'create(...)' are incompatible between these types. Type 'Promise<Document<any, any, any>[]>' is not assignable to type 'Promise<IStatus[]>'. Type 'Document<any, any, any>[]' is not assignable to type 'IStatus[]'. Type 'Document<any, any, any>' is not assignable to type 'IStatus'. 55 const Status: Model = model("gen_Status", GenStatus);

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I resolve it and the answer is here.

Before

const Status: Model<IStatus> = model("gen_Status", GenStatus);

After

const Status: Model<IStatus> = model<IStatus>("gen_Status", GenStatus);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda