##// END OF EJS Templates
fixed object activation when a single argument passed to the constructor.
cin -
r46:747292a4f3ac di-typescript
parent child
Show More
@@ -84,7 +84,7
84 84 },
85 85 "duplexer": {
86 86 "version": "0.1.1",
87 "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
87 "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
88 88 "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=",
89 89 "dev": true
90 90 },
@@ -129,7 +129,7
129 129 "dependencies": {
130 130 "tape": {
131 131 "version": "2.3.3",
132 "resolved": "https://registry.npmjs.org/tape/-/tape-2.3.3.tgz",
132 "resolved": "http://registry.npmjs.org/tape/-/tape-2.3.3.tgz",
133 133 "integrity": "sha1-Lnzgox3wn41oUWZKcYQuDKUFevc=",
134 134 "dev": true,
135 135 "requires": {
@@ -289,7 +289,7
289 289 },
290 290 "path-is-absolute": {
291 291 "version": "1.0.1",
292 "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
292 "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
293 293 "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
294 294 "dev": true
295 295 },
@@ -301,7 +301,7
301 301 },
302 302 "readable-stream": {
303 303 "version": "1.1.14",
304 "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
304 "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
305 305 "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
306 306 "dev": true,
307 307 "requires": {
@@ -354,7 +354,7
354 354 },
355 355 "string_decoder": {
356 356 "version": "0.10.31",
357 "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
357 "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
358 358 "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
359 359 "dev": true
360 360 },
@@ -411,13 +411,13
411 411 },
412 412 "through": {
413 413 "version": "2.3.8",
414 "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
414 "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz",
415 415 "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
416 416 "dev": true
417 417 },
418 418 "through2": {
419 419 "version": "0.2.3",
420 "resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz",
420 "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz",
421 421 "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=",
422 422 "dev": true,
423 423 "requires": {
@@ -140,7 +140,7 export class Configuration {
140 140 }
141 141
142 142 async _loadModule(moduleName: string) {
143 trace.log("loadModule {0}", moduleName);
143 trace.debug("loadModule {0}", moduleName);
144 144
145 145 const m = await new Promise(fulfill => {
146 146 this._require([moduleName], fulfill);
@@ -229,7 +229,6 export class ServiceDescriptor implement
229 229 injectMethod(instance, m, context, spec[m]);
230 230 });
231 231 }
232
233 232 return instance;
234 233 }
235 234 }
@@ -15,13 +15,19 export class TypeServiceDescriptor exten
15 15
16 16 const ctor = this._type = opts.type;
17 17
18 if (this._params && this._params.length) {
18 if (this._params) {
19 if (this._params.length) {
19 20 this._factory = (...args) => {
20 21 const t = Object.create(ctor.prototype);
21 22 const inst = ctor.apply(t, args);
22 23 return isPrimitive(inst) ? t : inst;
23 24 };
24 25 } else {
26 this._factory = arg => {
27 return new ctor(arg);
28 };
29 }
30 } else {
25 31 this._factory = () => {
26 32 return new ctor();
27 33 };
@@ -10,6 +10,9 define({
10 10 provider: {
11 11 $dependency: "db"
12 12 }
13 },
14 foo: {
15 $type: "./Foo:Foo"
13 16 }
14 17 }
15 18 },
@@ -87,7 +87,8 test("Load configuration from module", a
87 87
88 88 t.assert(!isNull(f1), "foo should be not null");
89 89
90 const b1 = container.resolve("bar");
90 const b1 = container.resolve("bar") as Bar;
91 91
92 t.assert(!isNull(b1), "foo should be not null");
92 t.assert(!isNull(b1), "bar should not be null");
93 t.assert(!isNull(b1.foo), "bar.foo should not be null");
93 94 });
@@ -1,3 +1,12
1 import { Foo } from "./Foo";
2
1 3 export class Bar {
2 4 name = "bar";
5
6 foo: Foo;
7
8 constructor(_opts) {
9 if (_opts && _opts.foo)
10 this.foo = _opts.foo;
3 11 }
12 }
General Comments 0
You need to be logged in to leave comments. Login now