This project is read-only.

Issues using "CrmRestKit." in a TypeScript file


Hi there,

I have a custom TypeScript class that invokes a method using the CrmRestKit object. However, when I attempt to use "CrmRestKit.ByQuery" method, my TypeScript file tells me that the "CrmRestKit" does not exist. I've got the "CrmRestKit+BlueBird.js" and "CrmRestKit.d.ts" file installed and referenced in my solution already.

In addition, I'm not using requirejs, so when the rest kit is initialized on load, it's put into the window browser globals.

When I convert the TypeScript to JavaScript and plug it into dynamics, everything works beautifully. My only issue is with the TypeScript compiler not knowing what the CrmRestKit object is. I also don't see any interface for it.

Any help you can provide is appreciated.


file attachments


thuld wrote Jul 16, 2014 at 4:03 PM

@patrickverbeeten: Could you address this issue.

wrote Jul 16, 2014 at 4:41 PM

mjfaga wrote Jul 16, 2014 at 4:41 PM

Thanks thuld. I spent some more time last night working on this and refactored some of the CrmRestKit.d.ts file (effectively had to remove the wrapper module and added a global CrmRestKit variable). I've attached it for reference. It contains some of the updates I already submitted in a patch yesterday, plus a few more additions/modifications, including a ByQuerySync method. I left my "TODO" comments indicating what I changed in place for reference. With these changes, everything is working great.

If I'm misusing the definition file, I'm happy to understand what I'm doing wrong.

wrote Jul 17, 2014 at 11:49 PM

mjfaga wrote Jul 17, 2014 at 11:49 PM

Hi again... made some progress and was able to undo the removal of the "RestKit" module. That's back in place. Turns out all I needed to do was update the definition file to export each individual interface, class and module instead. I've attached an updated version of what we are using. This is essentially you out of the box file with some additional functionality added.

Once I think we are done adding things, I'll probably be submitting another patch.

Let me know if you have any questions.

thuld wrote Jul 18, 2014 at 6:48 AM

Hi mifaga,

to be hornets I am not very familiar with TypeScript. patrickverbeeten Created the TypeScript stuff.


wrote Dec 9, 2017 at 11:34 PM