@@ -55,24 +55,17 @@ export class BindTargetParser {
55
55
filePath : string ,
56
56
scope ?: BindTargetScope ,
57
57
) : BindTargetDeclaration {
58
- const bindTargetDeclaration : BindTargetDeclaration = { } as BindTargetDeclaration ;
59
-
60
- // listen to children
61
- bindTargetDeclaration . listenToChildren = unvalidatedBindTargetDeclaration . listenToChildren ;
62
-
63
58
// storage prop
64
- bindTargetDeclaration . storageProp = new PropPath (
59
+ const storageProp = new PropPath (
65
60
unvalidatedBindTargetDeclaration . storageProp . map ( x => new PropAccess ( x . type , x . prop . value ) ) ,
66
61
) ;
67
62
68
63
// storage type
64
+ let storageType : string ;
69
65
if ( unvalidatedBindTargetDeclaration . storageType === undefined ) {
70
- bindTargetDeclaration . storageType = this . mb . metadataManager . defaultSource ;
66
+ storageType = this . mb . metadataManager . defaultSource ;
71
67
} else {
72
- bindTargetDeclaration . storageType = this . validateStorageType (
73
- unvalidatedBindTargetDeclaration . storageType ,
74
- fullDeclaration ,
75
- ) ;
68
+ storageType = this . validateStorageType ( unvalidatedBindTargetDeclaration . storageType , fullDeclaration ) ;
76
69
}
77
70
78
71
// storage path
@@ -81,25 +74,28 @@ export class BindTargetParser {
81
74
value : filePath ,
82
75
} ;
83
76
84
- const source = this . mb . metadataManager . getSource ( bindTargetDeclaration . storageType ) ;
77
+ const source = this . mb . metadataManager . getSource ( storageType ) ;
85
78
if ( source === undefined ) {
86
79
throw new MetaBindInternalError ( {
87
80
errorLevel : ErrorLevel . CRITICAL ,
88
81
effect : 'can not validate bind target' ,
89
- cause : `Source '${ bindTargetDeclaration . storageType } ' not found. But validation was successful. This should not happen.` ,
82
+ cause : `Source '${ storageType } ' not found. But validation was successful. This should not happen.` ,
90
83
context : {
91
84
fullDeclaration : fullDeclaration ,
92
85
sources : [ ...this . mb . metadataManager . sources . keys ( ) ] ,
93
86
} ,
94
87
} ) ;
95
88
}
96
89
97
- bindTargetDeclaration . storagePath = source . validateStoragePath (
98
- storagePathToValidate ,
99
- hadStoragePath ,
100
- fullDeclaration ,
101
- this ,
102
- ) ;
90
+ const storagePath = source . validateStoragePath ( storagePathToValidate , hadStoragePath , fullDeclaration , this ) ;
91
+
92
+ // construct bind target declaration
93
+ const bindTargetDeclaration : BindTargetDeclaration = {
94
+ storageType : storageType ,
95
+ storagePath : storagePath ,
96
+ storageProp : storageProp ,
97
+ listenToChildren : unvalidatedBindTargetDeclaration . listenToChildren ,
98
+ } ;
103
99
104
100
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
105
101
if ( source . id === BindTargetStorageType . SCOPE ) {
0 commit comments