@@ -24,15 +24,15 @@ export type ResolutionAction = (
24
24
*/
25
25
export interface BindingElement {
26
26
type : 'binding' ;
27
- value : Binding ;
27
+ value : Readonly < Binding > ;
28
28
}
29
29
30
30
/**
31
31
* Wrapper for injections tracked by resolution sessions
32
32
*/
33
33
export interface InjectionElement {
34
34
type : 'injection' ;
35
- value : Injection ;
35
+ value : Readonly < Injection > ;
36
36
}
37
37
38
38
/**
@@ -90,7 +90,7 @@ export class ResolutionSession {
90
90
* @param session The current resolution session
91
91
*/
92
92
private static enterBinding (
93
- binding : Binding ,
93
+ binding : Readonly < Binding > ,
94
94
session ?: ResolutionSession ,
95
95
) : ResolutionSession {
96
96
session = session || new ResolutionSession ( ) ;
@@ -106,7 +106,7 @@ export class ResolutionSession {
106
106
*/
107
107
static runWithBinding (
108
108
action : ResolutionAction ,
109
- binding : Binding ,
109
+ binding : Readonly < Binding > ,
110
110
session ?: ResolutionSession ,
111
111
) {
112
112
const resolutionSession = ResolutionSession . enterBinding ( binding , session ) ;
@@ -122,7 +122,7 @@ export class ResolutionSession {
122
122
* @param session The current resolution session
123
123
*/
124
124
private static enterInjection (
125
- injection : Injection ,
125
+ injection : Readonly < Injection > ,
126
126
session ?: ResolutionSession ,
127
127
) : ResolutionSession {
128
128
session = session || new ResolutionSession ( ) ;
@@ -138,7 +138,7 @@ export class ResolutionSession {
138
138
*/
139
139
static runWithInjection (
140
140
action : ResolutionAction ,
141
- injection : Injection ,
141
+ injection : Readonly < Injection > ,
142
142
session ?: ResolutionSession ,
143
143
) {
144
144
const resolutionSession = ResolutionSession . enterInjection (
@@ -155,7 +155,7 @@ export class ResolutionSession {
155
155
* Describe the injection for debugging purpose
156
156
* @param injection Injection object
157
157
*/
158
- static describeInjection ( injection ?: Injection ) {
158
+ static describeInjection ( injection ?: Readonly < Injection > ) {
159
159
/* istanbul ignore if */
160
160
if ( injection == null ) return undefined ;
161
161
const name = getTargetName (
@@ -175,7 +175,7 @@ export class ResolutionSession {
175
175
* Push the injection onto the session
176
176
* @param injection Injection The current injection
177
177
*/
178
- pushInjection ( injection : Injection ) {
178
+ pushInjection ( injection : Readonly < Injection > ) {
179
179
/* istanbul ignore if */
180
180
if ( debugSession . enabled ) {
181
181
debugSession (
@@ -214,7 +214,7 @@ export class ResolutionSession {
214
214
/**
215
215
* Getter for the current injection
216
216
*/
217
- get currentInjection ( ) : Injection | undefined {
217
+ get currentInjection ( ) : Readonly < Injection > | undefined {
218
218
for ( let i = this . stack . length - 1 ; i >= 0 ; i -- ) {
219
219
const element = this . stack [ i ] ;
220
220
if ( isInjection ( element ) ) return element . value ;
@@ -225,7 +225,7 @@ export class ResolutionSession {
225
225
/**
226
226
* Getter for the current binding
227
227
*/
228
- get currentBinding ( ) : Binding | undefined {
228
+ get currentBinding ( ) : Readonly < Binding > | undefined {
229
229
for ( let i = this . stack . length - 1 ; i >= 0 ; i -- ) {
230
230
const element = this . stack [ i ] ;
231
231
if ( isBinding ( element ) ) return element . value ;
@@ -237,7 +237,7 @@ export class ResolutionSession {
237
237
* Enter the resolution of the given binding. If
238
238
* @param binding Binding
239
239
*/
240
- pushBinding ( binding : Binding ) {
240
+ pushBinding ( binding : Readonly < Binding > ) {
241
241
/* istanbul ignore if */
242
242
if ( debugSession . enabled ) {
243
243
debugSession ( 'Enter binding:' , binding . toJSON ( ) ) ;
@@ -260,7 +260,7 @@ export class ResolutionSession {
260
260
/**
261
261
* Exit the resolution of a binding
262
262
*/
263
- popBinding ( ) {
263
+ popBinding ( ) : Readonly < Binding > {
264
264
const top = this . stack . pop ( ) ;
265
265
if ( ! isBinding ( top ) ) {
266
266
throw new Error ( 'The top element must be a binding' ) ;
@@ -277,14 +277,14 @@ export class ResolutionSession {
277
277
/**
278
278
* Getter for bindings on the stack
279
279
*/
280
- get bindingStack ( ) : Binding [ ] {
280
+ get bindingStack ( ) : Readonly < Binding > [ ] {
281
281
return this . stack . filter ( isBinding ) . map ( e => e . value ) ;
282
282
}
283
283
284
284
/**
285
285
* Getter for injections on the stack
286
286
*/
287
- get injectionStack ( ) : Injection [ ] {
287
+ get injectionStack ( ) : Readonly < Injection > [ ] {
288
288
return this . stack . filter ( isInjection ) . map ( e => e . value ) ;
289
289
}
290
290
0 commit comments