Reputation: 2071
I've come across an unusual hurdle with TypeScript regarding definitions. I've attempting to write a definition file for the (very simple) Backbone.Syphon library. The Backbone.Syphon object contains only two methods, serialize
and deserialize
. However, I've been unable to successfully write a definition file.
My existing definition file is as follows (leaving off the deserialize for now, because its orthogonal to the question at hand):
define module Backbone
class Syphon {
serialize(view: Backbone.View, options: any): any;
}
}
Yet, when attempting to use Backbone.Syphon.serialize()
anywhere, the error I receive is:
error TS2094: The property 'serialize' does not exist on value of type 'typeof Backbone.Syphon'
Upvotes: 1
Views: 124
Reputation: 221192
This should look something like:
define module Backbone.Syphon {
function serialize(view: Backbone.View, options: any): any;
// function deserialize(/* etc */): any;
class KeyExtractorSet {
registerDefault(thing: ($el: any) => void): void;
}
module KeyExtractors {
function register(name: string, thing: ($el: any) => any): void;
}
/* ... more ... */
}
Upvotes: 2