Project Description

High-quality (documented and strongly typed) TypeScript declarations for SharePoint 2013 JavaScript Object Model (CSOM) + lots of examples.

What's new in Release 1.2

TypeScript 0.9.1.1 support

  • SharePoint TypeScript Definitions are now compliant with the new version of TypeScript

Added and improved definitions

  • SP.RequestExecutor definitions added
  • SPAnimation definitions added
  • All SharePoint SP.ClientCollection objects are now decorated with proper generic type arguments
  • SP.SOD definitions improved
  • SPClientTemplates definitions improved

New and improved examples

  • Sample_Animation example added
  • CSRTabs example improved

What's new in Release 1.1

TypeScript 0.9 support

  • SharePoint TypeScript Definitions are now compliant with the new version of TypeScript
  • TypeScript generics are now used for defining collection classes (derivatives of SP.ClientCollection object)

Improved coverage

  • Added mQuery definitions (m$)
  • Added SPClientAutoFill definitions
  • SP.Utilities namespace is now fully covered
  • SP.UI modal dialog definitions improved
  • CSR definitions improved, added some missing methods and context properties, mostly related to list forms

More examples

  • New example: Creating a lookup by search field using Search CSOM, CSR and SPClientAutoFill
  • New example: Creating a list form with tabs using CSR
  • New example: Custom field with validation using CSR
  • New example: Using mQuery
  • New example: Textbox with autocomplete using SPClientAutoFill

Nuget

Coverage

  1. Client Side Object Model (CSOM) core classes
    • SP namespace (ready)
    • SP.WebParts (ready)
    • SP.Utilities (ready)
    • SP.SOD (ready)
    • SP.RequestExecutor (ready)
    • mQuery (ready)
  2. Social object library
    • SP.Sharing (ready)
    • SP.UserProfiles (ready)
    • SP.Social (ready)
  3. SharePoint Client Side Rendering 
    • 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)
    • SP.UI.TileView (planned)
    • SP.UI.Controls (planned)
    • SP.UI.ComboBox (planned)
    • SPClientAutoFill (ready)
    • SPAnimation (ready)
  6. SharePoint Search
    • Microsoft.SharePoint.Client.Search (ready)
  7. Business Connectivity Services
    • SP.BusinessData (ready)
  8. SharePoint Managed Metadata
    • SP.Taxonomy (ready)
  9. SharePoint Publishing Infrastructure
    • SP.Publishing (planned)

Please, contribute your definitions!

Examples

Besides the definitions, the project also contains many great examples of SharePoint JavaScript CSOM usage. No doubt, all of them are made with TypeScript!

Currently we have the following examples:

  1. JSOM: Basic tasks in SharePoint using JSOM with TypeScript
  2. JSOM: Working with taxonomy with TypeScript
  3. mQuery: Sample dynamic table
  4. Client controls: Autofill sample
  5. Client Side Rendering: Custom list view
  6. Client Side Rendering: Complexity field
  7. Client Side Rendering: Conditional formatting
  8. Client Side Rendering: Form with tabs
  9. Client Side Rendering: Custom Field with Validator
  10. Client Side Rendering: Lookup field with search
  11. Workflow Services: Retrieve list of available workflow actions
  12. Search: Using search CSOM  with TypeScript
  13. User Profiles: Retrieve properties for current user
  14. Social: Determine if the current user follows a site and follow it, if not yet

Examples project is made as a SharePoint-hosted app.

You can download the example project from Downloads tab and try it out or explore examples source code in Source Code tab.

How to add definitions to existing project

  1. Install the TypeScript add-in.

Edit csproj source file (right-click on your project in VS -> Unload project, right click again -> Edit YourProject.csproj) and include the following code:

<PropertyGroup>
    <TypeScriptTarget>ES3</TypeScriptTarget>
    <TypeScriptIncludeComments>true</TypeScriptIncludeComments>
    <TypeScriptSourceMap>true</TypeScriptSourceMap>
<TypeScriptModuleKind>CommonJS</TypeScriptModuleKind> </PropertyGroup> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" />
  1. Download the definitions file provided by this project (SharePoint.d.ts) and add this file to your project. This can also be done via Nuget:
    PM> Install-Package sharepoint.TypeScript.DefinitelyTyped
  2. Make sure that "DeploymentType" for SharePoint.d.ts is set to "NoDeployment". 
  3. Add a new TypeScript file to the project. You can add it either to a module (recommended) or to a SharePoint Mapped Folder. Set the "DeploymentType" for the .ts file to "NoDeployment", and make sure it is set to "ElementFile" (module) or "TemplateFile" (Mapped Folder) for the .js file
  4. Reference the SharePoint.d.ts by adding the following code to your .ts file (the path is relative to your .ts file):
    /// <reference path="SharePoint.d.ts"/>
  5. Enjoy!

About Authors

Andrey Markeev is SharePoint Server MVP, online expert, active blogger, published author, frequent speaker. He works as a Senior SharePoint Consultant at NED Software Consulting Oy (Helsinki, Finland).

Stanislav Vyshchepan is SharePoint Server MVP, Solutions Architect at i-Teco (Moscow, Russia), Certified Trainer and SharePoint Development coach.

 

Last edited Sep 18, 2013 at 7:11 PM by omlin, version 42