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

Support as const syntax for injection tokens #23

Closed
reiv opened this issue May 30, 2020 · 0 comments · Fixed by #27
Closed

Support as const syntax for injection tokens #23

reiv opened this issue May 30, 2020 · 0 comments · Fixed by #27

Comments

@reiv
Copy link

reiv commented May 30, 2020

Typescript 3.4 added a language feature to turn array literals into narrowly typed readonly tuples using the as const type assertion. It would improve the experience of typed-inject if we could use this syntax instead of having to import and use the tokens() helper function to specify dependencies. Right now it does not work because readonly arrays cannot be assigned to mutable arrays (which inject is assumed to be), so we get a type error in the provideXX() or injectXX() call.

As mentioned by @nicojs this would be a possible feature for a new (major) release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant