Skip to content

More inferrence #10

@jackmellis

Description

@jackmellis

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions