Skip to main content
2 of 21
edited tags
rene
  • 2.8k
  • 2
  • 17
  • 35

Stack Exchange Global Types - a type declaration package for global objects exposed by Stack Exchange

Screenshot / Code Snippet

animated usage example

About

Stack Exchange global types is a type declaration package adding or augmenting type definitions for global objects exposed by Stack Exchange for client-side consumption on pages of network sites. Currently, the package includes the following:

Features Definitions/augmentations Known Limitations
augments Stacks exposed by the @stackoverflow/stacks package Adds missing classes and helper methods like showModal/hideModal (see example usage in official Stacks docs)
adds type definitions for StackExchange object (exposed on all pages on the network sites) Full definition (for example, StackExchange.options.user.isRegistered) - as most of the Stack Exchange codebase is not open-source, so there are no type definitions available to augment v1.1.1 only includes some of the exposed helper methods as each needs to be tested

License

The script is licensed under the GPL-3.0-or-later license.

Download

Type declarations are available as a GitHub package and can be installed via a package manager like NPM as usual:

npm install --save-dev @userscripters/stackexchange-global-types

As GitHub only supports scoped packages, you will need a simple .npmrc file at your project root:

@userscripters:registry=https://npm.pkg.github.com

An NPM package is planned to be released in the near future.

Platform

The type declarations are intended to be used with TypeScript/JavaScript projects targeting browsers.

Contact

Author: Oleg Valter Organization: UserScripters

Please, submit bug reports on the source repository. Before adding a new one, please check if it hasn't been raised before.

You can also drop by to chat, we are a friendly bunch.

Code

Source code is written TypeScript (d.ts declaration files).

The project is using dtslint (see repo) for unit-testing types.

Contributions are welcome, you can always submit a PR here.

0Valt
  • 1.4k
  • 4
  • 16