microsoft / tsyringe

Lightweight dependency injection container for JavaScript/TypeScript
MIT License
5.19k stars 172 forks source link

@scope options don't match the documentation #160

Open ivandotv opened 3 years ago

ivandotv commented 3 years ago

Describe the bug

Documentation for @scope says that there are four possible options for lifecycle however, TS gives us only two.

// scoped.d.ts
export default function scoped<T>(lifecycle: Lifecycle.ContainerScoped | Lifecycle.ResolutionScoped, token?: InjectionToken<T>): (target: constructor<T>) => void;

Expected behavior

I expect all four versions to be available. Other options are very convenient. For example, I have a hybrid app, and on the server, I need a new instance every time, but in the browser, I need a singleton.

@scoped(type of window === 'undefined' ? Lifecycle.Transient : Lifecycle.Singleton)

Version: 4.5.0

killerchip commented 2 years ago

Is this still awaiting triage? Isn't this a bug? Or is "By Design" supporting only these two scopes?

semiautomatixfu commented 2 years ago

How is this still an issue?