wardbell / bardjs

Spec helpers for testing angular v.1.x apps with Mocha, Jasmine and QUnit
MIT License
178 stars 34 forks source link

No Typescript type definitions available for bardjs #10

Closed thaliaarchi closed 9 years ago

thaliaarchi commented 9 years ago

I have been using bardjs in my Typescript app and have been wanting a type definition file. When Typescript doesn't have a type definition file, it will complain that the bard functions don't exist. I created an issue on the DefinitelyTyped repository (the location of all Typescript definitions) to add this.

WolfSoko commented 9 years ago

Pushing it!

wardbell commented 9 years ago

Did you folks create a bardjs.d.ts? I haven't looked. I'm thinking of rewriting it in TS which would give me a d.ts "for free".

Of course if someone wants to do that before I get to it ... happiness!

thaliaarchi commented 9 years ago

I made the definitions for bardjs in definitely typed. They are currently being reviewed in this pull request.

wardbell commented 9 years ago

Sorry I haven't looked yet. I did this in version one of breeze.d.ts long ago but haven't had to since. Maybe this week unless someone beats me to it

thaliaarchi commented 9 years ago

I have made the definition files. Would you be willing to create a few use cases for each feature in bard? I need that so I can verify my definitions and also to create the test file.

For example: bard.appModule('app');

thaliaarchi commented 9 years ago

I have finished the definition file and the tests for the definition file on DefinitelyTyped. It would be great if you could look at my definition file and tests to see if I typed everything correctly and also to see if my tests used all the functions correctly.

You can see the definitions at this pull request.

thaliaarchi commented 9 years ago

The pull request has been merged into DefinitelyTyped.

wardbell commented 9 years ago

Thanks so very much for doing this ... especially writing those tests and steering it through the process. You are my hero today!

thaliaarchi commented 9 years ago

Thanks!

tonyeung commented 8 years ago

@TepigMC @wardbell sorry to necro this. How are we supposed to use bard.inject when using typescript?

When using bard.inject(), the tsc complains about every instance of the injected service being called, because we never created a variable to hold the service.

TS2304: Cannot find name 'authenticationManager

As a workaround, declaring the variable in the first describe block AND assigning it the value of the service being generated by bard.inject() in the before each block will reduce the number of errors to 1

see below:

describe('authentication manager', () => {
    var expect = chai.expect;
    var AuthenticationManager: app.auth.IManageAuthentication; //<- typed service
    beforeEach(function () {
        bard.appModule('app.auth');
        bard.inject(this, 'authenticationManager');
        AuthenticationManager = authenticationManager; // <- only one error left here
    });
    it('should not be null',  () => {
        console.log('authentication manager should not be null');

        expect(AuthenticationManager).to.be.ok; // <- without the var at the top this would be a syntax error
    });
JuHwon commented 8 years ago

Sry to necrobump. @tonyeung i guess you already have solved this. Though for all others who might come here and search for answers: just checkout the tests of the typings file. Here you will find some answers how to use it ;)