diff --git a/packages/spec/src/spec.emu.html b/packages/spec/src/spec.emu.html index 9e4dc311c1..6ecca654fa 100644 --- a/packages/spec/src/spec.emu.html +++ b/packages/spec/src/spec.emu.html @@ -372,7 +372,7 @@

Syntactic Grammar

`...` ReferenceExpression InterfaceStatement : - `interface` Identifier TemplateParameters? InterfaceHeritage? `{` InterfaceBody? `}` + DecoratorList? `interface` Identifier TemplateParameters? InterfaceHeritage? `{` InterfaceBody? `}` InterfaceHeritage : `extends` ReferenceExpressionList; diff --git a/website/src/content/docs/docs/language-basics/decorators.md b/website/src/content/docs/docs/language-basics/decorators.md index 9397bb12f5..5d2e1369a7 100644 --- a/website/src/content/docs/docs/language-basics/decorators.md +++ b/website/src/content/docs/docs/language-basics/decorators.md @@ -5,7 +5,18 @@ title: Decorators Decorators in TypeSpec allow developers to attach metadata to types within a TypeSpec program. They can also be used to compute types based on their inputs. Decorators form the core of TypeSpec's extensibility, providing the flexibility to describe a wide variety of APIs and associated metadata such as documentation, constraints, samples, and more. -A range of TypeSpec constructs can be decorated, including [namespaces](./namespaces.md), [operations](./operations.md) and their parameters, and [models](./models.md) and their members. +Various elements of TypeSpec can be decorated. +Examples include the following, + +* [enums](./enums.md) +* [interfaces](./interfaces.md) +* [models](./models.md) +* [namespaces](./namespaces.md) +* [operations](./operations.md) +* [scalar](./scalars.md) +* [unions](./unions.md) + +and their parameters or members. Decorators are defined using JavaScript functions that are exported from a standard ECMAScript module. When a JavaScript file is imported, TypeSpec will look for any exported functions prefixed with `$`, and make them available as decorators within the TypeSpec syntax. When a decorated declaration is evaluated by TypeSpec, the decorator function is invoked, passing along a reference to the current compilation, an object representing the type it is attached to, and any arguments the user provided to the decorator.