Type 'string' is not assignable to type 'never'
See original GitHub issueBug 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:
- Created a year ago
- Comments:15 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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’
The camp with
Type 'string' is not assignable to type 'never'
is theownerID
, and the type ofcandidatura
is the class of the first message of this issues, and sorry for the delay to response