<!-- thumbnail: https://example.com/some-image.png --> <!-- version: 1.1.1 --> <!-- tag: library --> <!-- excerpt: Stack Exchange global types adds or augments type definitions for global objects exposed by Stack Exchange to aid userscript authors --> ## Screenshot / Code Snippet [![animated usage example][1]][1] ## 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][2] package | Adds missing classes and helper methods like `showModal`/`hideModal` (see [example usage][3] 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][4] license. ### Download Type declarations are available as a [GitHub package][5] and can be installed via a package manager like NPM as usual: ```shell 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: ```npmrc @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][6] Organization: [UserScripters][7] Please, submit bug reports on the [source repository][8]. Before adding a new one, please check if it hasn't been raised before. You can also [drop by to chat][9], we are a friendly bunch. ## Code [Source code][10] is written TypeScript (`d.ts` declaration files). The project is using `dtslint` (see [repo][11]) for unit-testing types. Contributions are welcome, you can always submit a [PR here][12]. [1]: https://i.sstatic.net/v21na.gif [2]: https://www.npmjs.com/package/@stackoverflow/stacks [3]: https://stackoverflow.design/product/components/modals/#helpers [4]: https://spdx.org/licenses/GPL-3.0-or-later [5]: https://github.com/userscripters/stackexchange-global-types/releases/tag/v1.1.1 [6]: https://stackoverflow.com/users/11407695/oleg-valter [7]: https://github.com/userscripters [8]: https://github.com/userscripters/stackexchange-global-types/issues [9]: https://chat.stackoverflow.com/rooms/214345/userscript-newbies-and-friends [10]: https://github.com/userscripters/stackexchange-global-types/blob/master/index.d.ts [11]: https://github.com/microsoft/dtslint [12]: https://github.com/userscripters/stackexchange-global-types/pulls