-
Notifications
You must be signed in to change notification settings - Fork 2
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
Support Generically Typed Implementations #4
base: main
Are you sure you want to change the base?
Conversation
@@ -21,7 +21,8 @@ | |||
"mock" | |||
], | |||
"dependencies": { | |||
"typescript-rtti": "^0.4.16" | |||
"deep-equal": "^2.0.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think I don't need this here
|
||
// if it's a generic ref, lookup the specific match we put in the map | ||
if( token instanceof ReflectedGenericRef && token.isGeneric()){ | ||
token = this.#generics.find(t => t.matchesRef(token)) || token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming matchesRef(..)
works out, we can essentially resolve the token here with a simple list of generic tokens, then let things play out as normal :)
@@ -206,6 +223,9 @@ export class Injector { | |||
return { tokens: [ typeRef.token ] }; | |||
else if (typeRef.isLiteral()) | |||
return { tokens: [ typeRef.value.constructor ]} | |||
else if (typeRef.isGeneric() ) | |||
// TODO: ask @rezonant for a better way to handle this | |||
return { tokens: [ typeRef ]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking this is good now. Essentially we support the ref itself as an actual token (and presume our token resolution will unify different instances)
Brought us up to the 0.5.0 cut of rtti, and added a first stab at supporting generic tokens.
Probably a much smarter way of both creating the provider + resolving the tokens, but I was able to "break all teh tests" and then repair them with this simple approach.
Def open to feedback. But it's working on my use case really nicely, so gives me hope :)