2

I am trying to use BreezeJS with the standard Typescript type definition files. Using the test file as a guide, I have the following:

/// <reference path="../typings/breeze/breeze.d.ts" />

import breeze = module(Breeze);

class ExerciseEntityManager {
    manager: breeze.EntityManager;

    constructor() {
        this.manager = new breeze.EntityManager({
            serviceName: 'api/ExerciseItems'
        });
    }

    GetAllExercises(success: any, fail?: any) {
        var query = Breeze.EntityQuery.from('ExerciseItems');

        // TODO: Make sure this works if fail is undefined
        return this.manager.executeQuery(query)
            .then(success)
            .fail(fail);
    }
}

This compiles to the following:

var breeze = Breeze;
var ExerciseEntityManager = (function () {
    function ExerciseEntityManager() {
        this.manager = new breeze.EntityManager({
            serviceName: 'api/ExerciseItems'
        });
    }
    ExerciseEntityManager.prototype.GetAllExercises = function (success, fail) {
        var query = Breeze.EntityQuery.from('ExerciseItems');
        return this.manager.executeQuery(query).then(success).fail(fail);
    };
    return ExerciseEntityManager;
})();

When I load this into my page, I get the javascript error: 'Uncaught reference error: Breeze is not defined.' I get a similar error using the breeze-tests.ts file from the breeze repository, so I am obviously doing something wrong.

If I comment out the 'var breeze = Breeze;' line from the compiled file, it works, but this is obviously not an ideal solution.

Can anyone help?

1 Answer 1

1

The Breeze typescript definition files were updated in v 1.2.5 and I don't see the error in that build. Can you try 1.2.5 and repost as to whether that was the issue?

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.