File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ export class ContainerInstance {
231231 return service . id === identifier ;
232232
233233 if ( service . type && identifier instanceof Function )
234- return service . type === identifier || identifier . prototype instanceof service . type ;
234+ return service . type === identifier ; // todo: not sure why it was here || identifier.prototype instanceof service.type;
235235
236236 return false ;
237237 } ) ;
Original file line number Diff line number Diff line change 1+ import "reflect-metadata" ;
2+ import { Container } from "../../../src/Container" ;
3+ import { Service } from "../../../src/decorators/Service" ;
4+ import { expect } from "chai" ;
5+
6+ describe ( "github issues > #56 extended class is being overwritten" , function ( ) {
7+
8+ beforeEach ( ( ) => Container . reset ( ) ) ;
9+
10+ it ( "should work properly" , function ( ) {
11+
12+ @Service ( )
13+ class Rule {
14+ getRule ( ) {
15+ return "very strict rule" ;
16+ }
17+ }
18+
19+ @Service ( )
20+ class Whitelist extends Rule {
21+ getWhitelist ( ) {
22+ return [ "rule1" , "rule2" ] ;
23+ }
24+ }
25+
26+ const whitelist = Container . get ( Whitelist ) ;
27+ expect ( whitelist . getRule ) . to . not . be . undefined ;
28+ expect ( whitelist . getWhitelist ) . to . not . be . undefined ;
29+ whitelist . getWhitelist ( ) . should . be . eql ( [ "rule1" , "rule2" ] ) ;
30+ whitelist . getRule ( ) . should . be . equal ( "very strict rule" ) ;
31+
32+ const rule = Container . get ( Rule ) ;
33+ expect ( rule . getRule ) . to . not . be . undefined ;
34+ expect ( ( rule as Whitelist ) . getWhitelist ) . to . be . undefined ;
35+ rule . getRule ( ) . should . be . equal ( "very strict rule" ) ;
36+ } ) ;
37+
38+ } ) ;
You can’t perform that action at this time.
0 commit comments