[I] DecoratorContext
Context passed to decorator implementations.
Extends
Section titled “Extends”InvocationContext
Properties
Section titled “Properties”| Property | Type | Description | Overrides |
|---|---|---|---|
decoratorTarget | DiagnosticTarget | The diagnostic target for the decorator application. | - |
program | Program | The current TypeSpec Program. | InvocationContext.program |
Methods
Section titled “Methods”call()
Section titled “call()”call<T, A, R>( decorator, target, ... args): R;Helper to call a decorator implementation from within another decorator implementation.
This function is identical to callDecorator.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends Type |
A extends any[] |
R |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
decorator | (context, target, …args) => R | The decorator function to call. |
target | T | The target to which the decorator is applied. |
…args | A | Arguments to pass to the decorator. |
Returns
Section titled “Returns”R
callDecorator()
Section titled “callDecorator()”callDecorator<T, A, R>( decorator, target, ... args): R;Helper to call a decorator implementation from within another decorator implementation.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T extends Type |
A extends any[] |
R |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
decorator | (context, target, …args) => R | The decorator function to call. |
target | T | The target to which the decorator is applied. |
…args | A | Arguments to pass to the decorator. |
Returns
Section titled “Returns”R
Inherited from
Section titled “Inherited from”InvocationContext.callDecoratorcallFunction()
Section titled “callFunction()”callFunction<A, R>(func, ...args): R;Helper to call a function implementation from within a decorator implementation.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
A extends any[] |
R |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
func | (context, …args) => R | The function implementation to call. |
…args | A | Arguments to pass to the function. |
Returns
Section titled “Returns”R
Inherited from
Section titled “Inherited from”InvocationContext.callFunctiongetArgumentTarget()
Section titled “getArgumentTarget()”getArgumentTarget(argIndex): DiagnosticTarget | undefined;Helper to get the target for a given argument index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
argIndex | number | Argument index in the decorator call. |
Returns
Section titled “Returns”DiagnosticTarget | undefined
Example
Section titled “Example”@dec("hello", 123)model MyModel { }getArgumentTarget(0)-> target for “hello”getArgumentTarget(1)-> target for 123
Inherited from
Section titled “Inherited from”InvocationContext.getArgumentTarget