2013-11-17

It has been a while since I had a chance to enjoy TypeScript while crafting solutions for SharePoint 2010 and 2013. Not SharePoint 2010, nor SharePoint 2013 provide definitions for its JavaScript object model. Hence, a few SharePoint MVPs (@amarkeev and @gandjustas) have come up with an incredible project “SharePoint 2013 TypeScript Definitions” to make it possible leveraging TypeScript with SharePoint apps.

Actually, out of the box, TypeScript provides little support to utilize 3rd part libraries, frameworks or products. However, there is a rapidly growing community, and DefinitelyTyped repository enables most popular libraries to be used with TypeScript.

What is the issue?

Well, the same story has to do with recent JavaScript API for Office, which makes it possible to write apps for Microsoft Office products; Word, Excel, Outlook, Project and PowerPoint. There isan open API provided by Office.js file, but nothing much for TypeScript yet. Writing pure js, even with intellisence might not be the best option, so why wouldn’t e create TypeScript definitions for JavaScript Office API, then?

I spent last week playing with Office Apps and checking if anyone has already come up with that, but it seems that Office apps is not popular topic yet, and there are no definitions for TypeScript out there. Well, not a big deal, we may always create them on our own.

Office.js TypeScript Definitions

So, you want to write an Office app, but “tired” of poor-typed JavaScript and always forget “small details” so that the development experience becomes painful? No worries, check outTypeScript and Office.js TypeScript Definitions.

Much better, huh?

As for the coverage, the project has just been started, so there is a long ride ahead. Current implementation could be seen here:

Object Mail app Content app Task pane app Status
Appointment x
AsyncResult x x x done
AttachmentDetails x
Binding x x done
Bindings  x  x done
Contact  x
Context  x  x x done
CustomProperties x x (Word)
CustomXmlNode x (Word)
CustomXmlPart x (Word)
CustomXmlParts x (Word)
CustomXmlPrefixMappings x (Word)
Diagnostics
Document  x x done
EmailAddressDetails  x
EmailUser x
Entities x
Error x x  x done
File  x
Item x
Mailbox x
MatrixBinding  x  x done
MeetingRequest x
MeetingSuggestion x
MeetingSuggestion x
Message x
Office x  x  x done
PhoneNumber  x
ProjectDocument  x (Project)
RoamingSettings  x
Settings  x x  done
TableBinding x x done
TableData x x done
TextBinding x  x done
TaskSuggestion x
Slice  x
UserProfile  x
Enumerations  in progress

A full and up to time table might be found at the official project site – Office.js TypeScript Definitions.

Examples

For the start, there is only one example with stands for the default Word task pane application. It shows basic Office app design and allows query current selection from the document. Basically, default VS template and code was rewritten with TypeScript and Office.js TypeScript Definitions.

Be patient, more samples and coverage are to come.

What is next?

Well, there are lots of Office API which have not been covered yet. Step by step, Office.js TypeScript Definitions would provide full coverage of JavaScript API for Office.

Also, it would be nice if you had a chance to share your own experience with TypeScript andOffice.js TypeScript Definitions; suggestions, improvement and any other feedback are highly appreciated. If you want to join – go ahead, will work it out together.

Links

Conclusion

TypeScript could provide a better development experience, but lack of the definitions might not allow you to leverage the full potential of TypeScript’s features.

Office.js TypeScript Definitions project is supposed to enable TypeScript utilization while writing Office apps. Take a look, play with that and see how it might be useful for your projects.

About the author 

Anton Vishnyakov