Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How do I handle types of other extensions? #17

Closed
lens0021 opened this issue Sep 16, 2021 · 2 comments
Closed

[Question] How do I handle types of other extensions? #17

lens0021 opened this issue Sep 16, 2021 · 2 comments

Comments

@lens0021
Copy link
Contributor

Hi, If this is not a suitable place for questions, feel free to close this issue.
As a skin developer, I have called to some variables defined in extensions like below without @wikimedia/types-wikimedia.

code:

/** @type {EchoApi} */ var echoApi = new mw.echo.api.EchoApi();

.d.ts:

interface EchoApi {}
interface MediaWiki {
  echo: {
    api: {
      EchoApi: {
        new (): EchoApi;
      };
    };
  };
}

declare const mw: MediaWiki;

And I want to replace it with the library but I don't know how to. I think I have two options:

  • Adding definitions for extensions to this repository.
  • Extending types-wikimedia in my own skin.

About the second option, I couldn't find the syntax to extend global mw. (It may be because I am not familiar with TypeScript.)
What should I do?

Regards.

@jdlrobson
Copy link
Member

Good question. Ideally I think they'd be exported by the extension via npm, however we already had this problem with eventLog(Extension:EventLogging) and documented here so I think it would be fine to document in this repo for now https://github.com/wikimedia/typescript-types/blob/master/MediaWiki.d.ts#L79

@lens0021
Copy link
Contributor Author

I see, thank you for answering!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants