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

regression: inversify 6 no longer allows binding null values #1519

Open
simhnna opened this issue Jul 26, 2023 · 3 comments
Open

regression: inversify 6 no longer allows binding null values #1519

simhnna opened this issue Jul 26, 2023 · 3 comments
Assignees
Milestone

Comments

@simhnna
Copy link

simhnna commented Jul 26, 2023

Used to work in inversify 5

import { Container } from "inversify";

const container = new Container();
const s = Symbol('foo');
container.bind(s).toConstantValue(null);


console.log(container.get(s));

Produces:

/project/node_modules/inversify/lib/utils/binding_utils.js:62
        throw new Error(ERROR_MSGS.INVALID_BINDING_TYPE + " " + serviceIdentifierAsString);
              ^

Error: Invalid binding type: Symbol(foo)
    at ensureFullyBound (/project/node_modules/inversify/lib/utils/binding_utils.js:62:15)
    at _getResolvedFromBinding (/project/node_modules/inversify/lib/resolution/resolver.js:99:42)
    at /project/node_modules/inversify/lib/resolution/resolver.js:127:22
    at _resolveInScope (/project/node_modules/inversify/lib/resolution/resolver.js:121:14)
    at _resolveBinding (/project/node_modules/inversify/lib/resolution/resolver.js:126:12)
    at /project/node_modules/inversify/lib/resolution/resolver.js:88:20
    at resolve (/project/node_modules/inversify/lib/resolution/resolver.js:225:12)
    at /project/node_modules/inversify/lib/container/container.js:622:49
    at Container._get (/project/node_modules/inversify/lib/container/container.js:590:38)
    at Container._getButThrowIfAsync (/project/node_modules/inversify/lib/container/container.js:593:27)
@weyert
Copy link

weyert commented Oct 16, 2023

Have you found a solution for this?

@simhnna
Copy link
Author

simhnna commented Oct 17, 2023

You can wrap primitives { value: null }

It's currently no longer a high priority for my projects. If I have time I might try creating a merge request that allows binding null values but understanding the code of inversofy isn't very easy...

@Jameskmonger Jameskmonger added this to the 6.0.3 milestone Dec 17, 2023
@Jameskmonger
Copy link
Member

Added to milestone 6.0.3, we will aim to resolve this regression as a priority. cc @PodaruDragos

@Jameskmonger Jameskmonger self-assigned this Dec 17, 2023
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

No branches or pull requests

3 participants