Skip to content

Vis-data failing on newest typescript #1011

@ViliusArminas

Description

@ViliusArminas

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch vis-data@7.1.4 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/vis-data/declarations/data-interface.d.ts b/node_modules/vis-data/declarations/data-interface.d.ts
index 6646376..1d80495 100644
--- a/node_modules/vis-data/declarations/data-interface.d.ts
+++ b/node_modules/vis-data/declarations/data-interface.d.ts
@@ -55,7 +55,7 @@ export interface AddEventPayload {
     items: Id[];
 }
 /** Update event payload. */
-export interface UpdateEventPayload<Item, IdProp extends string> {
+export interface UpdateEventPayload<Item extends Partial<Record<IdProp, OptId>>, IdProp extends string> {
     /** Ids of updated items. */
     items: Id[];
     /** Items as they were before this update. */
@@ -68,7 +68,7 @@ export interface UpdateEventPayload<Item, IdProp extends string> {
     data: FullItem<Item, IdProp>[];
 }
 /** Remove event payload. */
-export interface RemoveEventPayload<Item, IdProp extends string> {
+export interface RemoveEventPayload<Item extends Partial<Record<IdProp, OptId>>, IdProp extends string> {
     /** Ids of removed items. */
     items: Id[];
     /** Items as they were before their removal. */
@@ -80,7 +80,7 @@ export interface RemoveEventPayload<Item, IdProp extends string> {
  * @typeParam Item - Item type that may or may not have an id.
  * @typeParam IdProp - Name of the property that contains the id.
  */
-export interface EventPayloads<Item, IdProp extends string> {
+export interface EventPayloads<Item extends Partial<Record<IdProp, OptId>>, IdProp extends string> {
     add: AddEventPayload;
     update: UpdateEventPayload<Item, IdProp>;
     remove: RemoveEventPayload<Item, IdProp>;
@@ -91,7 +91,7 @@ export interface EventPayloads<Item, IdProp extends string> {
  * @typeParam Item - Item type that may or may not have an id.
  * @typeParam IdProp - Name of the property that contains the id.
  */
-export interface EventPayloadsWithAny<Item, IdProp extends string> extends EventPayloads<Item, IdProp> {
+export interface EventPayloadsWithAny<Item extends Partial<Record<IdProp, OptId>>, IdProp extends string> extends EventPayloads<Item, IdProp> {
     "*": ValueOf<EventPayloads<Item, IdProp>>;
 }
 /**
@@ -100,7 +100,7 @@ export interface EventPayloadsWithAny<Item, IdProp extends string> extends Event
  * @typeParam Item - Item type that may or may not have an id.
  * @typeParam IdProp - Name of the property that contains the id.
  */
-export interface EventCallbacks<Item, IdProp extends string> {
+export interface EventCallbacks<Item extends Partial<Record<IdProp, OptId>>, IdProp extends string> {
     /**
      * @param name - The name of the event ([[EventName]]).
      * @param payload - Data about the items affected by this event.
@@ -126,7 +126,7 @@ export interface EventCallbacks<Item, IdProp extends string> {
  * @typeParam Item - Item type that may or may not have an id.
  * @typeParam IdProp - Name of the property that contains the id.
  */
-export interface EventCallbacksWithAny<Item, IdProp extends string> extends EventCallbacks<Item, IdProp> {
+export interface EventCallbacksWithAny<Item extends Partial<Record<IdProp, OptId>>, IdProp extends string> extends EventCallbacks<Item, IdProp> {
     /**
      * @param name - The name of the event ([[EventName]]).
      * @param payload - Data about the items affected by this event.
diff --git a/node_modules/vis-data/declarations/data-set-part.d.ts b/node_modules/vis-data/declarations/data-set-part.d.ts
index ffb28f9..55b1c10 100644
--- a/node_modules/vis-data/declarations/data-set-part.d.ts
+++ b/node_modules/vis-data/declarations/data-set-part.d.ts
@@ -1,11 +1,11 @@
-import { DataInterface, EventCallbacksWithAny, EventPayloads, Id } from "./data-interface";
+import { DataInterface, EventCallbacksWithAny, EventPayloads, Id, OptId } from "./data-interface";
 /**
  * [[DataSet]] code that can be reused in [[DataView]] or other similar implementations of [[DataInterface]].
  *
  * @typeParam Item - Item type that may or may not have an id.
  * @typeParam IdProp - Name of the property that contains the id.
  */
-export declare abstract class DataSetPart<Item, IdProp extends string> implements Pick<DataInterface<Item, IdProp>, "on" | "off"> {
+export declare abstract class DataSetPart<Item extends Partial<Record<IdProp, OptId>>, IdProp extends string> implements Pick<DataInterface<Item, IdProp>, "on" | "off"> {
     private readonly _subscribers;
     protected _trigger(event: "add", payload: EventPayloads<Item, IdProp>["add"], senderId?: Id | null): void;
     protected _trigger(event: "update", payload: EventPayloads<Item, IdProp>["update"], senderId?: Id | null): void;

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions