Skip to content

refine value provider check if user passes a 'undefined' value#205

Open
intellild wants to merge 1 commit into
microsoft:masterfrom
intellild:value_provider_undefined
Open

refine value provider check if user passes a 'undefined' value#205
intellild wants to merge 1 commit into
microsoft:masterfrom
intellild:value_provider_undefined

Conversation

@intellild
Copy link
Copy Markdown

@intellild intellild commented Jul 29, 2022

If user pass { useValue: undefined }, isProvider returns false,
causing

if (!isProvider(providerOrConstructor)) {
treat the object as a class


Open with GitKraken

@intellild intellild changed the title allow 'undefined' value for value provider refine value provider check if user passes a 'undefined' value Jul 29, 2022
@risenxxx
Copy link
Copy Markdown

Fixed this in tsyringe-neo

@etiennenoel
Copy link
Copy Markdown
Collaborator

What is the use case to register undefined for a certain token? Would using the new isOptional property of @inject solve this?

@intellild
Copy link
Copy Markdown
Author

What is the use case to register undefined for a certain token? Would using the new isOptional property of @inject solve this?

isOptional won't work, the use case is that register is called dynamically at runtime and the value could be undefined as expected. The issue is isValueProvider check is not accurate and the provider is treated as other providers and result in unexpected behavior.

@intellild
Copy link
Copy Markdown
Author

@intellild please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

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 this pull request may close these issues.

3 participants