tslint(2345) error in schema
See original GitHub issueNot 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:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top 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 >
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 Free
Top 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
@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 intsconfig.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?Thanks for the feedback. We’ll add a note about this in the docs.