Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda