2

I'm starting to upgrade an AngularJS app to Angular 4, and I'm trying to bootstrap it using the upgrade adapter like this in the ('entry' file for the app) - where the function is within a closure, in an independent app.ts file :

app.ts (was previously App.js):

(function () {

    import { UpgradeAdapter } from '@angular/upgrade';

    var adapter = new UpgradeAdapter();
    adapter.bootstrap(document.body, ['portalHomeApp']);
    angular
        .module('portalHomeApp', ['shared']);

I'm getting an error for the initial import of UpgradeAdapter:

An import declaration can only be used in a namespace or module

What do I need to do? Do I somehow make it available to the 'portalHomeApp' module, or do I simply now need a namespace now that I'm using TypeScript?

Chris Halcrow
  • 28,994
  • 18
  • 176
  • 206
  • 2
    you are using import inside function() – Gourav Garg Dec 01 '17 at 09:56
  • I'll add a comment that I eventually abandoned the upgrade approach in favour of completely rebuilding the app in Angular. The upgrade route turned out to be complex and messy. It was actually easier to start again from the ground up using Angular, where everything just worked like it was supposed to. – Chris Halcrow May 29 '19 at 05:08

0 Answers0