4

We are moving from SharePoint 2013 to SharePoint Online. We are thinking of migrating existing webparts in 2013, which have jquery - ajax, to SPFX client webparts. Do we have to rewrite all the code in Typescript? Or, can we inject the existing jquery ajax in Typescript?

4

A great reference when planning this move is [Migrate existing customization to the SharePoint Framework][1] in the SharePoint Framework documentation. Unfortunately, there isn't an answer that would fit every situation.

Here's a relevant quote from that section regarding whether or not you'll need to rewrite:

Given the variety of JavaScript libraries, there is no easy way to tell upfront if your existing scripts can be reused in a SharePoint Framework solution or if you need to rewrite it after all. The only way to determine this is by trying to move the different pieces to a SharePoint Framework solution and see if they work as expected.

For jQuery, in general, there is also some good guidance out there when moving to TypeScript. jQuery, in itself, can and is used in Typescript code. From How to use jQuery with TypeScript:

Most likely you need to download and include the TypeScript definition file for jQuery—jquery.d.ts—in your project.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.