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 Document seem to be not combitable with other interfaces

See original GitHub issue

This is the Document type.

type Document<T> = DocumentLike & {
    [key in keyof T]: T[key]
}

It is supposed to accept any objects { } with appropriate values. See the example below

interface IName {  name: string }
let testObj: IName = { name: 'Aora' }
idx.addAdocuments([ testObj ]) // error!

This isn’t making any sense. Because if I remove the interface (IName) of testObj, this suddenly works just fine. That means it works as it is supposed to. So what’s up with the type error?

Type 'IName' is not assignable to type 'Document<any>'.
  Type 'IName' is not assignable to type 'DocumentLike'.
    Index signature is missing in type 'IName'.ts(2322)

Another great example would the README.md file

const documents = [
    { book_id: 123, title: 'Pride and Prejudice' },
    ...
  ]

Here each object can be given an interface like

interface IBook {book_id: number,  title: string}
const documents = [
    { book_id: 123, title: 'Prejudice' } as IBook,
    ...
  ]

And as you expect, using this in the addDocuments function produces the same error. Pardon me if I’m wrong somewhere.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
emyanncommented, Oct 19, 2020

Hello @bidoubiwa, sorry for the delayed answer, same for me in holidays last week. I definitely want to take a peek at this issue as I worked on those types. I’ll send a PR by the end of the week and let you know if I ever have an impediment working on this issue 🙏

0reactions
bidoubiwacommented, Oct 15, 2020

Hey @emyann, If you have no time to resolve this, which is not a problem! Could you tell me so someone else can be assigned to this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implementing Incompatible Interfaces - java - Stack Overflow
I am trying to build a class that implements Queue and Map . Both interfaces define the remove(Object) method, but with different return...
Read more >
Everything you wanted to know about interfaces, but were ...
Topics covered include: Understand what constitutes an interface, how to identify interfaces, how to define and document interface definitions, what constitutes ...
Read more >
Allow extending multiple interfaces with different, but ... - GitHub
Interface 'SomeChange' cannot simultaneously extend types 'Change' and 'SomeChangeExtension'. Named property 'type' of types 'Change' and ' ...
Read more >
How to troubleshoot damaged documents in Word - Office
Method 3: Create a link to the damaged document. Step 1: Create blank document. In Word, select the File Menu, and then select...
Read more >
Interface Compatibility - Linker and Libraries Guide
Interface Compatibility. Many types of change can be made to an object. In their simplest terms, these changes can be categorized into one...
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