No, it's not possible right out of the box. See this answer for more reference.
Possible Solutions
I'm not sure why you'd want or need to do this, but some possible solutions to your problem could be one of the following:
- Add a static property (ex.
fullyQualifiedName
) that contains a string with the fully qualified name in it. Write a unit test to run through your modules to ensure the name is correct on any class that has that static property.
- Add a static property again, but this time have your build script automatically fill in the name property.
- Have a method that runs at the start of your application that will fill in the static property of any classes in the module passed to it.
Example
An example of how to do this is the following:
module TestModule {
export class TestClass1 {
// initialize it to undefined or null to ensure the
// typescript compiler adds it as a property
static fullyQualifiedName: string = undefined as any;
}
export module OtherModule {
export class TestClass2 {
static fullyQualifiedName: string = undefined as any;
}
export class TestClass3 {
}
}
}
function fillFullyQualifiedName(m: any, name: string) {
// if it's a module
if (typeof m === "object") {
for (const propName of Object.keys(m)) {
fillFullyQualifiedName(m[propName], name + "." + propName);
}
}
// else, if it's a class with the fullyQualifiedName property
else if (typeof m === "function" && m.hasOwnProperty("fullyQualifiedName")) {
m["fullyQualifiedName"] = name;
}
}
fillFullyQualifiedName(TestModule, "TestModule");
// some tests...
TestModule.TestClass1.fullyQualifiedName === "TestModule.TestClass1";
TestModule.OtherModule.TestClass2.fullyQualifiedName === "TestModule.OtherModule.TestClass2";
TestModule.OtherModule.TestClass3["fullyQualifiedName"] == null;
I didn't test that very much, but it should help you get the idea and apply it to any of the possible solutions I listed above.