1 | // Copyright (c) Jupyter Development Team.
|
2 | // Distributed under the terms of the Modified BSD License.
|
3 | /*-----------------------------------------------------------------------------
|
4 | | Copyright (c) 2014-2017, PhosphorJS Contributors
|
5 | |
|
6 | | Distributed under the terms of the BSD 3-Clause License.
|
7 | |
|
8 | | The full license is in the file LICENSE, distributed with this software.
|
9 | |----------------------------------------------------------------------------*/
|
10 |
|
11 | /**
|
12 | * A runtime object which captures compile-time type information.
|
13 | *
|
14 | * #### Notes
|
15 | * A token captures the compile-time type of an interface or class in
|
16 | * an object which can be used at runtime in a type-safe fashion.
|
17 | */
|
18 | export class Token<T> {
|
19 | /**
|
20 | * Construct a new token.
|
21 | *
|
22 | * @param name - A human readable name for the token.
|
23 | */
|
24 | constructor(name: string) {
|
25 | this.name = name;
|
26 | this._tokenStructuralPropertyT = null!;
|
27 | }
|
28 |
|
29 | /**
|
30 | * The human readable name for the token.
|
31 | *
|
32 | * #### Notes
|
33 | * This can be useful for debugging and logging.
|
34 | */
|
35 | readonly name: string;
|
36 |
|
37 | // @ts-ignore
|
38 | private _tokenStructuralPropertyT: T;
|
39 | }
|