Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript is not happy with the types on 6.0.0 #210

Closed
JoelParke opened this issue Jun 17, 2017 · 4 comments
Closed

typescript is not happy with the types on 6.0.0 #210

JoelParke opened this issue Jun 17, 2017 · 4 comments

Comments

@JoelParke
Copy link
Contributor

JoelParke commented Jun 17, 2017

BEFORE you spend much time on this.... I noticed that I also have a build issue with tsc. I will report back once I verify this issue.... Hopefully it is an issue with my build... -- we will see.

I went back to v4.1.0 to verify. I had several places where I was using streaming.
First : typescript was screaming... (not really an issue, but I don't believe that I should have to modify my code which was built off of the example for monk.)

Second: I modified my local @types/monk, to eliminate the typescript errors...
But then my typical streaming code returns nothing!

An example of that looks like:

     lists.find({})
      .each((list: ListData) => { .... })
      .catch(...)
      .then(....)

When I went back to 4.0.1, all I needed to do, to eliminate the typescript errors was to modify the promise interface and add (catch(), then(), and each()):

     export interface promise {
         type:string
        on(eventName:string, fn:Function):void;
        error(fn:Function):promise;
        catch(fn:Function):promise;
        success(fn:Function):promise;
        each(fn:Function):promise;
        then(fn:Function):promise;
    }

So that I didn't need to change my code much.

I am VERY glad to see the progress on monk with the inclusion of the typescript stuff. And hope the issues with each() is resolved soon!

@mathieudutour
Copy link
Collaborator

I'm not very fluent in typescript. Happy to accept any PR to improve the examples/types for it tho

@mathieudutour mathieudutour changed the title 6.0.0 is badly broken typescript is not happy with the types on 6.0.0 Jun 22, 2017
@JoelParke
Copy link
Contributor Author

JoelParke commented Aug 24, 2017

I recently moved to the latest release. Some things have improved in this regard, but I still have several places where I have to do:

(<any> user).find({}).then(....) 

otherwise I see TS2349 errors. Note I am now using the very latest typescript tool.
NOTE: here, user is a monk.ICollection from db.get('users').

While moving to the latest 6.0.3 release I also found a VERY serious error using .each() which I will report as a different issue in a few minutes.

I also am not very fluent in typescript, but I appreciate it very much because it helps me find MANY errors. Also thanks VERY much for maintaining monk! If I get some time, after my current release deadline, I will attempt to learn some more and see if I can't devise some typescript that can help with this issue around TS2349.

@mathieudutour
Copy link
Collaborator

should be fixed in 6.0.4

@JoelParke
Copy link
Contributor Author

THANKS!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants