Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Entity decorator return type to ClassDecorator #5776

Merged
merged 1 commit into from May 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/decorator/entity/Entity.ts
Expand Up @@ -5,23 +5,23 @@ import {TableMetadataArgs} from "../../metadata-args/TableMetadataArgs";
* This decorator is used to mark classes that will be an entity (table or document depend on database type).
* Database schema will be created for all classes decorated with it, and Repository can be retrieved and used for it.
*/
export function Entity(options?: EntityOptions): Function;
export function Entity(options?: EntityOptions): ClassDecorator;

/**
* This decorator is used to mark classes that will be an entity (table or document depend on database type).
* Database schema will be created for all classes decorated with it, and Repository can be retrieved and used for it.
*/
export function Entity(name?: string, options?: EntityOptions): Function;
export function Entity(name?: string, options?: EntityOptions): ClassDecorator;

/**
* This decorator is used to mark classes that will be an entity (table or document depend on database type).
* Database schema will be created for all classes decorated with it, and Repository can be retrieved and used for it.
*/
export function Entity(nameOrOptions?: string|EntityOptions, maybeOptions?: EntityOptions): Function {
export function Entity(nameOrOptions?: string|EntityOptions, maybeOptions?: EntityOptions): ClassDecorator {
const options = (typeof nameOrOptions === "object" ? nameOrOptions as EntityOptions : maybeOptions) || {};
const name = typeof nameOrOptions === "string" ? nameOrOptions : options.name;

return function (target: Function) {
return function (target) {
getMetadataArgsStorage().tables.push({
target: target,
name: name,
Expand Down