question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type 'string' is not assignable to type 'never'

See original GitHub issue

Bug description

For some reason i’m getting the Type 'string' is not assignable to type 'never' error, but the variables are with same tipe (string)

How to reproduce

prisma.< database >.<create || update>({ data: <data> })

Prisma information

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

model Users {
  id           String         @id @unique
  firstName    String
  lastName     String
  email        String         @unique
  password     String
  number       Int
  curriculo    String?
  createdAt    DateTime       @default(now())
  updatedAt    DateTime       @updatedAt
  anuncios     Anuncios[]
  candidaturas Candidaturas[]
}

model Anuncios {
  id           String         @id @unique
  ownerID      String
  companyName  String
  local        String
  description  String         @db.VarChar(500)
  salary       String?
  role         String
  typeJob      String // Remoto, presencial ou híbrido
  requirements String?        @db.VarChar(500)
  contractType String
  createdAt    DateTime       @default(now())
  updatedAt    DateTime       @updatedAt  
  owner        Users          @relation(fields: [ownerID], references: [id])
  candidaturas Candidaturas[]
}

model Candidaturas {
  id         String   @id @unique
  ownerID    String
  anuncioID  String
  status     Int      @default(0) //0 - nenhuma atualização, 1 - aceito, 2 - recusado, 3 - Em analise
  createdAt  DateTime @default(now())
  updatedAt  DateTime @updatedAt
  owner      Users    @relation(fields: [ownerID], references: [id])
  anuncio    Anuncios @relation(fields: [anuncioID], references: [id])
}
async create(candidatura: Candidaturas): Promise<Candidaturas> {
    return this.prisma.candidaturas.create({ data: candidatura });
  }
  
  Candidaturas.ts:
import { v4 as uuid } from 'uuid';

import Users from './Users';
import Anuncios from './Anuncios';

class Candidaturas {
  public readonly id: string;

  public readonly ownerID: string;

  public readonly anuncioID: string;

  public status?: number;

  public createdAt: Date;

  public updatedAt: Date;

  public readonly owner?: Users;

  public readonly anuncio?: Anuncios;

  constructor(props: Omit<Candidaturas, 'id' | 'createdAt' | 'updatedAt'>, id?: string) {
    Object.assign(this, props);

    if (!id) {
      this.id = uuid();
    }
  }
}

export default Candidaturas;

Environment & setup

  • OS: Windows11
  • Database: mysql
  • Node.js version: v16.16.0

Prisma Version

prisma                  : 4.5.0
@prisma/client          : 4.5.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine    : introspection-core 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary           : prisma-fmt 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Format Wasm             : @prisma/prisma-fmt-wasm 4.5.0-43.0362da9eebca54d94c8ef5edd3b2e90af99ba452
Default Engines Hash    : 0362da9eebca54d94c8ef5edd3b2e90af99ba452
Studio                  : 0.476.0

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
DiogoMarques2003commented, Nov 29, 2022

@janpio the data of table is: id, status, createdAt, updatedAt, ownerID, anuncioID ‘dc667d1b-796a-4821-b2ef-7581326e2edf’, ‘0’, ‘2022-11-19 17:09:32.933’, ‘2022-11-19 17:09:32.933’, ‘548095e2-bd83-4028-89aa-e6f016031e53’, ‘ae7cb90d-db65-460c-bcd3-fde0bbef9a7c’

1reaction
DiogoMarques2003commented, Nov 8, 2022

Someone would need to reproduce first, so if you can give us more information, that would help.

For which field do you get Type 'string' is not assignable to type 'never'? Is there any extra info about this error? For example, where it comes from?

Could you give us an example of the data passed in prisma.candidaturas.create({ data: candidatura }); (candidatura)

The camp with Type 'string' is not assignable to type 'never' is the ownerID, and the type of candidatura is the class of the first message of this issues, and sorry for the delay to response

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is "not assignable to parameter of type never" error in ...
The reason was that the array was initialised with also the option of an empty array. Typescript saw a push to a type...
Read more >
Argument of type not assignable to parameter type 'never'
The error "Argument of type is not assignable to parameter of type 'never'" occurs when we declare an empty array without explicitly typing...
Read more >
Typescript `never` type - Explain Programming
Type 'string' is not assignable to type 'never'. Question: Typescript: Under strictNullChecks option, using concat in order to build an array leads to...
Read more >
What is not assignable to parameter of type never error in ...
I get the following TS error: [ts] Argument of type 'string' is not assignable to parameter of type 'never'. What exactly am I...
Read more >
Type 'string' is not assignable to type 'never'. - Reddit
A type never can mean your condition may always be false. There is also weird typing shenanigans that can cause something to get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found