1

I try start use TypeScript 2.4.1 on my old AngularJS project. Firstly I try to refactor my simple controller to ts. On controller, I use anonymous function in compile process get Error:(35, 11) TS2339:Property 'app' does not exist on type 'Window'.

  (function (app) {
    'use strict';
    app.ReservationModule.controller('ItineraryController', ItineraryController);

    ItineraryController.$inject = [
        'SeatMapService',
        'SeatMapSegments'
    ];

    /**
     *  Controlling interaction between seatMap service and Itinerary view.
     */
    function ItineraryController(SeatMapService:any, SeatMapSegments:any) {

        const vm = this;
        vm.deselectService = deselectService;
        vm.show = show;

        /**
         * Deselect traveller seat on seatMap service by segment.
         */
        function deselectService(traveller, segment) {
            SeatMapService.deselectService(traveller, segment);
        }

        /**
         * Returns true if segment has new seatMap service.
         * @param segment
         * @return {boolean}
         */
        function show(segment) {
            return SeatMapSegments.getSegment(segment).hasNewSeatsService();
        }
    }
})(window.app); // type script error reason is here
0

1 Answer 1

6

Make window dynamic.

(<any>window).app

You can also reference this question: How do you explicitly set a new property on `window` in TypeScript?

Sign up to request clarification or add additional context in comments.

3 Comments

Seems like you just copied someone else's answer. If you think the two questions are the same, then vote to close as a duplicate.
Seems like I answered the question and referenced another question. Calling me down won't help this guy. My answer will.
And your whole thing of copying an answer is ridiculous. I already knew the answer and found the post that I learned it from (and that I had already upvoted) and linked it. EVERY answer is copied from somewhere, even if it's the doc, and I don't see people getting downvoted for those.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.