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

Use default class property for @optional injected properties #1467

Merged
merged 6 commits into from
Oct 17, 2023

Commits on Jun 23, 2022

  1. Use default class property for @optional injected properties

    Currently the @optional tag overrides class properties defined with typescript-style default values:
    ```typescript
    @Injectable()
    class Ninja {
        @Inject(Weapon) @optional() weapon: Weapon = new Katana();
    
        ....
    }
    ```
    this currently sets the weapon property to `undefined` if no Weapon is present in the container. My proposed change allows does not override the default and results in the weapon property being set to new Katana().
    
    (Default values in the constructor already work, but I would prefer not to add boilerplate constructors if this solution is possible.)
    haaijman-imagem committed Jun 23, 2022
    Configuration menu
    Copy the full SHA
    a938e44 View commit details
    Browse the repository at this point in the history

Commits on Aug 13, 2022

  1. Configuration menu
    Copy the full SHA
    dc9e16a View commit details
    Browse the repository at this point in the history

Commits on Sep 13, 2023

  1. Configuration menu
    Copy the full SHA
    1cfb828 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    65e8b52 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    68fbf1a View commit details
    Browse the repository at this point in the history

Commits on Oct 17, 2023

  1. Configuration menu
    Copy the full SHA
    56055bf View commit details
    Browse the repository at this point in the history