Most OS X applications (particularly the ones written by Apple) are scriptable using either AppleScript or JavaScript. The API each application supports is described by an SDEF file. (See e.g. sdef /Applications/Safari.app.)
Is there any way to automatically generate .d.ts files from .sdef files, and thus create ambient typings suitable for use with TypeScript?