# @enonic-types/global

> Global variables and functions type definition.

Latest version **8.0.4** (published 2026-08-12) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @enonic-types/global
pnpm add @enonic-types/global
yarn add @enonic-types/global
bun add @enonic-types/global
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 8.0.4 |
| Published | 2026-08-12 |
| First published | 2022-07-25 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 211 |
| Maintainers | alansemenov, edloidas |
| Keywords | enonic, enonic-xp, global, common, types, typescript |

## Links

- npm: https://www.npmjs.com/package/@enonic-types/global
- Repository: https://github.com/enonic/xp.git#master
- Homepage: https://github.com/enonic/xp/tree/master#readme
- Issues: https://github.com/enonic/xp/issues
- npm.io page: https://npm.io/package/@enonic-types/global

## Dependencies (1)

- [@enonic-types/core](https://npm.io/package/@enonic-types/core.md) 8.0.4

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 8.0.4 (latest) — 2026-08-12
- 8.1.0-RC2 (beta) — 2026-09-14
- 8.1.0-RC1 — 2026-09-09
- 8.1.0-B3 — 2026-09-07
- 8.1.0-B2 — 2026-09-02
- 8.1.0-B1 — 2026-08-27
- 7.16.8 — 2026-08-11
- 8.0.4-B2 — 2026-08-07
- 7.16.8-B1 — 2026-08-06
- 7.16.7 — 2026-07-10
- 8.0.4-B1 — 2026-07-09
- 7.16.7-RC1 — 2026-07-07
- 8.0.3 — 2026-07-02
- 7.16.6 — 2026-07-02
- 7.16.5 — 2026-06-12
- … 80 more at https://npm.io/package/@enonic-types/global/versions

## README

# Enonic XP global TS types

> TypeScript definitions for global variables of Enonic XP

## Install

```bash
npm i --save-dev @enonic-types/global
```

## Use

Add the corresponding types to your `tsconfig.json` file that is used for application's server-side TypeScript code:

```json
{
  "compilerOptions": {
    "types": [
      "@enonic-types/global"
    ]
  }
}
```

After that, all the global XP variables will be typed.

Import functions, such as `require`, will return typed objects if the corresponding types for imported libraries are also added to
your `tsconfig.json`.

## Configuration

### Require

To add support for type resolution for the custom libraries via `require`, you can redeclare the `XpLibraries` interface in global scope,
which will lead to declaration merging:

```ts
declare global {
    interface XpLibraries {
        '/lib/custom/mylib': typeof import('./mylib');
    }
}
```

#### Other imports

If you want to use custom import functions, like `__non_webpack_require__` with Webpack, just use global `XpRequire` type for this:

```ts
declare const __non_webpack_require__: XpRequire;
```

### Beans

To create a new bean, a `__.newBean()` function must be used. Making it return a proper type can be done in two ways. Say you have created
an interface for that been somewhere in your project:

```ts
interface SomeHelper {
    help(text: string): void;
}
```

#### Option 1

You can pass the type argument explicitly. This option is a bit cleaner.

```ts
const helper = __.newBean<SomeHelper>('com.me.project.SomeHelper');
```

#### Option 2

Or you can map the bean name to bean interface. It may be a preferable way to do it, if the bean is used across multiple files:

```ts
declare global {
    interface XpBeans {
        'com.me.project.SomeHelper': SomeHelper;
    }
}

const helper = __.newBean('com.me.project.SomeHelper');
```

---
_Source: https://npm.io/package/@enonic-types/global · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
