Add typed InjectionToken<...> constants to piral-ng and use them when providing piral, Props and Context using those tokens in the dependency injection container.
Description
For downward-compatibility the string-based providers should probably be kept.
The relevant source code parts are:
Some application developers prefer the new inject(...) funtion over the classic @Inject(...) annotation.
inject is typed more strictly, it does not allow a simple string parameter anymore, like @Inject.
So writing inject('piral') will fail in a type checking error.
Since the token passed to inject must exactly match the one used as provide key, developers currently can not use the the inject function without using type-avoiding hacks (like inject('piral' as any)).
New Feature Proposal
Add typed
InjectionToken<...>
constants topiral-ng
and use them when providingpiral
,Props
andContext
using those tokens in the dependency injection container.Description
For downward-compatibility the string-based providers should probably be kept. The relevant source code parts are:
module.ts
: https://github.com/smapiot/piral/blob/1c113ff5fb1b3c9faae24dbba09c750c5e75cbc2/src/converters/piral-ng/src/module.ts#L40standalone.ts
: https://github.com/smapiot/piral/blob/1c113ff5fb1b3c9faae24dbba09c750c5e75cbc2/src/converters/piral-ng/src/standalone.ts#L49Background
Some application developers prefer the new
inject(...)
funtion over the classic@Inject(...)
annotation.inject
is typed more strictly, it does not allow a simplestring
parameter anymore, like@Inject
. So writinginject('piral')
will fail in a type checking error.Since the token passed to
inject
must exactly match the one used asprovide
key, developers currently can not use the theinject
function without using type-avoiding hacks (likeinject('piral' as any)
).Example
The following is an ad-hoc change, without even compiling/building Piral. https://github.com/hwanders/piral/commit/84347a912fda06914a6d4048d018f567b281086b