nicojs / typed-inject

Type safe dependency injection for TypeScript
Apache License 2.0
448 stars 23 forks source link

feat(as const): allow to declare tokens as const #27

Closed nicojs closed 4 years ago

nicojs commented 4 years ago

Allow to declare tokens as const.

This:

class Foo {
  static inject = tokens('bar');
}

Can now also be specified as:

class Foo {
  static inject = ['bar'] as const;
}

Fixes #23

BREAKING CHANGE: The typed-inject is now expecting tokens to be provided in a readonly array. You can either use as const or the tokens helper function for it.