Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More inferrence #10

Open
jackmellis opened this issue Aug 17, 2020 · 0 comments
Open

More inferrence #10

jackmellis opened this issue Aug 17, 2020 · 0 comments
Labels

Comments

@jackmellis
Copy link
Member

jackmellis commented Aug 17, 2020

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);
@jackmellis jackmellis transferred this issue from jpex-js/jpex Dec 10, 2020
@jackmellis jackmellis added enhancement New feature or request epic and removed enhancement New feature or request labels Dec 10, 2020
@jackmellis jackmellis changed the title Advanced inferrence More inferrence Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant