I'm trying to use Angular 1.x with TypeScript 1.5.3 and SystemJS. The index.html
page is set up to System.import('bootstrapper')
which should start things up.
bootstrapper.ts
gets compiled to bootstrapper.js
and works fine as long as it doesn't use angular (i.e. doing just a console.log()
works ok)
Now, I'd like to import and use angular to bootstrap it. I've already done jspm install angular
and I also installed some typings for angular using tsd
. The typings are referenced at the top of the bootstrap.ts
file.
Unfortunately doing import angular from 'angular'
doesn't compile, I get Module "angular" has no default export
. My questions are:
- Why doesn't
import angular from 'angular'
compile? Looking in theangular.d.ts
file I seedeclare module 'angular'{ export = angular; }
which, if I understand correctly, is a default export from the module angular of a variable (defined above in the typings file)declare var angular: angular.IAngularStatic
- I noticed that doing
import 'angular'
compiles and then I can actually referenceangular
and do e.g.angular.module(...)
, but I don't think I understand correctly how this works. Shouldn'timport 'angular'
do a "bare import", i.e. running a module only for its side effects? If that's the case, does that mean that this import actually registersangular
in the global scope?
I'm pretty sure I don't understand correctly how modules/type definition files work in Typescript, thanks in advance for an explanation.