question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: make use of injection-js

See original GitHub issue

I’m submitting a…


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

  • At this time we cannot use InjectionToken, an Angular-like feature, and have to manually type string to @Inject (I could not use const variable too, see my comment )

UPDATE: I have figured out this is an limitation of Nest when you could not declare token in the same file with Module. That’s why I propose that we should use injection-js instead current DI system.

  • Lack of type checking for components array declaration in Module. In Angular when we try to declare providers in @NgModule, we have nice type checking and auto completion. But we we don’t have that nice feature in Nestjs @Module components declaration.

Expected behavior

We should make use of injectable-js, a light weight and well tested DI framework extracted from Angular core v4.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

With that we can support InjectionToken for creating unique token across application as well as reuse code across server and client side. (Token in Angular use InjectionToken)

Environment


Nest version: 4.6.0

 
For Tooling issues:
- Node version: 8.9.4  
- Platform:  Mac

Others:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
shekohexcommented, Feb 16, 2018

Hi @sandangel That sounds strange to me, Nest Is using Reflection under the hood , maybe imo it is a limitation of the library reflect-metadata or Typescript idk, but Angular or injection-js using another approach but it is the same concept. due to some limitation on the browser, and you know Angular SHOULD have support for massive number of browsers. actually, about month ago, I was playing with Injection-js and decided to create a simple core framework for learning purpose, something like Nest, but instead of creating my own Depancy Injection Engine, I prefered to go with Angular’s, here is a minimal repo: Core 101. I learned a lot of techniques and how Angular or Nest works. anyway, I think there is no reason to change the Nest DI Engine with Angular’s one. Hope this will help you.

0reactions
lock[bot]commented, Sep 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proposal to allow drug injection sites spurs debate
Delaware County Sheriff Craig DuMond said allowing drug use at the sites would only facilitate addiction to potentially deadly narcotics. “We ...
Read more >
California debates opening supervised sites for people to use ...
A man uses a safe injection site in New York City in January. A bill in California would allow pilot sites in San...
Read more >
A Proposal for Botulinum Toxin Type A Injection Into ... - NCBI
Botulinum toxin type-A (BTX-A) injection for treating chronic migraine (CM) has developed into a new technique covering distinct injection ...
Read more >
Denver heroin users could use supervised injection site if ...
Denver heroin users could use supervised injection site if proposal passes multiple hurdles. Legislative committee gives initial approval as ...
Read more >
Governor Newsom Vetoes Bill for Drug-Injection Sites in ...
The proposal would have made the nation's most populous state home to its broadest experiment with supervised injection sites, where people ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found