ing
This commit is contained in:
parent
1fb44fdb5f
commit
8fe2823519
|
@ -15,6 +15,7 @@
|
||||||
"test": "yarn run jest",
|
"test": "yarn run jest",
|
||||||
"test:watch": "yarn run jest -- --watch",
|
"test:watch": "yarn run jest -- --watch",
|
||||||
"jest": "PWD=$(pwd) NODE_ENV=test ./node_modules/.bin/jest -w 1 --coverage",
|
"jest": "PWD=$(pwd) NODE_ENV=test ./node_modules/.bin/jest -w 1 --coverage",
|
||||||
|
"build:dev": "set NODE_ENV=production && ./node_modules/.bin/webpack-dashboard -m -- ./node_modules/.bin/webpack --progress --profile --colors --config ./config/webpack/webpack.config.dev.js",
|
||||||
"build": "set NODE_ENV=production && ./node_modules/.bin/webpack-dashboard -m -- ./node_modules/.bin/webpack --progress --profile --colors --config ./config/webpack/webpack.config.prod.js",
|
"build": "set NODE_ENV=production && ./node_modules/.bin/webpack-dashboard -m -- ./node_modules/.bin/webpack --progress --profile --colors --config ./config/webpack/webpack.config.prod.js",
|
||||||
"lint": "./node_modules/.bin/tslint -c tslint.json 'src/ts/**/*.{ts,tsx}' && ./node_modules/.bin/sass-lint 'src/**/*.scss'",
|
"lint": "./node_modules/.bin/tslint -c tslint.json 'src/ts/**/*.{ts,tsx}' && ./node_modules/.bin/sass-lint 'src/**/*.scss'",
|
||||||
"stats": "set NODE_ENV=production && webpack --progress --config ./config/webpack/webpack.config.stats.js --profile --json > ./config/webpack/stats/stats.json"
|
"stats": "set NODE_ENV=production && webpack --progress --config ./config/webpack/webpack.config.stats.js --profile --json > ./config/webpack/stats/stats.json"
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {Method} from './method';
|
||||||
|
|
||||||
export class Class extends AccessibleObject {
|
export class Class extends AccessibleObject {
|
||||||
private _clazzType: ClassType;
|
private _clazzType: ClassType;
|
||||||
|
private _constructor: Constructor;
|
||||||
private _fields: Map<PropertyKeyType, Field>;
|
private _fields: Map<PropertyKeyType, Field>;
|
||||||
private _methods: Map<PropertyKeyType, Method>;
|
private _methods: Map<PropertyKeyType, Method>;
|
||||||
|
|
||||||
|
@ -31,6 +32,13 @@ export class Class extends AccessibleObject {
|
||||||
Metadata.set(LOAFER_CLASS, clazz, clazzType);
|
Metadata.set(LOAFER_CLASS, clazz, clazzType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === clazz._constructor) {
|
||||||
|
let parameterTypes = Metadata.getOwnParamTypes(clazzType);
|
||||||
|
if (undefined !== parameterTypes) {
|
||||||
|
clazz._constructor = new Constructor(clazz, parameterTypes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return clazz;
|
return clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +47,19 @@ export class Class extends AccessibleObject {
|
||||||
this._clazzType = clazzType;
|
this._clazzType = clazzType;
|
||||||
this._fields = new Map();
|
this._fields = new Map();
|
||||||
this._methods = new Map();
|
this._methods = new Map();
|
||||||
|
this._constructor = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* _defineField
|
||||||
|
*/
|
||||||
|
public _defineConstructor(parameterTypes: any[]): Constructor {
|
||||||
|
let cons: Constructor = this._constructor;
|
||||||
|
if (undefined === cons) {
|
||||||
|
cons = new Constructor(this, parameterTypes);
|
||||||
|
this._constructor = cons;
|
||||||
|
}
|
||||||
|
return cons;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +86,9 @@ export class Class extends AccessibleObject {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getConstructor(): Constructor {
|
||||||
|
return this._constructor;
|
||||||
|
}
|
||||||
|
|
||||||
public getOwnField(propertyKey: PropertyKeyType): Field {
|
public getOwnField(propertyKey: PropertyKeyType): Field {
|
||||||
return this._fields.get(propertyKey);
|
return this._fields.get(propertyKey);
|
||||||
|
|
|
@ -458,7 +458,7 @@ export class Metadata {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static getParamTypes(target: any, propertyKey?: PropertyKeyType): any[] {
|
public static getParamTypes(target: any, propertyKey?: PropertyKeyType): any[] {
|
||||||
return Reflect.getMetadata(DESIGN_PARAM_TYPES, target, propertyKey!) || [];
|
return Reflect.getMetadata(DESIGN_PARAM_TYPES, target, propertyKey!);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -490,7 +490,7 @@ export class Metadata {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static getOwnParamTypes(target: any, propertyKey?: PropertyKeyType): any[] {
|
public static getOwnParamTypes(target: any, propertyKey?: PropertyKeyType): any[] {
|
||||||
return Reflect.getOwnMetadata(DESIGN_PARAM_TYPES, target, propertyKey!) || [];
|
return Reflect.getOwnMetadata(DESIGN_PARAM_TYPES, target, propertyKey!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,14 @@ export class Decorator {
|
||||||
let field: Field = null;
|
let field: Field = null;
|
||||||
let method: Method = null;
|
let method: Method = null;
|
||||||
let parameter: Parameter = null;
|
let parameter: Parameter = null;
|
||||||
|
let cons: Constructor = null;
|
||||||
|
|
||||||
switch(decoratorType) {
|
switch(decoratorType) {
|
||||||
case DecoratorType.CLASS:
|
case DecoratorType.CLASS:
|
||||||
if (typeof(annotation.classDecorator) === 'undefined') {
|
if (typeof(annotation.classDecorator) === 'undefined') {
|
||||||
throw new Error(`Cannot apply @${name} decorator on Class.`);
|
throw new Error(`Cannot apply @${name} decorator on Class.`);
|
||||||
}
|
}
|
||||||
|
cons = clazz._defineConstructor(Metadata.getOwnParamTypes(target));
|
||||||
|
|
||||||
clazz._addAnnotation(annotation);
|
clazz._addAnnotation(annotation);
|
||||||
|
|
||||||
|
@ -57,7 +59,6 @@ export class Decorator {
|
||||||
if (typeof(annotation.methodDecorator) === 'undefined') {
|
if (typeof(annotation.methodDecorator) === 'undefined') {
|
||||||
throw new Error(`Cannot apply @${name} decorator on Method.`);
|
throw new Error(`Cannot apply @${name} decorator on Method.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
method = clazz._defineMethod(propertyKey,
|
method = clazz._defineMethod(propertyKey,
|
||||||
Metadata.getOwnParamTypes(target, propertyKey),
|
Metadata.getOwnParamTypes(target, propertyKey),
|
||||||
Metadata.getOwnReturnType(target, propertyKey));
|
Metadata.getOwnReturnType(target, propertyKey));
|
||||||
|
@ -69,10 +70,15 @@ export class Decorator {
|
||||||
throw new Error(`Cannot apply @${name} decorator on Parameter.`);
|
throw new Error(`Cannot apply @${name} decorator on Parameter.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (undefined === propertyKey) {
|
||||||
|
cons = clazz.getConstructor();
|
||||||
|
parameter = cons.getParameter(descriptorOrParameterIndex);
|
||||||
|
} else {
|
||||||
method = clazz._defineMethod(propertyKey,
|
method = clazz._defineMethod(propertyKey,
|
||||||
Metadata.getOwnParamTypes(target, propertyKey),
|
Metadata.getOwnParamTypes(target, propertyKey),
|
||||||
Metadata.getOwnReturnType(target, propertyKey));
|
Metadata.getOwnReturnType(target, propertyKey));
|
||||||
parameter = method.getParameter(descriptorOrParameterIndex);
|
parameter = method.getParameter(descriptorOrParameterIndex);
|
||||||
|
}
|
||||||
parameter._addAnnotation(annotation);
|
parameter._addAnnotation(annotation);
|
||||||
|
|
||||||
return annotation.parameterDecorator.call(annotation, target, propertyKey, descriptorOrParameterIndex);
|
return annotation.parameterDecorator.call(annotation, target, propertyKey, descriptorOrParameterIndex);
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
@ActionMapping('@overflow/modules/member/MemberReducer')
|
@ActionMapping('@overflow/modules/member/MemberReducer')
|
||||||
export default class MemberReducer {
|
export default class MemberReducer {
|
||||||
private name: string;
|
private name: string;
|
||||||
public constructor(@Parameter() name: string) {
|
public constructor(count: number, @Parameter() name: string) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user