-
Notifications
You must be signed in to change notification settings - Fork 0
More inferrence #10
Copy link
Copy link
Open
Labels
Description
More Inferrence
Some advanced things I'd like to be able to handle in the future:
Interface inheritance
interface Foo extends Bah {}
jpex.factory<Foo>(fn);
jpex.resolve<Bah>();where Foo can be substituted for Bah during resolution
Shape inference
Rather than named types it'd be great if you could just provide a shape and we can check the shape of our deps
interface Foo { color: string }
jpex.constant<Foo>({ color: 'blue' });
// somehow we can work out that this shape matches Foo
const foo = jpex.resolve<{ color: string }>();The crux of all this is that babel does isolated modules so all you have to go on is the imported type name.
Variable names
Ability to check if the dependency name is a variable. Right now we only check if the first parameter is a string literal.
// works
jpex.factory('foo', foo);
// does not work
const name = 'foo';
jpex.factory(name, foo);Reactions are currently unavailable