@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
81 lines (41 loc) • 1.28 kB
Markdown
---
lang: en
title: 'API docs: metadata.decoratorfactory.withtarget'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/metadata
permalink: /doc/en/lb4/apidocs.metadata.decoratorfactory.withtarget.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/metadata](./metadata.md) > [DecoratorFactory](./metadata.decoratorfactory.md) > [withTarget](./metadata.decoratorfactory.withtarget.md)
## DecoratorFactory.withTarget() method
Set a reference to the target class or prototype for a given spec if it's an object
**Signature:**
```typescript
withTarget(spec: T, target: Object): T;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
spec
</td><td markdown="1">
T
</td><td markdown="1">
Metadata spec
</td></tr>
<tr><td markdown="1">
target
</td><td markdown="1">
Object
</td><td markdown="1">
Target of the decoration. It is a class or the prototype of a class.
</td></tr>
</tbody></table>
**Returns:**
T