Skip to content

Property <<plugin name>> does not exist on type 'Plugins' #266

Open

Description

@wlecki

Hey! I'm creating a new plugin for the analytics lib :)
It's almost ready to be published, but I'm getting this Typescript error when calling custom methods in my plugin:

image

I'm uncertain if that's something I missed in my configuration, or if that's something we can improve in the main analytics lib. I can prepare a PR here too.

Activity

  1. DavidWells commented on Apr 3, 2022

    @DavidWells
    Owner

    Mmmm not sure how exactly you'd type this.

    Suggestions welcome.

  2. wlecki commented on Jun 14, 2022

    @wlecki
    ContributorAuthor

    Hey :)

    So I've found this script to generate typing, but I have hard time understanding it (thus, creating a PR): https://github.com/DavidWells/analytics/blob/e324d0c97797c5d661bb11c8f2014e05cb639564/packages/analytics-core/scripts/types.js

    But the simplest solution would be to allow Record for plugins property on AnalyticsInstance like this:

    export interface AnalyticsInstance  {
      identify: Identify;
      track: Track;
      page: Page;
      user: User;
      reset: Reset;
      ready: Ready;
      on: On;
      once: Once;
      getState: GetState;
      storage: Storage;
      plugins: Plugins & Record<string, any>;
    }

    Now plugins property is typed like this: plugins: Plugins;

  3. shafferchance-lulu commented on Aug 26, 2022

    @shafferchance-lulu

    Using namespace and interface merging via globals is how my team accomplished this. We did unfortunately have to coerce to get it working if did some wrapping you could be probably get it to override directly.

  4. shafferchance-lulu commented on Aug 26, 2022

    @shafferchance-lulu

    It would be a combination of @wlecki and a global declaration file.

  5. wlecki commented on Jan 12, 2023

    @wlecki
    ContributorAuthor

    @shafferchance-lulu could you please share a snippet of our namespace and interface merging via globals? Thanks!

  6. deevus commented on Jan 25, 2024

    @deevus
    Contributor

    Vite does a similar thing: https://vitejs.dev/guide/env-and-mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions