# deprecated-decorator

> A simple decorator for deprecated methods and properties.

Latest version **0.1.6** (published 2016-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install deprecated-decorator
pnpm add deprecated-decorator
yarn add deprecated-decorator
bun add deprecated-decorator
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2016-04-12 |
| First published | 2016-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | vilicvane |
| Maintainers | vilic |
| Keywords | deprecated, decorator, typescript, babel, es7 |

## Links

- npm: https://www.npmjs.com/package/deprecated-decorator
- Repository: https://github.com/vilic/deprecated-decorator
- Homepage: https://github.com/vilic/deprecated-decorator#readme
- Issues: https://github.com/vilic/deprecated-decorator/issues
- npm.io page: https://npm.io/package/deprecated-decorator

## 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

- 0.1.6 (latest) — 2016-04-12
- 0.1.5 — 2016-01-04
- 0.1.4 — 2016-01-04
- 0.1.3 — 2016-01-04
- 0.1.2 — 2016-01-03
- 0.1.1 — 2016-01-03
- 0.1.0 — 2016-01-03

## README

[![NPM Package](https://badge.fury.io/js/deprecated-decorator.svg)](https://www.npmjs.com/package/deprecated-decorator)
[![Build Status](https://travis-ci.org/vilic/deprecated-decorator.svg)](https://travis-ci.org/vilic/deprecated-decorator) 

# Deprecated Decorator

A simple decorator for deprecated properties, methods and classes. It can also wrap normal functions via the old-fashioned way.

Transpilers supported:

- **TypeScript** with `experimentalDecorators` option enabled.
- **Babel** with [transform-decorators-legacy](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy) for version 6.x.

## Install

```sh
npm install deprecated-decorator --save
```

## API References

```ts
export declare type DeprecatedDecorator = ClassDecorator & PropertyDecorator;

export interface DeprecatedOptions {
    alternative?: string;
    version?: string;
    url?: string;
}

export declare function deprecated(options?: DeprecatedOptions): DeprecatedDecorator;
export declare function deprecated(alternative?: string, version?: string, url?: string): DeprecatedDecorator;

export declare function deprecated<T extends Function>(fn: T): T;
export declare function deprecated<T extends Function>(options: DeprecatedOptions, fn: T): T;
export declare function deprecated<T extends Function>(alternative: string, fn: T): T;
export declare function deprecated<T extends Function>(alternative: string, version: string, fn: T): T;
export declare function deprecated<T extends Function>(alternative: string, version: string, url: string, fn: T): T;

export default deprecated;
```

## Usage

Decorating a class will enable warning on constructor and static methods (including static getters and setters):

```ts
import deprecated from 'deprecated-decorator';

// alternative, since version, url
@deprecated('Bar', '0.1.0', 'http://vane.life/')
class Foo {
    static method() { }
}
```

Or you can decorate methods respectively:

```ts
import deprecated from 'deprecated-decorator';

class Foo {
    @deprecated('otherMethod')
    method() { }
    
    @deprecated({
        alternative: 'otherProperty',
        version: '0.1.2',
        url: 'http://vane.life/'
    })
    get property() { }
}
```

For functions:

```ts
import deprecated from 'deprecated-decorator';

let foo = deprecated({
    alternative: 'bar',
    version: '0.1.0'
}, function foo() {
    // ...
});
```

## License

MIT License.

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