# @types/namespace-js

> TypeScript definitions for namespace-js

Latest version **0.0.4** (published 2023-11-07) · MIT license · 10 weekly downloads

## Install

```sh
npm install @types/namespace-js
pnpm add @types/namespace-js
yarn add @types/namespace-js
bun add @types/namespace-js
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; popular repo; extremely popular.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2023-11-07 |
| First published | 2023-06-06 |
| Weekly downloads | 10 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51420 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/namespace-js
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/namespace-js
- npm.io page: https://npm.io/package/@types/namespace-js

## Recent versions

- 0.0.4 (latest) — 2023-11-07
- 0.0.1 (ts4.3) — 2023-08-22
- 0.0.3 — 2023-10-18
- 0.0.2 — 2023-09-23
- 0.0.0 — 2023-06-06

## README

# Installation
> `npm install --save @types/namespace-js`

# Summary
This package contains type definitions for namespace-js (https://github.com/hirokidaichi/namespace-js).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/namespace-js.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/namespace-js/index.d.ts)
````ts
export as namespace Namespace;

export namespace NamespaceJs {
    type UserObject = object;
    type Fqn = string;
    type ImportName = string;
    // if you don't attach anything in use() function, ns is this type.
    type DotUserObject<Fqn, UserObject> = Fqn extends `${infer Fqn1}.${infer Fqn2}` ? {
            [P in Fqn1]: DotUserObject<Fqn2, UserObject>;
        }
        : {
            [P in Extract<Fqn, string>]: {
                [P in keyof UserObject]: UserObject[P];
            };
        };

    interface Definition<T extends UserObject> {
        define(
            callback: (
                ns: T & {
                    // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
                    provide: <U extends UserObject>(obj: U) => void;
                },
            ) => void,
        ): void;
    }

    interface Application<T extends UserObject> {
        use<U extends UserObject, Syntax>(
            syntax: Syntax,
        ): Syntax extends `${Fqn} ${ImportName}` ? Application<T & U>
            : Syntax extends string ? Application<DotUserObject<Syntax, T & U>>
            : never;
        apply(callback: (ns: T) => void): void;
    }
}

declare global {
    // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
    function Namespace<T extends NamespaceJs.UserObject>(fqn: NamespaceJs.Fqn): NamespaceJs.Definition<T>;
}

export const use: NamespaceJs.Application<{}>["use"];
export const apply: NamespaceJs.Application<{}>["apply"];

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 09:09:39 GMT
 * Dependencies: none

# Credits
These definitions were written by [kuromoka](https://github.com/kuromoka).

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