I'm new to RxDB and I've come across a strange Typescript error in my Electron project.
Here are the relevant parts of my code:
import RxDB, { RxCollection, RxDatabase } from "rxdb";
RxDB.plugin(require("pouchdb-adapter-idb"));
const heroSchema = {
title: 'hero schema',
description: 'describes a simple hero',
version: 0,
type: 'object',
properties: {
name: {
type: 'string',
primary: true
},
color: {
type: 'string'
}
},
required: ['color']
};
// Inside an async function so await works fine
const db = await RxDB.create({ name: "heroedb", adapter: "idb" });
const devices = await db.collection({
name: "herocollection",
schema: heroSchema
});
However, Typescript gives me this error:
Argument of type '{ name: string; schema: { title: string; description: string; version: number; type: string; prop...' is not assignable to parameter of type 'RxCollectionCreator'.
Types of property 'schema' are incompatible.
Type '{ title: string; description: string; version: number; type: string; properties: { name: { type: ...' is not assignable to type 'RxJsonSchema | RxSchema<any>'.
Type '{ title: string; description: string; version: number; type: string; properties: { name: { type: ...' is not assignable to type 'RxSchema<any>'.
Property 'jsonID' is missing in type '{ title: string; description: string; version: number; type: string; properties: { name: { type: ...'
Adding jsonID
to the schema raises another error about a missing property. It seems like I've made a mistake somewhere. Any insights would be greatly appreciated.