TypeScript Definition file for SPServices v0.1

Here’s something I have wanted to write for a long time, both as Thank-You to Marc Anderson’s work on SPServices, as well as for personal learning of the TypeScript language.

Adding TypeScript Definition reference:

image

$().sp (intellisense)

image

$().SPServices.defaults.cacheXML

image

$().SPServices.Version()

image

$().SPServices.SPCascadeDropdowns({ … })

image

And one more.

$().SPServices({ … })

image

Syntax Error Detection that TypeScript does so well. 

Except for the error message.

Repeat after me in a ROBOT way.  “String is missing apply from type Function”.

What it means is I was expecting a function why did I find a string. 

And because Javascript can be surprisingly retarded, TypeScript tries to accommodate and wonders: perhaps this string is a function in disguise - so let me look for the apply method on this object.  NOPE.  It is not a function.   /s

image

Bonus.  TypeScript understands SPServices returns a JQueryXHR promise object.

image

Wait.  Where’s all the other methods?

This is v0.1…

Download

jquery.SPServices.d.ts.d

Also, how do I get this into Marc’s repo?

Discussions