File tree Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,17 @@ var Context = (function () {
3
3
}
4
4
Context . extend = //for plain JS version
5
5
function ( callback ) {
6
+ //return type isn't really void; void is used because otherwise TS gives this error when running `new MyContext(...`:
7
+ //"Call signatures used in a 'new' expression must have a 'void' return type."
6
8
return function ( ) {
7
9
var args = [ ] ;
8
10
for ( var _i = 0 ; _i < ( arguments . length - 0 ) ; _i ++ ) {
9
11
args [ _i ] = arguments [ _i + 0 ] ;
10
12
}
11
13
var context = new callback ( ) ;
14
+ if ( ! context . bindRoles )
15
+ throw new Error ( 'bindRoles() method not found' ) ;
16
+
12
17
context . bindRoles . apply ( callback , arguments ) ;
13
18
return context ;
14
19
} ;
Original file line number Diff line number Diff line change 1
1
export class Context
2
2
{
3
3
//for plain JS version
4
- static extend ( callback ) : Function {
5
- return function ( ...args : any [ ] ) {
4
+ static extend ( callback ) {
5
+ //return type isn't really void; void is used because otherwise TS gives this error when running `new MyContext(...`:
6
+ //"Call signatures used in a 'new' expression must have a 'void' return type."
7
+
8
+ return function ( ...args : any [ ] ) : void {
6
9
var context = new callback ( ) ;
10
+ if ( ! context . bindRoles ) throw new Error ( 'bindRoles() method not found' ) ;
11
+
7
12
context . bindRoles . apply ( callback , arguments ) ;
8
13
return context ;
9
14
}
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ var TransferMoney = require('./TransferMoney');
4
4
var src = new Account ( 20 ) ;
5
5
var dst = new Account ( 10 ) ;
6
6
7
- //var ctx = TransferMoney(src, dst, 10);
8
7
var ctx = new TransferMoney ( src , dst , 10 ) ;
9
8
10
9
ctx . execute ( ) ;
Original file line number Diff line number Diff line change @@ -4,16 +4,12 @@ import TransferMoney = require('./TransferMoney');
4
4
var src = new Account ( 20 ) ;
5
5
var dst = new Account ( 10 ) ;
6
6
7
-
8
- //var ctx = new TransferMoney(src, dst, 10);
9
-
10
-
11
- var ctx = TransferMoney ( src , dst , 10 ) ;
7
+ var ctx = new TransferMoney ( src , dst , 10 ) ;
12
8
13
9
ctx . execute ( ) ;
14
10
15
11
//ctx.bindRoles(dst, src, 50);
16
12
//ctx.execute();
17
13
18
14
console . log ( src . getBalance ( ) ) ;
19
- console . log ( dst . getBalance ( ) ) ;
15
+ console . log ( dst . getBalance ( ) ) ;
You can’t perform that action at this time.
0 commit comments