File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
core-decorator/src/decorator
types/core-decorator/model Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -36,14 +36,17 @@ export function Inject(param?: InjectParams | string) {
3636 function constructorInject ( target : any , parameterIndex : number ) {
3737 const argNames = ObjectUtils . getConstructorArgNameList ( target ) ;
3838 const argName = argNames [ parameterIndex ] ;
39- // TODO get objName from design:type
40- const objName = typeof param === 'string' ? param : param ?. name ;
4139 const injectObject : InjectConstructorInfo = {
4240 refIndex : parameterIndex ,
4341 refName : argName ,
44- objName : objName || argName ,
42+ // TODO get objName from design:type
43+ objName : injectParam ?. name || argName ,
4544 } ;
4645
46+ if ( injectParam ?. optional ) {
47+ injectObject . optional = true ;
48+ }
49+
4750 PrototypeUtil . setInjectType ( target , InjectType . CONSTRUCTOR ) ;
4851 PrototypeUtil . addInjectConstructor ( target as EggProtoImplClass , injectObject ) ;
4952 }
Original file line number Diff line number Diff line change @@ -13,4 +13,8 @@ export interface InjectConstructorInfo {
1313 * obj's name will be injected
1414 */
1515 objName : EggObjectName ;
16+ /**
17+ * optional inject
18+ */
19+ optional ?: boolean ;
1620}
You can’t perform that action at this time.
0 commit comments