/* eslint max-classes-per-file: ["error", 20] */ import { describe, it } from "mocha"; import {LifetimeManager} from "../LifetimeManager"; import {Container} from "../Container"; import { fluent } from "../traits"; class Foo { foo = "foo"; } class Bar { bar = "bar"; constructor(foo?: () => Foo) {} } interface Services { foo: Foo; bar?: Bar; baz: Foo; } interface ServicesB { // will give errors // baz: Bar; baz: Foo; zoo?: Foo; } interface SharedServices { foo: Foo; bar?: Bar; baz: Bar; } const config = fluent() .declare() .declare() .register({ bar: it => it .lifetime("context") .factory($ => new Bar($("zoo", {lazy: true, default: new Foo()}))), foo: it => it.factory($ => new Foo()), baz: it => it.value(new Foo()) }) .done({}); declare const container: Container; const c2 = config.apply(container); c2.resolve("baz");