.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

TypeScript for SharePoint 2013

Posted By:Sagar Pardeshi       Posted Date: February 23, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

TypeScript for SharePoint 2013
 

Introduction

SharePoint 2013 is all about JavaScript. JavaScript CSOM is greatly improved and enhanced, SharePoint Apps are essentially JavaScript-based, Client Side Rendering is now the main rendering technique for all SharePoint lists (well, except for Survey and Calendar lists), JSGrid is used for list edit mode, and many many other things.

Yes, JavaScript won, so now we, SharePoint developers, have to deal with it much more often than we used to.

Script#

People noticed drawbacks of JS long ago. To smooth them out, projects like Script# and GWT were created. The idea is basically to compile a normal language like C# into JavaScript code - this is exactly what Script# does.

And it works well enough! Script# has been used by Microsoft itself for some big projects, like Office Web Apps, Bing Maps, and by pure happenstance, for SharePoint JavaScript Object Model (JSOM)! Can you believe that? But yes, it's true, majority of js files you will find in 15 hive was generated by Script#.

Yes, Script# works very well... unless you must use some existing JS libraries. In this case, you need definitions that would contain information about types of variables, parameters, methods, etc. Unfortunately, no Script# definitions for SharePoint is available. And creating them by hand is a very tedious work, trust me. But wait, if SharePoint JSOM is written in Script#,

TypeScript

Not so long ago, another project has been started by Microsoft, TypeScript. Unlike Script# and GWT, which use existing languages (C# and Java) as the source, TypeScript is a new language. But the thing is, TypeScript is a superset of JavaScript! So any existing JS can compile in TypeScript without errors (at least this is the theory, in practice I know some exceptions from this rule).

Support of TypeScript is broad, community is passionate, and TypeScript definitions for many and many JS libraries have already been created. The biggest collection of them (DefinitelyTyped project) includes definitions for 130 different libraries!!

TypeScript compiler is opensource and is written in JavaScript, and this means that we can have TypeScript intellisense right in browser.

In sum, TypeScript is definitely promising. And even better, now you can use it with SharePoint!

create high-quality strongly-typed and even half-documented definitions which cover great deal of SharePoint JavaScript API (and we plan to add even more definitions in next releases).

Currently, we have the following things covered:

  1. Client Side Object Model (CSOM) core classes
    • SP namespace (ready)
    • SP.WebParts (ready)
    • SP.SOD (ready)
  2. Social object library
    • SP.Sharing (ready)
    • SP.UserProfiles (ready)
    • SP.Social (ready)
  3. SharePoint Client Side Rendering (CSR) 
    • SPClientTemplates (ready)
  4. Workflows
    • SP.Workflow (ready)
    • SP.WorkflowServices (ready)
  5. SharePoint UI elements:
    • SP.UI.Notify (ready)
    • SP.UI.Status (ready)
    • SP.UI.Menu (ready)
    • SP.UI.ModalDialog (ready)
    • SP.UI.ApplicationPages - some useful stuff here nobody knows about e.g. ClientPeoplePickerWebServiceInterface! (ready)
    • CalloutManager (ready)
  6. SharePoint Search
    • Microsoft.SharePoint.Client.Search (ready)
  7. Business Connectivity Services
    • SP.BusinessData (ready)
  8. SharePoint Managed Metadata
    • SP.Taxonomy (ready)

Basically this means that now you and we - all of us can use TypeScript when working with SharePoint JavaScript, and benefit from strong typing and intellisense.

Project also includes many examples written in TypeScript and a couple of extensions. Please, visit the project site on CodePlex to find out more:

 

SharePoint 2013 TypeScript Definitions

 

TypeScript Important Links

http://typescript.codeplex.com/

http://www.typescriptlang.org/Samples/

http://www.typescriptlang.org/

 

 


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend