This commit is contained in:
crusader 2018-09-06 12:30:22 +09:00
parent e81ce83303
commit fba9e42c4e
3 changed files with 11 additions and 10 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@overflow/core-js", "name": "@overflow/core-js",
"version": "0.0.7", "version": "0.0.10",
"description": "TypeScript library setup for multiple compilation targets using tsc and webpack", "description": "TypeScript library setup for multiple compilation targets using tsc and webpack",
"main": "./bundles/index.umd.js", "main": "./bundles/index.umd.js",
"module": "./esm5/index.js", "module": "./esm5/index.js",

View File

@ -14,7 +14,7 @@ export interface Decorator<Attribute = {}> {
parameterDecorator?: (target: Object, propertyKey: PropertyKeyType, parameterIndex: number) => void; parameterDecorator?: (target: Object, propertyKey: PropertyKeyType, parameterIndex: number) => void;
} }
export abstract class Decorator<Attribute = {}> extends Annotation { export abstract class Decorator<Attribute = {}> extends Annotation<Attribute> {
public constructor(attribute?: Attribute) { public constructor(attribute?: Attribute) {
super(attribute); super(attribute);

View File

@ -6,7 +6,6 @@ import {
} from '../core'; } from '../core';
import { import {
Annotation,
Class, Class,
Constructor, Constructor,
Field, Field,
@ -23,19 +22,21 @@ import { Decorator } from './Decorator';
export class DecoratorHelper { export class DecoratorHelper {
public static register<AttributeType>(attribute: AttributeType, ...decoratorArgs: any[]) { public static register<Attribute = {}>(DecoratorClass: Type<Decorator<Attribute>>, attribute?: Attribute) {
const annotation = new Annotation<AttributeType>(attribute); const annotation: Decorator<Attribute> = new DecoratorClass(attribute);
const name: string = Annotation.name; const name: string = DecoratorClass.name;
DecoratorHelper.registerAnnotation(name, annotation, decoratorArgs); return function (...decoratorArgs: any[]) {
return DecoratorHelper.registerAnnotation(name, annotation, decoratorArgs);
};
} }
public static create = <Attribute = {}>(DecoratorClass: Type<Decorator<Attribute>>) => { public static create<Attribute = {}>(DecoratorClass: Type<Decorator<Attribute>>) {
return (attribute: Attribute) => { return function (attribute?: Attribute) {
const annotation: Decorator<Attribute> = new DecoratorClass(attribute); const annotation: Decorator<Attribute> = new DecoratorClass(attribute);
const name: string = DecoratorClass.name; const name: string = DecoratorClass.name;
return (...decoratorArgs: any[]) => { return function (...decoratorArgs: any[]) {
return DecoratorHelper.registerAnnotation(name, annotation, decoratorArgs); return DecoratorHelper.registerAnnotation(name, annotation, decoratorArgs);
}; };
}; };