A. Duff A. Duff - 1 year ago 140
TypeScript Question

Force Typescript to recognize __moduleName

I'm trying to set up a build environment for Angular2 and SystemJs, such that I can import components from external libraries, which are defined like so:

moduleId: __moduleName,
selector: 'foo-selector',
templateUrl: 'foo.component.html'

I know for sure that this is what I want to use, because it works when I run it. But Typescript compilation fails because it can't recognize
. How can I tell Typescript to recognize this, or at least, not to complain about it?

This is with Typescript version 2.1.0-dev.20160915 and
is set to

Answer Source

You can try to add this line to your typings/index.d.ts file:

declare var __moduleName: string;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download