This commit is contained in:
Pete Gonzalez 2020-12-03 00:43:32 -08:00
Родитель 77c08544e9
Коммит 3ebdd5b5f5
2 изменённых файлов: 39 добавлений и 0 удалений

Просмотреть файл

@ -51,6 +51,8 @@ docs_nav:
url: /pages/tags/alpha
- title: '@beta'
url: /pages/tags/beta
- title: '@decorator'
url: /pages/tags/decorator
- title: '@deprecated'
url: /pages/tags/deprecated
- title: '@defaultValue'

37
pages/tags/decorator.md Normal file
Просмотреть файл

@ -0,0 +1,37 @@
---
layout: page
title: '@decorator'
navigation_source: docs_nav
---
| Standardization: | [Extended]({% link pages/spec/standardization_groups.md %}) |
| Syntax kind: | [Block tag]({% link pages/spec/tag_kinds.md %}) |
## Usage
[ECMAScript decorators](https://www.typescriptlang.org/docs/handbook/decorators.html) are sometimes an important part
of an API contract. However, today the TypeScript compiler does not represent decorators in the .d.ts output files
used by API consumers. The `@decorator` tag provides a workaround, enabling a decorator expression to be quoted
in a doc comment.
## Example
```ts
class Book {
/**
* The title of the book.
* @decorator `@jsonSerialized`
* @decorator `@jsonFormat(JsonFormats.Url)`
*/
@jsonSerialized
@jsonFormat(JsonFormats.Url)
public website: string;
}
```
## See also
- [RFC #271](https://github.com/microsoft/tsdoc/issues/271): `@decorator` tag for documenting ECMAScript decorators