What are Symbols?

Symbols are a new primitive data type available in ES6. With Symbol() we can create a new value that’s not equal to any other value, which is important when avoiding collisions is critical as when dealing with an IoC container.

How are Symbols used in Masquerade?

Each Service Provider should be registered with a unique Symbol to ensure the global integrity of any resolution calls.
This is achieved by exporting a single constant referencing the Symbol in our symbols.ts file.
export const Foo: unique symbol = Symbol.for("FooProvider")
This symbol should be imported when manually resolving your service from the container.
import * as Symbols from "../symbols"
const foo: FooContract = container.resolve<FooContract>(Symbols.Foo)
Although the container accepts strings as resolution tokens, we highly recommend defining a Symbol and using it in this way to avoid collisions.