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.

tslint(2345) error in schema

See original GitHub issue

Not sure I misunderstood the docs, or if the tslint can be safely ignored. My Book.ts looks like this:

import { types, schema } from "papr";
import papr from "../config/papr";

const bookSchema = schema({
    asin: types.string({ required: true }),
    title: types.string({ required: true }),
    short_summary: types.string({ required: true }),
    long_summary: types.string({ required: true }),
    release_date: types.date({ required: true }),
    publisher_name: types.string({ required: true }),
    language: types.string({ required: true }),
    runtime_length_min: types.number({ required: true }),
    format_type: types.string({ required: true }),
    cover_image: types.string({ required: true }),
    genres: types.array(
        types.object(
            {
                name: types.string({ required: true }),
                id: types.string({ required: true }),
                type: types.string({ required: true }),
            },
        )
    ),
    primary_series: types.object(
        {
            name: types.string({ required: true }),
            id: types.string({ required: true }),
            position: types.string({ required: true }),       
        }
    ),
    secondary_series: types.object(
        {
            name: types.string({ required: true }),
            id: types.string({ required: true }),
            position: types.string({ required: true }),       
        }
    ),
}, {
    timestamps: true,
});

export type BookDocument = typeof bookSchema[0];
const Book = papr.model("books", bookSchema);
export default Book;

And the lint error is as follows:

Argument of type '[ObjectType<Pick<{ asin: string; title: string; short_summary: string; long_summary: string; release_date: Date; publisher_name: string; language: string; runtime_length_min: number; format_type: string; cover_image: string; genres: ObjectType<...>[]; primary_series: ObjectType<...>; secondary_series: ObjectType<......' is not assignable to parameter of type '[BaseSchema, Partial<BaseSchema>]'.
  Type 'ObjectType<Pick<{ asin: string; title: string; short_summary: string; long_summary: string; release_date: Date; publisher_name: string; language: string; runtime_length_min: number; format_type: string; cover_image: string; genres: ObjectType<...>[]; primary_series: ObjectType<...>; secondary_series: ObjectType<...>...' is not assignable to type 'BaseSchema'.
    Property '_id' is optional in type 'ObjectType<Pick<{ asin: string; title: string; short_summary: string; long_summary: string; release_date: Date; publisher_name: string; language: string; runtime_length_min: number; format_type: string; cover_image: string; genres: ObjectType<...>[]; primary_series: ObjectType<...>; secondary_series: ObjectType<...>...' but required in type 'BaseSchema'.ts(2345)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
KasimAhmiccommented, Sep 27, 2021

@avaly Here is my example repo: https://github.com/KasimAhmic/papr-issue

Spent the last few days experimenting and I’ve boiled it down to the strictNullChecks options in tsconfig.json. The tslint issue disappears for me when I set it to true but fails if I set it to false or don’t have the option in there at all.

I’ll continue to play around with it but so far, I think my issue is resolved. @suv95 would you be able to set strictNullChecks to true in your project to see if this fixes it for you as well?

2reactions
avalycommented, Sep 29, 2021

Thanks for the feedback. We’ll add a note about this in the docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PropOptions causing Typescript-Error (TS2345) #752 - GitHub
Typescript no longer compiles any schema object that has properties with the @Prop decorator with a PropOptions object.
Read more >
TypeScript Error (TS2345) argument of type Person
The problem is the call of useState() . Since you don't pass the initial value, the variable person will be undefined at first....
Read more >
How to fix property not existing on EventTarget in TypeScript
This error occurs when you try to access a property on an event target in TypeScript. Property 'value' does not exist on type...
Read more >
@typescript-eslint/eslint-plugin-tslint | Yarn - Package Manager
ESLint plugin that wraps a TSLint configuration and lints the whole source ... See typescript-eslint.io for documentation on the latest released version.
Read more >
TS compile of go gives error TS2345 - Northwoods Software
I believe our code is doing the Diagram.inherit right after constructing the subclass. However, the puzzling thing is why the first parameter ...
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